GUI Rendering Overview Question in 1.8
by William Lee Sims · in Torque Game Engine Advanced · 01/05/2009 (11:49 pm) · 6 replies
In my recent port from TGE, I'm trying to move a custom HUD GUI class.
The GUI made up of several parts. I get the GUI's position and extents in ::onResize() and then I find a scale and position so that the GUI is centered and scaled (making it work on wide- or tall-screens.)
In TGE, I call glScalef() so that all future OpenGL calls are automatically scaled. I would also call glTranslatef() so that all future OpenGL calls are translated.
In TGEA, I did the following inside of my ::onRender() call
It didn't work.
I can't seem to see how the GUI is rendered (probably because it's too late), and therefore, I can't see how to properly translate my code.
I could just keep a Matrix around, but I would have to implement a pop/push system as I do several other "glTransatef()" calls to move graphics that are attached to other moving graphics.
The GUI made up of several parts. I get the GUI's position and extents in ::onResize() and then I find a scale and position so that the GUI is centered and scaled (making it work on wide- or tall-screens.)
In TGE, I call glScalef() so that all future OpenGL calls are automatically scaled. I would also call glTranslatef() so that all future OpenGL calls are translated.
In TGEA, I did the following inside of my ::onRender() call
GFX->pushWorldMatrix(); MatrixF tr(true); tr.scale( Point3F( mScale, mScale, 1 ) ); tr.setPosition( Point3F( mTranslate.x, mTranslate.y, 0 ) ); GFX->multWorld( tr ); ... RENDER USING VARIUOS GFX->getDrawUtil() CALLS ... GFX->popWorldMatrix();
It didn't work.
I can't seem to see how the GUI is rendered (probably because it's too late), and therefore, I can't see how to properly translate my code.
I could just keep a Matrix around, but I would have to implement a pop/push system as I do several other "glTransatef()" calls to move graphics that are attached to other moving graphics.
#2
01/06/2009 (6:40 am)
Ah nvm, you wanted to move them around.
#3
Mostly during animations, I used the OpenGL transform functions so that each individual part could render relative to itself. Since the transforms stack, it makes chained animations work "automatically".
01/06/2009 (9:44 am)
@Jaimi - I am just drawing flat bitmaps. All are scaled, most are (obviously) translated within the entire GUI area, and a few are rotated.Mostly during animations, I used the OpenGL transform functions so that each individual part could render relative to itself. Since the transforms stack, it makes chained animations work "automatically".
#4
Is there a matrix stack for GUI rendering?
In the meantime, I've developed a Matrix Stack and am putting all calls to the various drawBitmap calls through it. It's a little bit of a chore, but it might be my only option.
01/06/2009 (12:38 pm)
A simpler question might be: Is there a matrix stack for GUI rendering?
In the meantime, I've developed a Matrix Stack and am putting all calls to the various drawBitmap calls through it. It's a little bit of a chore, but it might be my only option.
#5
I believe it is like you suspect, you will need to manually transform all of your 2D coordinates.
Jaimi
01/07/2009 (8:38 am)
Hi William - I believe it is like you suspect, you will need to manually transform all of your 2D coordinates.
Jaimi
#6
01/12/2009 (11:59 am)
I did end up making a MatrixStack class and then I make calls to the GFX->getDrawUtil() through that class. It feels a little hack-ish. I guess I'm probably one of the few people who like to make complex GUI classes that do a lot in one class. It makes me miss the OpenGL rendering pipeline, though!
Associate Jaimi McEntire
King of Flapjacks