Home » Community » Forums » NeHe Productions » Wierd font thing
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Wierd font thing
Post New Topic  Post Reply 
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)


 User Rating: 1012   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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.."

 User Rating: 1097   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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



 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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)



 User Rating: 1012   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: