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, 1.0f,
- 1.0f,-1.0f, 1.0f, 0.0f, 0.0f,
- 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
+ 1.0f,-1.0f, 1.0f, 0.0f, 0.0f,
+ 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
// back
-1.0f,-1.0f,-1.0f, 0.0f, 0.0f,
-1.0f, 1.0f,-1.0f, 0.0f, 1.0f,
- 1.0f,-1.0f,-1.0f, 1.0f, 0.0f,
- 1.0f,-1.0f,-1.0f, 1.0f, 0.0f,
+ 1.0f,-1.0f,-1.0f, 1.0f, 0.0f,
+ 1.0f,-1.0f,-1.0f, 1.0f, 0.0f,
-1.0f, 1.0f,-1.0f, 0.0f, 1.0f,
- 1.0f, 1.0f,-1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f,-1.0f, 1.0f, 1.0f,
// left
-1.0f,-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f,-1.0f, 0.0f, 0.0f,
1.0f,-1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f, 0.0f, 0.0f,
+ 1.0f, 1.0f, 1.0f, 0.0f, 1.0f
};
static bool initilised = false;
-static unsigned int vbo, vao, transformLoc;
+static unsigned int vbo, vao, transformLoc, cameraLoc;
static crpgShader *shader = NULL;
static crpgTexture *tex = NULL;
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, &ct->transform);
}
+void crpgCubeSetCamera(crpgCube *c, mat4_t *cam)
+{
+ Cube_t *ct = (Cube_t *) c;
+ crpgShaderUse(shader);
+ unsigned int loc = glGetUniformLocation(crpgShaderID(shader), "camera");
+ glUniformMatrix4fv(loc, 1, GL_FALSE, cam);
+ crpgShaderUse(0);
+}
+
static bool printed = false;
void crpgCubeRender(crpgCube *c)
{