referencing opengl state

Looking at the 3rd edition of the orange book and the GLSL language specification, it would appear that variables such as gl_ModelViewMatrix have been depreciated in favor of uniform variables. For example, in the orange book, I see the modelview matrix represented as follows

uniform mat4 MVMatrix;

in the shader source code listing (p 189), but there is no call to glUniform in the application code (p 247) that indicates what maps this variable name to the corresponding OpenGL state. If this isn’t a typo in the book, I assume that “MVMatrix” is a reserved name, but I can’t find any documentation indicating what all these variables are.

These “gl_” variables seemed like a really convenient way to reference the underlying OpenGL state. Does anyone know why this change was made? Can anyone point me to any documentation indicating what the preferred way to do this is?

MVMatrix is a custom name. And the application code has to contain GL.Uniform instruction to load the actual modelview matrix in it.

These “gl_” variables are deprecated in order to let you choose your own path. I, for example, don’t use any matrices doing spatial transformations by quaternions.

BTW, Noone is forcing you to use forward-compatible GL-3 context. If you like built-in uniforms, you’d better stick with traditional GL-2 context.

Thanks. Since my understanding is that uniform values are stored w/ the program, does this mean that I need to pass common values like the modelview matrix using glUniform for each shader? Or is there some way that this value can be specified once per frame and automatically picked up by each shader?

Btw, is there a place where I can go to view the complete list of custom names? I don’t find this in the docs.

I’m fine using the new way, I just want to make sure I understand all the caveats.

Custom names are just that, custom names. They can be anything you want, almost, so there is not a list. I don’t know what the restrictions on custom names are for GL-3, but in GL-2 they can’t start with “gl_”

Adding to what ‘todayman’ said:

Your engine must support some kind of auto-parameters feature. It works in the following way:
-you have custom parameters somewhere
-each shader contains a list of required parameters, they are loaded (calling glUniform) each time shader is activated
-some logic updates actual parameters values (e.g. View can update camera matrix per frame, model can update modelview matrix per call, etc).

Consider looking at my implementation (in Boo language):

Sorry I think my second post confused the issue. Hopefully the following will clarify:

If the “MVMatrix” variable used in the orange book is just a normal user defined uniform variable, then I understand that there would be no list. However, that still leaves the question of why the book doesn’t update them? Is this just a typo? If I need to specify this value using glUniform myself, can I just update the value once per frame as opposed to once for each program (as my understanding is that each program maintains it’s own state of uniform values)? If not, this seems really inefficient.

If “MVMatrix” is some sort of reserved uniform variable that automatically gets updated by OpenGL, then I would like to see a list of all reserved variable names.

Again, MVMatrix is just a user-specified uniform variable name. I can’t tell you why there is no update of this var in the book. Either an author forgot to call glUniform or the value is not supposed to change per frame (in case of static object).

Your understanding is correct: each program maintains it’s own state of values. So if you are going GL-3 way, you need to implement mechanics for updating each shader’s uniform values.

Thanks for the clarification.