Skip to main content
gamedev.net
🔒 Locked

Text wandering offscreen

Started by Shinesparked Jan 29, 2006 at 8:52 PM 1 replies 750+ views
Original Post
Shinesparked
Shinesparked
First, a big thanks to Jeff for Lesson 13 on bitmap fonts. I incorporated them into my OpenGL app easily. I only have one tiny problem: If I pass in slightly negative values into glRasterPos2f, the following call to glCallLists doesn't draw anything, even though the text should be visible. The reason that I'd want to do something silly like this is because I'm building a simple GUI and want to allow users to drag text anywhere they want. Currently, the text blinks off suddenly when dragged to the left or bottom edge of the app window. (Interestingly, the text has no problem if it goes too far positive, only if it starts negative.) Any advice? Alternatively, if there's no way to make glCallLists behave from a negative position, are there any methods for dynamically generating full-fledged textures (rather than simple bitmaps) from fonts? I'm trying to find a solution that uses fonts on the user's machine rather than requiring me to include fonts. Thanks in advance for any help.
lack the hack
lack the hack
hmm, so your saying if it goes towards the edge of the screen it disappears? or if it is any negative value in glRasterPos2f()? please show some code....

also, to have your scene a little more visible, put in this
gluLookAt(0,0,40,0,0,0,0,1,0);

that will place the camera at (0,0,40), so you can see more stuff in your scene.

also, with fonts there is something like an invisible box around them, if any part of that box goes off the screen, even just a little bit of it, then the whole entire text disappears with it..so that might be your problem

hope that helps,

--nathan
Shinesparked
Shinesparked
I figured out what's happening. After setting the raster position, I added the following test:

glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &bBool);

I discovered that bBool becomes false when the raster position leaves the viewport. If the raster position is invalid, calls to glBitmap won't work, which I assume is what wglUseFontBitmaps calls.

Can anyone think of a work-around? Is there any way to make raster positions outside of the window valid? I could probably get by even if I only expanded the valid region by the width of a single character (since I can always clip the original string if I need to).

Topic Locked

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

Sign in to reply to this topic.