Skip to content

Commit 90b3dce

Browse files
chriscamachoraysan5
authored andcommitted
added GetMatrixProjection fixed issue with GL11 where model matrix was identity (raysan5#999)
1 parent a6db31c commit 90b3dce

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/raylib.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ typedef struct Sound {
432432
typedef struct Music {
433433
int ctxType; // Type of music context (audio filetype)
434434
void *ctxData; // Audio context data, depends on type
435-
435+
436436
unsigned int sampleCount; // Total number of samples
437437
unsigned int loopCount; // Loops count (times music will play), 0 means infinite loop
438438

@@ -1319,6 +1319,7 @@ RLAPI void SetShaderValueTexture(Shader shader, int uniformLoc, Texture2D textur
13191319
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
13201320
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
13211321
RLAPI Matrix GetMatrixModelview(void); // Get internal modelview matrix
1322+
RLAPI Matrix GetMatrixProjection(void); // Get internal projection matrix
13221323

13231324
// Texture maps generation (PBR)
13241325
// NOTE: Required shaders should be provided

src/rlgl.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,6 +3155,23 @@ void SetMatrixProjection(Matrix proj)
31553155
#endif
31563156
}
31573157

3158+
// Return internal projection matrix
3159+
Matrix GetMatrixProjection(void) {
3160+
#if defined(GRAPHICS_API_OPENGL_11)
3161+
float mat[16];
3162+
glGetFloatv(GL_PROJECTION_MATRIX,mat);
3163+
Matrix m;
3164+
m.m0 = mat[0]; m.m1 = mat[1]; m.m2 = mat[2]; m.m3 = mat[3];
3165+
m.m4 = mat[4]; m.m5 = mat[5]; m.m6 = mat[6]; m.m7 = mat[7];
3166+
m.m8 = mat[8]; m.m9 = mat[9]; m.m10 = mat[10]; m.m11 = mat[11];
3167+
m.m12 = mat[12]; m.m13 = mat[13]; m.m14 = mat[14]; m.m15 = mat[15];
3168+
return m;
3169+
#else
3170+
return projection;
3171+
#endif
3172+
#
3173+
}
3174+
31583175
// Set a custom modelview matrix (replaces internal modelview matrix)
31593176
void SetMatrixModelview(Matrix view)
31603177
{
@@ -3170,6 +3187,10 @@ Matrix GetMatrixModelview(void)
31703187
#if defined(GRAPHICS_API_OPENGL_11)
31713188
float mat[16];
31723189
glGetFloatv(GL_MODELVIEW_MATRIX, mat);
3190+
matrix.m0 = mat[0]; matrix.m1 = mat[1]; matrix.m2 = mat[2]; matrix.m3 = mat[3];
3191+
matrix.m4 = mat[4]; matrix.m5 = mat[5]; matrix.m6 = mat[6]; matrix.m7 = mat[7];
3192+
matrix.m8 = mat[8]; matrix.m9 = mat[9]; matrix.m10 = mat[10]; matrix.m11 = mat[11];
3193+
matrix.m12 = mat[12]; matrix.m13 = mat[13]; matrix.m14 = mat[14]; matrix.m15 = mat[15];
31733194
#else
31743195
matrix = modelview;
31753196
#endif

0 commit comments

Comments
 (0)