Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Bitmap Font Problem when using glut?

This topic is 5132 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

Hi I want to show some bitmapfont text in my opengl program, so i had a look at the NeHe Lesson 13. The downloadable code compiled and worked fine. I copy and pasted the relevant methods to my sourcecode, in which i am creating my window with glut. But there is no text shown at all. As far as i can see ist the only difference between my programm and the NeHe Code the way of creating the window. Just for testing purposes i wrote a simple new program with a glut window an the font methods, which doesn''t work, too. You can take a lot at the code here: http://www.uni-koblenz.de/~ansgar/OpenGL/main.cpp Any suggestions? If this doesn''t work out soon, i''ll try texture font instead.

Share this post

Link to post
Share on other sites
Hi. I see a few things that you need to change:

--In a reshape function, you need to do the following:
a. Setup your viewport (you've done this)
b. Set the matrix mode to GL_PROJECTION to mess with the projection matrix stack and then clear it via glLoadIdentity() (). (you've done this)
c. Setup your projection (which you've done; ortho mode).
d. Set the matrix mode to GL_MODELVIEW so you can do your drawing.
e. Call glLoadIdentity() again to reset the MODELVIEW matrix.

You've done a-c, but not d-e. (Very important)

--Since your scene "has depth" [not just (x, y) or 2D, but 3D or (x, y, z)], you're going to want to add GL_DEPTH_BUFFER_BIT to the glClear call at the beginning of your display function:

--You need to call glLoadIdentity() at the beginning in your display function so that your MODELVIEW matrix gets reset (loaded with the identity matrix) every time you draw a frame. (Very important)


[edited by - urayami on May 27, 2004 3:10:27 PM]

Share this post

Link to post
Share on other sites
Hi urayami
You are right with what you wrote. But i still don''t get, why i can''t see any text displayed. The reshape function has no effect on what''s shown after executing the program. Correcting the other two mistakes i made, also didn''t bring the font to screen.
Do you have any other suggestons?
Of course everybody is welcome to try modifying my small testcode to get it work. :-)

Share this post

Link to post
Share on other sites
I think I know what went wrong with my program: The following functions need to get the device context (hDC) to work.

wglUseFontBitmaps(hDC, 32, 96, base);
SelectObject(hDC, oldfont);

The problem is, that I don''t know how to get the device context of the glut windows i create. Any suggestions?

Share this post

Link to post
Share on other sites
If you look at the NeHe Lesson 13 page and go to the bottom, there are a couple of conversions for this lesson to GLUT. However, I don''t think you will be able to do it directly, ie. you will have to come up with a workaround to get the font in there. It is because function with a wgl*** in front of it is a Windows specific extension to OpenGL. Since GLUT is cross platform, it would not have the facilities to interact with wgl*** code.

First make it work, then make it fast. --Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!