I just read this:
“OpenGL provided support
for managing coordinate transformations and projections using the standard matrix stacks
(GL_MODELVIEW and GL_PROJECTION). In core OpenGL 4.0, however, all of the functionality
supporting the matrix stacks has been removed. Therefore, it is up to us to provide our own
support for the usual transformation and projection matrices, and then to pass them into our
shaders.”
This is strange, so how do I set the modelview and projection matrices now? I should create
them in the opengl app and then multiply the vertices in the vertex shader with the matrices?
Nope. Fixed function was replaced by programmable pipeline that lets you design your transformations however you want.
If you want to have something that would work just like the old OpenGL pair of matrix stacks, then you’d want to make your vertex shader look, for instance, like:
(You can optimise that a bit, of course)
And the corresponding client-size code (shown as C++ here) would be like:
I’ve assumed here that you have a Matrix4x4 class that supports operations like
.translate(). A library like GLM can provide you with client-side implementations of matrices and vectors that behave like corresponding GLSL types, as well as implementations of functions likegluPerspective.You can also keep using the OpenGL 1 functionality through the OpenGL compatibility profile, but that’s not recommended (you won’t be using OpenGL’s full potential then).
OpenGL 3 (and 4)’s interface is more low level than OpenGL 1; If you consider the above to be too much code, then chances are you’re better off with a rendering engine, like Irrlicht.