GLSL 1.4 and gl_ModelViewProjectionMatrix

Hello,

since the built-in uniforms gl_ModelViewMatrix, gl_ModelView,
gl_ProjectionMatrix and gl_NormalMatrix are deprecated I
wonder which alternative you are using?

My first thought was to use this code (gluPerspective) to calculate
an own “gl_ProjectionMatrix” and this code to calculate the
“gl_ModelView” matrix.

Then I can make these matrices available in the shader
using glUniformMatrix4fv, right?

Is this a good way to do it? Does anybody already have some
code to calculate the gl_NormalMatrix. According to this article it is
the transpose of the inverse of the upper 3x3 gl_ModelViewMatrix.

And a last question, how to replace the glViewport() stuff,
I guess it is also deprecated?

Thanks :slight_smile:

Best regards!

You can use to calculate whatever library you would like to use (even your own one). Personally, I prefer GLM.

In order to access the matrix in the shader you can either use standard uniforms or you can also use uniform buffers.

No matter how you make the required matrices available for your shader, the responsibility to do so it is up to your application.

Personally, I use uniform buffers containing the modelview and the projection matrix, as well as the MVP matrix in order to avoid unnecessary matrix multiplication on a per-vertex basis.

Hey! Thanks for sharing your experiences! :slight_smile: