What are gl_ModelViewMatrix and gl_ModelViewProjectionMatrix in modern OpenGL?

I have this code which is the context of "#version 330 core"

gl_Position =           PerspectiveViewMatrix(90.0, AspectRatio, 0.01, 1000.0  )


                        *    TranslationMatrix(0, 0, -4 -0.35*MouseWheel)        


                        *    RotationMatrix(MouseMovement.y, X_AXIS)        
                        *    RotationMatrix(-MouseMovement.x, Y_AXIS)    
                        *    RotationMatrix(float(Strafing*3), Z_AXIS)    


                        *    TransformationMatrix

                        *    in_Vertex;

Which part of them is the old gl_ModelViewMatrix, and which part is gl_ModelViewProjectionMatrix? (What is gl_ProjectionMatrix that was used to create the ModelViewProjection?)

+5
source share
1 answer

I'm not too familiar with GLSL 3.3, but I'm sure that PerspectiveViewMatrix (is this even a builin function?) Builds a matrix that replaces the old built-in gl_ProjectionMatrix

gl_ModelViewMatrix "" , TranslationMatrix, RotationMatrix TransformationMatrix.


, . . (, GLM). :

// in your app

std::array<GLfloat, 16> projection;

glMatrixMode(GL_PROJECTION);
glPushMatrix();
gluOrtho(...);
glGetFloatv(GL_PROJECTION_MATRIX, projection.data());
glPopMatrix();

glUniformMatrix4fv(glGetUniformLocation(ShaderProgramID, "ProjectionMatrix"), 1, GL_FALSE, projection.data());

// in vertex shader

uniform mat4 ProjectionMatrix;
in vec4 InVertex;

void main() {
    gl_Position = ProjectionMatrix * InVertex;
}
+6

All Articles