Replace openGL API to DX( TGE Resource to TGEA )
by Wang Guojing · in General Discussion · 10/30/2007 (1:47 am) · 3 replies
I found a FlashGUI Resource in TGE,and I want to use it in TGEA. I was trying to integrate it but it uses the dgl.h, which doesn't exist on TGEA.
The problem is that i have little DX knowledge, and no openGL knowledge.I don't understand these code:
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1, 0, 1, -1, 1, 1); //(replace to GFX->setOrtho(...);)
glMatrixMode(GL_MODELVIEW);
...
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
What should I replace these code to GFX function? Thanks!
The problem is that i have little DX knowledge, and no openGL knowledge.I don't understand these code:
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1, 0, 1, -1, 1, 1); //(replace to GFX->setOrtho(...);)
glMatrixMode(GL_MODELVIEW);
...
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
What should I replace these code to GFX function? Thanks!
#2
glPushMatrix(); // This tells OpenGL to save the current matrix to the stack so you don't lose it when you start messing with projection matrices.
glLoadIdentity(); // As it says, it creates a new, identity matrix. Always a good place to start. The identity matrix looks like this:
[ 1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1 ]
glOrtho(-1, 0, 1, -1, 1, 1); //(replace to GFX->setOrtho(...);)
/* Multiplies the identity matrix with an orthographic matrix. The parameters of the orthographic matrix are:
( left, right, bottom, top, nearVal, farVal ) where
left, right are the coordinates for for the left and right clipping planes
bottom, top are the coord's. for the bottom and top horizontal clipping planes.
nearVal, farVal are the distances to the nearer and farther depth (perpendicular to whatever direction you're "looking") clipping planes.
Basically, the projection matrix defines the area that will be shown in your display.
*/
glMatrixMode(GL_MODELVIEW); // Now that your projection matrix is set up, go back to the Model/View matrix. This is where your drawing objects reside.
...
glDisable(GL_TEXTURE_GEN_S); // Don't compute the s or t coordinates when doing texture
glDisable(GL_TEXTURE_GEN_T); // generation computations. This may be because you only have a
// 1D or 2D texture. (I'm not sure why they did this in the middle
// of a GL_PROTECTION gig, but okay.)
glMatrixMode(GL_PROJECTION); // Getting ready to pop the matrix.
glPopMatrix(); // Pulls the previous matrix back off the stack, which I assume was
glMatrixMode(GL_MODELVIEW); // the modelview matrix.
It's hard to tell what's going on with only a segment of code like this, but there you are. Many good reference works are available for OpenGL. The one I use is the Opengl SuperBible, Fourth Edition. You can also find good information at www.opengl.org.
11/07/2007 (10:12 am)
GlMatrixMode(GL_PROJECTION); // This tells OpenGL that you're going to be fiddling with the projection matrix stack. (Think of this as the "camera view" matrix.)glPushMatrix(); // This tells OpenGL to save the current matrix to the stack so you don't lose it when you start messing with projection matrices.
glLoadIdentity(); // As it says, it creates a new, identity matrix. Always a good place to start. The identity matrix looks like this:
[ 1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1 ]
glOrtho(-1, 0, 1, -1, 1, 1); //(replace to GFX->setOrtho(...);)
/* Multiplies the identity matrix with an orthographic matrix. The parameters of the orthographic matrix are:
( left, right, bottom, top, nearVal, farVal ) where
left, right are the coordinates for for the left and right clipping planes
bottom, top are the coord's. for the bottom and top horizontal clipping planes.
nearVal, farVal are the distances to the nearer and farther depth (perpendicular to whatever direction you're "looking") clipping planes.
Basically, the projection matrix defines the area that will be shown in your display.
*/
glMatrixMode(GL_MODELVIEW); // Now that your projection matrix is set up, go back to the Model/View matrix. This is where your drawing objects reside.
...
glDisable(GL_TEXTURE_GEN_S); // Don't compute the s or t coordinates when doing texture
glDisable(GL_TEXTURE_GEN_T); // generation computations. This may be because you only have a
// 1D or 2D texture. (I'm not sure why they did this in the middle
// of a GL_PROTECTION gig, but okay.)
glMatrixMode(GL_PROJECTION); // Getting ready to pop the matrix.
glPopMatrix(); // Pulls the previous matrix back off the stack, which I assume was
glMatrixMode(GL_MODELVIEW); // the modelview matrix.
It's hard to tell what's going on with only a segment of code like this, but there you are. Many good reference works are available for OpenGL. The one I use is the Opengl SuperBible, Fourth Edition. You can also find good information at www.opengl.org.
#3
11/07/2007 (10:17 am)
Nice write-up Ray!
Associate David Montgomery-Blake
David MontgomeryBlake