Matrix Stack

Michael

Moderator
Contributor
Architecture
I noticed that the engine at the moment uses the glpush and glpop for matricies. I think it would be better to implement and maintain a matrix stack with a collection. Opengl's stack system is pretty inflexible and I think this would be a nice addition.
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Until you get some feedback from people who understand what you are talking about (pinging @manu3d ;)) I'll throw in my 2 cents... (bare with me when the questions don't make sense, it's just that this one-line-post looks like it could use some more detail)

Can you elaborate more
- where this stack would be used
- how it would be implemented (interace, ...)
- is this a major change or a small improvement?
 

manu3d

Active Member
Contributor
Architecture
I just had a look at the usages I could find of gl[Pop¦Push]Matrix. We don't seem to use those functions in a particularly complex way. So, I'd like to understand better what would the benefit be switching to our own matrix stack.

But in principle I don't mind. My main concerns are 1) code readability 2) performance. Just keep those issue in mind when you submit a PR and then we'll discuss the details.
 

Michael

Moderator
Contributor
Architecture
OpenGL Matrix stack has depreciated since OpenGL 3 and most 3d engine will tend to distance themselves from the fixed function pipeline. Most projects that i'm aware of roll out their own math library rather then use Opengl's Matrix stack. Some matrix operations are made quite a bit more complicated due to the way you have to work with OpenGL's matricies and getfloat. Operations such as calculating intersections against the view frustum or reordering operations can become significantly easier. It can't be too bad to implement. I've written a similar stack here:

https://github.com/Smoke-Tree-Studios/SmokeEngine/blob/master/SmokeEngine/Source/MatrixStack.cpp
 

manu3d

Active Member
Contributor
Architecture
FYI, the current engine is written against OpenGL 2.1 plus a few required extensions. See LwjglGraphics.checkOpenGL() for the actual capability checks.

Also, I'm not particularly moved by the argument that other projects do it differently. Matrix operations made more complicated? Where, in our project? If something can be made simpler it would certainly be a benefit. Intersection against the view frustrum? Is there something in our project on this regard that can be made better?

I understand that you understand the theory, but I'd like to understand how in practice this would be specifically beneficial for our project. Just go ahead and submit a PR so that we can discuss on the details.
 

Michael

Moderator
Contributor
Architecture
I noticed there has been some interest in using libgdx for cross platforms. So the opengl es platform does not take advantage of the fixed function pipeline. That means that the glpush and glpop will not be available unless libgdx does some kind of wrapper. From my understanding, I don't believe those functions are wrapped by the library. Porting also entails dropping anything related to the fixed function pipeline. This includes all of these:

glTranslatef, glColorPointer, glEdgeFlagPointer, glFogCoordPointer, glIndexPointer, glNormalPointer, glSecondaryColorPointer, glTexCoordPointer, glVertexPointer, glEnableClientState, glDisableClientState, and glInterleavedArrays, glClientActiveTexture, glFrustum, glLoadIdentity, glLoadMatrix, glLoadTransposeMatrix, glMatrixMode, glMultMatrix, glMultTransposeMatrix, glOrtho*, glPopMatrix, glPushMatrix, glRotate*, glScale*, and glTranslate*, glMaterial*, glLight*, glLightModel*, and glColorMaterial, glShadeModel, and glClipPlane*.
 

manu3d

Active Member
Contributor
Architecture
Michael, thank you for letting us know. Indeed there have been discussions about LibGDX and I've noticed you posted a similar comment in issue #2099. I'll post a reply there to keep the discussion in one place.
 
Top