-
Junior Member
Regular Contributor
glRasterPos/matrices?
I have a chunk of code for displaying bimapped text that is supposed to set up the window by loading the identity matrices and then using glOrtho(0,1,0,1,0,1), immediately followed by a glRasterPos2f(x,y). It works correctly the first time through, but after I pop the matrices back, do some other stuff, then come back, push the matrices, load the identities, etc., the first image I drew disappears and the new one appears. All subsequent calls to the function continue to display everything but the first one. I tried printing out the matrices and got this:
First time through...
Projection: 2 0 0 0 0 2 0 0 0 0 -2 0 -1 -1 -1 1
Modelview: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
All other times...
Projection: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Modelview: 2.6885e-10 0 0 0 0 2.6885e-10 0 0 0 0 -2.6885e-10 0 0 0 0 1
It seems to me that the first one is correct, and all the others are wrong, no? How can this be if I am loading the identity (in BOTH stacks), then only issuing a glOrtho(0,1,0,1,0,1) and a glRasterPos2f(x,y) before I print out the matrices?
Any suggestions would be greatly appreciated.
chennes
-
Junior Member
Regular Contributor
Re: glRasterPos/matrices?
Could you show us the code ?
-
Junior Member
Regular Contributor
Re: glRasterPos/matrices?
Sure... here it is. DrawingArea is just
a wrapper class for gtkGLArea... the only
additional thing that I do there is make
sure that the right drawing area is current.
DrawingArea.DeleteList (displayList);
DrawingArea.NewList (displayList);
DrawingArea.PushGL ();
int lWidth = DrawingArea.width();
int lHeight = DrawingArea.height();
float percentWidth = (float)insertionPoint[0] / (float)lWidth;
float percentHeight = 1 - (float)insertionPoint[1] / (float)lHeight;
DrawingArea.InitializeFont(font);
glColor3d(color[0], color[1], color[2]);
DrawingArea.make_current();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,1,0,1,0,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRasterPos3f(percentWidth,percentHeight,0);
float pMatrix[16];
glGetFloatv(GL_PROJECTION_MATRIX, pMatrix);
cout << "Projection: ";
for (int i = 0; i < 16; i++)
{
cout <<pMatrix[i] << " ";
}
cout << endl;
float mvMatrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mvMatrix);
cout << "Modelview: ";
for (int i = 0; i < 16; i++)
{
cout << mvMatrix[i] << " ";
}
cout << endl;
DrawingArea.PrintGL(name); //prints out the text to the area at the specified raster position.
DrawingArea.PopGL ();
glEndList();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules