how to print a text in a specified portion of a screen

Dear All,
i am using wglUseFontBitmaps (…) to print text in a window.
Other than glTranslatef (…) function, is there any method through which I can specify a particular point in the screen.
Thank you for your replies

Why not glTranslatef?

Thanks for the response.
i have an open GL window, in which I have Vertical and Horizontal Scroll bars.
these scroll bars accepts only Integer values, where as my window has graphs with float values. When I zoom the Graph with respect to the mouse movement, I need to adjust scroll,based on the scroll movememnt i need to adjust the Text i have drawn also…
I am not able to make a correct mapping between the Scroll Positions (integr) and the Text coordinates (float values)where I am using gltranslate (…)
Is there any other method like glRasterPos (…) which is there for bitmap font

I am not sure I understand your problem…

Presumably you are viewing a specific portion of a graph within your viewport. As you move the scroll bars, the graph scrolls (to show portions of the graph that are not otherwise shown).

Your scroll bars are integer based and the data in the graph is float based.

Now you have situations where you may have a point at 100.5 - which gets drawn at a point which is interpolated around 100/101 pixel…

Is the problem that when you draw the text, and move the scroll bars, the text (presumably a label for your points) appears to skip and stop (ie. It looks like the position of the text is being “rounded”).

If so are you sure you are calculating the positions correctly? Are you type casting correctly?

I’m also not sure to understand the problem.
I also use vertical scrollbar in my console project, but do not use glTranslate() to display text. I also don’t use wglUseFontBitmaps() for fonts. All is done “manually” using a bitmap as font map. Characters are taken from this bitmap and displays as quads with glVertex2i().
Fore more details, you can get the source at

Thanks for all your response.
Let me explain you my problem.
i dont use bitmap fonts because I can not rotate it , since I want to display some text in vertical.
The text is always drawn in relation to the Graph.On scrolling i need to place the text which I can do with respect to the Scroll Position only. So when I use glTranslate (…) for that replacement, I am not able to find a correct relative mapping between float values of the graph and integer positions of the Scroll bars. So like glRasterPos (…) which is used for bitmap fonts, I would like to know is there any function through which we can specify particular points in the screen and there after drawing the Text should start from that points.

Originally posted by jowins:
I am not able to find a correct relative mapping between float values of the graph and integer positions of the Scroll bars.

I think you’ll have to explain this statement a bit bettter. Perhaps if you provide a code snippet?

As for using a Bitmap as a font, you can rotate it any way you desire because you specify where the Quad that holds the characters is placed. If you want you can draw your text backwards, up side down etc.

I think that have a mapping of 1 pixel in scrollbar movement = 1 pixel in text movement is the way to go.

To do that, you can go into orthographic projection. The call may look something like this

gluOtho2D(0.0, WindowWidth, 0.0, WindowHeight);

Perhaps that will make it easier for you to work with.

Originally posted by rgpc:
I think you’ll have to explain this statement a bit bettter. Perhaps if you provide a code snippet?

the problem with bitmap font is it wont respond to glPushMatrix () and glPopMatrix ()
i have rotation for my Open GL window, but i want to rotate some text alon in the vertical direction, this independant rotation is not supported by bitmap fonts.

Let me explain that once again
I have a 3d graph and say I want to write ?Open GL" along the Y axes, and I have to write vertically along the Y axes.
By using the glTranslate (…) i wrote the text in the centre of the Y axes.
when I do scrolling, this text has to be aligned in the same centre but has to move along the Y axes. How can I do that?
Hope this would be clear
Thanks and regards


I thing there’s a misconception here with the word “bitmap”. Opengl bitmaps, as in glBitmap or wglCreateFontBitmaps, don’t response to matrix operations. But I think these guys are talking about storing the glyphs in a texture, and drawing the characters as textured quads. Then it will work, but that’s not the issue here.

So let’s see, if I got this right now. You want the labels to stay near the axes, but move along the axes so that they remain in screen when the graph is scrolled? So you could determine for example the maximum value on the y-axis that’s visible on the screen, and place the label a little below that.

One way get this value would be to draw the axis in feedback mode to get the screen coords of the endpoints of the visible part of the axis, and then gluUnproject it to get world space coords. But that’s quite a mess, maybe it’s easier to clip the lines by hand. Don’t know really, maybe someone has a simplier solution.