PDA

View Full Version : Writing text vertically



jowins
01-08-2003, 01:19 AM
Hi,
I want to write text vertically on an Open GL window. I tried making fonts with vertical orientation and adding to the DC and selecting it for glCalllists
For Horizontal orienntation its working fine but vertical no text is displayed.
Could you guys helpme out? Is there a simple way we can display text with different fonts (I want vertical display)
Thanks
Jowins

M/\dm/\n
01-08-2003, 01:29 AM
You can render text to texture in pbuffer and then rotate it as you want, but that's quick guess.

jowins
01-08-2003, 01:35 AM
Thanks for the reply,
but its not the only thing, I have 3D axes, showing some graph in that, which we can rotate. In the X and Z axes I write the Axes names horizontaly and in the Y axes i want to write vertically. I can do that in some way.. but is there any simple method thru which we can accompolish this. I have the rotation for the entire window also
Thanks

JustHanging
01-08-2003, 01:44 AM
How about glRotate? It should work at least on outline fonts.

-Ilkka

jowins
01-08-2003, 01:48 AM
Hi,
As I mentioned earlier i have so many objects in the window. I have a rotation functionality for the entire window, So is it possible to rotate a text alone within a window. I am drawing all the objects all together based on some data
Thanks
jowins

JustHanging
01-08-2003, 02:12 AM
Yeah, sure you can. Use push/popMatrix to limit the rotation to the text. Like this:

glPushMatrix
glRotate(90, 0, 0, 1);
draw text
glPopMatrix

-Ilkka

M/\dm/\n
01-08-2003, 02:28 AM
If you will use textures you can take a look at some billboarding tutorials, that shoud solve all your text problems in 3D space.

jowins
01-08-2003, 02:29 AM
I am sorry! its not working. when I use Push matrix nothing happens with respect to rotation. just draws the text horizontally

jowins
01-08-2003, 02:34 AM
Originally posted by M/\dm/\n:
If you will use textures you can take a look at some billboarding tutorials, that shoud solve all your text problems in 3D space.
Can you please tell me where I can find such tutorials

JustHanging
01-08-2003, 02:40 AM
How do you generate the display lists that contain the fonts?

-Ilkka

jowins
01-08-2003, 02:47 AM
Originally posted by JustHanging:
How do you generate the display lists that contain the fonts?

-Ilkka
void COpenGLWnd::MakeFont(BOOL bVert)
{
// create a font
SelectObject (m_pCDC-GetSafeHdc(), m_VertFont);
m_bHorzGotFont=wglUseFontBitmaps (m_pCDC->GetSafeHdc(), 0, 255, fontlist);

}

and for printing i use the function
void PrintString (LPCTSTR str)
{
glPushAttrib(GL_LIST_BIT);
glListBase(fontlist);
glCallLists(strlen(str), GL_UNSIGNED_BYTE, (GLubyte*)str);
glPopAttrib();
}

JustHanging
01-08-2003, 02:56 AM
Ok, well that's the problem. You use bitmap fonts, and bitmaps aren't affected by matrix transformations. Replace wglUseFontBitmaps with wglUseFontOutlines, and something should happen. If your texts are rotated, but not facing the viewer, go for the billboard stuff.

-Ilkka

jowins
01-09-2003, 02:07 AM
Thanks for you reply. It worked but how can I adjust the size of the fonts, say small size and bigger size. IS it possible? Could you please tell me where I can get that Bill board samples

JustHanging
01-09-2003, 07:21 AM
Of course you can adjust the size of the text, just use glScale the way you use glRotate to rotate it.

There's a very good billboarding tutorial at http://www.lighthouse3d.com/opengl/billboarding/ .

-Ilkka

jowins
01-09-2003, 06:58 PM
Thank you very much Mr Justhanging.
Thank you all for your replies. All helped me a lot.
Thanks