Jump to content
  • Advertisement
Sign in to follow this  
GogetaX

Print Text on screen?

This topic is 3534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Well, the simplest way to draw text on the screen would be to open a web browser and search Google, or search these very forums, for "OpenGL text rendering." Do this and you will certainly come up with many, many relevant results.

Also, try NeHe:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17

Share this post


Link to post
Share on other sites
leason 17.. didnt got that far yet XD
and i was asking for a simple 2D text on the screen without any bitmap or anything else..

any ideas any1?

Share this post


Link to post
Share on other sites
NeHe lesson 13 is the easiest way to print text on windows + ogl.
Also, bitmap fonts doesn't have to mean "using an external font texture", in the case of lesson 13, the bitmap is generating using the windows function CreateFont, which is the easiest way to do this without using glut or other external libraries.

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13

Share this post


Link to post
Share on other sites
thanks. but its kind of 3d-text. objects could be over it. is it possible to make a text over everything or maybe using another methods like Labels or whatever.. idk.

Share this post


Link to post
Share on other sites
If you switch to orthographic projection before drawing the text, it will always render on top of 3d-objects.

For more information about what orthographic projection is, check this out: http://en.wikipedia.org/wiki/Orthographic_projection

Switching to ortho mode is very easy in opengl:


glDepthMask(GL_FALSE);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, Width, Height, 0, 0, 1); //Width/Height - the surface size in pixels
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();





Switching back again is just a matter of restoring the previous projection state:

glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!