Matrix stacks still relevant?

Started by
4 comments, last by RobTheBloke 13 years, 5 months ago
I am currently trying to delve deeper into the OGL API and I have just read a text that says the OpenGL matrix stack is deprecated now. I was really happy when I read this, because I always hated this matrix stack thing in OpenGL.
Anyway, my question is: Do todays OpenGL engines still use matrix stacks? For me matrix stacks are closely related to the fixed function pipeline and since the FFP is pretty much dead (for new cutting edge projects) I wonder if matrix stacks are still used nowadays? Or should I completely forget about them?
Advertisement
Quote:Original post by schupf
Anyway, my question is: Do todays OpenGL engines still use matrix stacks? For me matrix stacks are closely related to the fixed function pipeline and since the FFP is pretty much dead (for new cutting edge projects) I wonder if matrix stacks are still used nowadays? Or should I completely forget about them?
The matrix stack was never related to the FFP (yes, I've read that "for me" at the beginning of the sentence). So it's pretty easy to let one of them die without any impact on the other one.

However, IMHO the matrix stack was ever an utility for small scale projects. In the early days, in any project I've done the matrix stack was sooner or later not sufficient. Since then I'm using an own representation of inter-connected spaces, which internally deal with matrices where needed. So each space has its own full-blown global matrix representation which is simply loaded into OpenGL as is.

Look at the threads here in GDnet. Many of them deal with the inconvenience when using the matrix stack and need to do global-to-local conversions, for example. I, personally, as well as others, have often argued that using an own implementation of matrix math as well as space parenting is senseful.
Matrix stacks still might get used in some form or another, but OpenGL's version of them is pretty irrelevant.

e.g. in a scene, one object might describe it's position relative to another, in which case you'd have a 'stack' of matrices that need to be multiplied together to get the absolute world matrix for that object... but this is fairly different to OpenGL's idea of a matrix stack.
@schupf where is the text that says the stack is deprecated? I'm interested to take a read. thanks.

@Hodgman just curious, why is the opengl version irrelevant? I have been using it like what you have described. in fact that's the only time i use them. without this, how would you implement it? Create your own stack? Or compute absolute matrix per frame?
==============================================Rage - Really Amateurish Graphics EngineCollada Parser / Serializer
Quote:Original post by jakesee
without this, how would you implement it? Create your own stack? Or compute absolute matrix per frame?
Either/or. There's no magic to the built-in OpenGL matrix stack, so it's fairly straightforward to achieve the same thing in your own code.
Quote:Original post by jakesee
@schupf where is the text that says the stack is deprecated? I'm interested to take a read. thanks.


gl_ModelViewMatrix is deprecated in the core profile, which means that all transformation functions in openGL are also deprecated (glTranslate, glPushMatrix, glMultMatrix etc).

Quote:Original post by jakesee
@Hodgman just curious, why is the opengl version irrelevant? I have been using it like what you have described. in fact that's the only time i use them. without this, how would you implement it? Create your own stack? Or compute absolute matrix per frame?


Create your own stack (and pass the resulting concatenation in as a matrix param to your vertex shader), or just set the world matrix directly as a uniform to your vertex shader.

Worth pointing to D3D which only has a matrix stack in the D3DX utils, but it's not a part of the core API.

This topic is closed to new replies.

Advertisement