🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Font Questions

Started by
4 comments, last by Blizz 24 years ago
I am trying to combine fonts and the 3d world from tutorial 10 and I have a few questions: The questions are about this part of the code ( DRAW-part)-> int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT / GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View glTranslatef(0.0f,0.0f,-1.0f); // verplaats Z(-1) om text te zien // Position The Text On The Screen glRasterPos2f(-0.05f, 0.32f); glPrint("SOME TEXT"); // Print GL Text To The Screen glRasterPos2f(-0.13f, 0.22f); glPrint("SOME MORE TEXT"); // Print GL Text To The Screen cnt1+=0.051f; // Increase The First Counter cnt2+=0.005f; // Increase The First Counter glTranslatef(0.0f,0.0f,1.0f); // *verplaats Z(+1) om terug te gaan naar de oude positie GLfloat x_m, y_m, z_m, u_m, v_m; GLfloat xtrans = -xpos; GLfloat ztrans = -zpos; GLfloat ytrans = -walkbias-0.25f; GLfloat sceneroty = 360.0f - yrot; int numtriangles; glRotatef(lookupdown,1.0f,0,0); glRotatef(sceneroty,0,1.0f,0); glTranslatef(xtrans, ytrans, ztrans); glBindTexture(GL_TEXTURE_2D, texture[filter]); numtriangles = sector1.numtriangles; // Process Each Triangle for (int loop_m = 0; loop_m < numtriangles; loop_m++) { glBegin(GL_TRIANGLES); // DRAW THE VERTICES glEnd(); } return TRUE; // Everything Went OK } 1: I want to display the framerate, but i move the current position 1 unit into space using glTranslatef(0.0f,0.0f,-1.0f);I can''t see the text when I''m too close to the texure.. Ofcourse I understand why that is (it''s behind the texture).. but I don''t know how to solve the problem.. IN SHORT: How to draw always on top? 2: Colors: When I set the color somewhere in my Draw routine it affects everything, but all I want is to change the font color.. How can I do that? That''s all.. Please help me out.. Blizz
Advertisement

1. Draw all of your 3d objects, then draw your 2d objects after it. Also, before drawing your 2d objects, make sure you disable depth test by calling glDisable(GL_DEPTH_TEST). Don''t forget to Enable the depth testing before drawing the 3d objects next cycle of the program.

DrawGLScene ()
{

glEnable(GL_DEPTH_TEST);
// Draw 3d objects

glDisable(GL_DEPTH_TEST);
// Draw text

}

======

2. Just change the color before drawing the object

glColor4ub(255, 0, 0, 255);
// Draw objects here - they will appear red

glColor4ub(255, 255, 255, 255);
// Draw text here - it will appear white

======

Good luck!

ThomW
www.LMNOpc.com
Thanks!

You really helped me out on question 1, but 2 doesn't seem to work right..

After I draw the rectangles I do this :

glLoadIdentity(); // Reset The View
glDisable(GL_DEPTH_TEST);
glColor4ub(0, 255, 0, 255);
glTranslatef(0.0f,0.0f,-1.0f); // verplaats Z(-1) om text te zien
glRasterPos2f(-0.05f, 0.32f); // Position The Text On The Screen
glPrint("PROFILE"); // Print GL Text To The Screen
glRasterPos2f(-0.13f, 0.22f);
glPrint("by Runez Creations"); // Print GL Text To The Screen

cnt1+=0.051f; // Increase The First Counter
cnt2+=0.005f; // Increase The First Counter

glTranslatef(0.0f,0.0f,0.0f); // *verplaats Z(+1) om terug te gaan naar de oude positie
glColor4ub(255, 255, 255, 255);
glEnable(GL_DEPTH_TEST);

- disable/enable depth testing like you said and I change the color and back. But the color still isn't right. When I want it to be red .. it becomes very brownlike red, and when I want green .. very dark green to .. not a bright color like I want it to be ..

Blizz

Edited by - Blizz on June 28, 2000 8:42:07 AM
Anyone?
I dunno, i dont have implent OpenGL in me demo yet.

But, why what you said and the code i see, its seem like, if your text is blended with your backbuffer
...

Just a tought

LowRad
Disable lighting before rendering text, then reenable it after you''re done:

glEnable(GL_LIGHTING);
// Draw 3D objects

glDisable(GL_LIGHTING);
// Draw text

What''s happening is that your text is being affected by the light, which is something you normally don''t want to have happen.

ThomW
www.LMNOpc.com

This topic is closed to new replies.

Advertisement