Advertisement

Wierd font thing

Started by June 28, 2000 04:00 PM
2 comments, last by RWarden 24 years, 4 months ago
I combined the code from the Windows and bitmapped font drawing routines into this:
    
glDisable ( GL_DEPTH_TEST );
glMatrixMode ( GL_PROJECTION );
glPushMatrix ( );
glLoadIdentity ( );
glOrtho ( g_rcScreen.left, g_rcScreen.right, g_rcScreen.bottom, g_rcScreen.top, -100, 100 );
glMatrixMode ( GL_MODELVIEW );
glPushMatrix ( );
glLoadIdentity ( );
glTranslated ( x, y, 0 );
glColor3f ( clr.r, clr.g, clr.b );
glPushAttrib ( GL_LIST_BIT );
glListBase ( g_fBase - 32 );
glCallLists ( strlen ( text ), GL_UNSIGNED_BYTE, text );
glPopAttrib ( );
glMatrixMode ( GL_PROJECTION );
glPopMatrix ( );
glMatrixMode ( GL_MODELVIEW );
glPopMatrix ( );
glEnable ( GL_DEPTH_TEST );
    
The g_rcScreen rect is (0,0)-(800,600). When I call this function and pass 0,0 as X and Y, the first time it draws the text at the -bottom- left corner. The second time, it draws to the bottom, centered (exactly to the right of where it finished drawing the first time). The third time, it draws exactly to the right of that, and by the fourth time the text is no longer visible on the screen. It would seem to be a problem with not calling LoadIdentity, but I am calling it.. and it still doesn''t explain why it''s drawing it on the bottom of the screen when I pass 0 for a y-coord. thanks for any help.. -RWarden (roberte@maui.net)
not sure about the second and third times, but I can explain the first..the Y coord in OpenGL is reversed, so it counts from the bottom up..your starting coords of 0,0 would end up in the lower left..the higher the Y, the higher on the screen..may fix issue with subsequent calls, may not..

"Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."
Advertisement
I think you problem is the push pop thing. You pop your modelview matrix into the projection matrix, and the projection matrix into the modelview matrix =).

it has to be:

push projection
push modelview

pop modelview
pop projection

Ries
Thanks for the help but neither one is the problem...
1. no matter what I pass as the x and y coords, the text is always rendered at the lower-left corner of the screen. so apparently the call to glTranslated isn''t doing anything.
2. the push/pop calls are in the correct order... you always pop in the reverse order from what you push because it''s a FIFO stack. thus, (and I tested this ) if I switch the order in which they are popped all the matrices get screwed up and the rest of the scene doesn''t render.

-RWarden (roberte@maui.net)

This topic is closed to new replies.

Advertisement