diff --git a/GL/matrix.c b/GL/matrix.c index d4ce3ff..85f0233 100644 --- a/GL/matrix.c +++ b/GL/matrix.c @@ -33,6 +33,10 @@ static const matrix_t IDENTITY = { void APIENTRY glDepthRange(GLclampf n, GLclampf f); +matrix_t* _glGetProjectionMatrix() { + return (matrix_t*) stack_top(&MATRIX_STACKS[1]); +} + void initMatrices() { init_stack(&MATRIX_STACKS[0], sizeof(matrix_t), 32); init_stack(&MATRIX_STACKS[1], sizeof(matrix_t), 32); diff --git a/GL/private.h b/GL/private.h index 9a63e0e..9a738e8 100644 --- a/GL/private.h +++ b/GL/private.h @@ -108,6 +108,8 @@ void _matrixLoadModelView(); void _matrixLoadTexture(); void _applyRenderMatrix(); +matrix_t* _glGetProjectionMatrix(); + void wipeTextureOnFramebuffers(GLuint texture); GLubyte checkImmediateModeInactive(const char* func); diff --git a/GL/state.c b/GL/state.c index 5bf43ad..5a38d78 100644 --- a/GL/state.c +++ b/GL/state.c @@ -563,6 +563,18 @@ void APIENTRY glGetBooleanv(GLenum pname, GLboolean* params) { } } +void APIENTRY glGetFloatv(GLenum pname, GLfloat* params) { + switch(pname) { + case GL_PROJECTION_MATRIX: + memcpy(params, _glGetProjectionMatrix(), sizeof(float) * 16); + break; + default: + _glKosThrowError(GL_INVALID_ENUM, "glGetIntegerv"); + _glKosPrintError(); + break; + } +} + void APIENTRY glGetIntegerv(GLenum pname, GLint *params) { switch(pname) { case GL_MAX_LIGHTS: diff --git a/containers/named_array.c b/containers/named_array.c index 4ae07bd..3aac6b5 100644 --- a/containers/named_array.c +++ b/containers/named_array.c @@ -60,8 +60,8 @@ void* named_array_alloc(NamedArray* array, unsigned int* new_id) { void* named_array_reserve(NamedArray* array, unsigned int id) { if(!named_array_used(array, id)) { - unsigned int j = id % 8; - unsigned int i = (id - j) / 8; + unsigned int j = (id % 8) - 1; + unsigned int i = id / 8; assert(!named_array_used(array, id)); array->used_markers[i] |= (unsigned char) 1 << j;