Skip to main content
GameDev.net gamedev.net
🔒 Locked

Gui?

Started by Cibressus Apr 30, 2004 at 10:08 PM 4 replies 500+ views
Original Post
Cibressus
Cibressus
Hey, i''m trying to render text in the projection matrix so it''s always infront of the camera. can someone please take a look at this or show some code were you''ve done this? glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective (45.0f, (GLfloat)(640)/(GLfloat)(480), // Calculate The Aspect Ratio Of The Window 1.0f, 100.0f); glColor3f(1,0,0); glRasterPos3f(0,0,-1.1); glPrint("test"); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); gluLookAt(cam.Pos.x,cam.Pos.y,cam.Pos.z, cam.View.x,cam.View.y,cam.View.z, cam.Up.x,cam.Up.y,cam.Up.z); //draw my objects
Venerable Vampire
Venerable Vampire
Instead of trying to draw text with a perpective projection matrix, try swapping to an ortho matrix, drawing the text, then swapping back. Assuming the function glPrint is doing the correct thing, try something like this:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,640.0/480.0,1.0,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
---draw 3d code here---
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,640,0,480,-1,1);
glMatrixMode(GL_MODELVIEW);
glRasterPos2f(0,5);
glPrint("test");
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Cibressus
Cibressus
lol, thank you so much. when i first write it out, i did''nt notice it at first (i should have payed more atention to the raser pos). i sighed and looked down and low and behold their it was. it scared me actuly.
Cibressus
Cibressus
just one more question, if i were to go into the texture matrix mode and render shapes and stuff would those actuly show up on the texture?
Cibressus
Cibressus
aslo, i can''t draw primitives, i''ve tried both vertex 3f and vertex 2f am is thier a particualar reason i can''t do this? or am i jsut doing it wrong.
Cibressus
Cibressus
ahah! i figured it out, it draws in pixels, not gl units. so when i went glVertex2f(0,1,0) it was only drawing it 1 pixel not 1 unit above my previous thing.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.