Rotating text


I’m using functions from a NeHe tutorial (shown below) to draw text in openGL. I’m using this code to draw values and labels onto a graph’s axes, so I need to be able to draw text on it’s side for the vertical axis. To do this I’m using glRotate to rotate the text 90 degrees, but I’m finding that although the method I’m using seems to have no problem rotating shapes, the text always comes out upright. I admit that I don’t actually understand the code below, and I was wondering if there’s something about it which means it isn’t subject to rotations. Any help would be appreciated.



GLvoid EnableFont(const char* FontName, GLuint* FontBase, HDC DeviceContext, const int FontSize)
HFONT font; // Windows Font ID
HFONT oldfont; // Used For Good House Keeping

*FontBase = glGenLists(96);		        // Storage For 96 Characters ( NEW )
font = CreateFont(-FontSize,				           // Height Of Font ( NEW )
                  0,				           // Width Of Font
                  0,				           // Angle Of Escapement
			      0,				           // Orientation Angle
                  100,			           // Font Weight
                  FALSE,				       // Italic
			      FALSE,				       // Underline
			      FALSE,				       // Strikeout
                  ANSI_CHARSET,			       // Character Set Identifier
                  OUT_TT_PRECIS,			   // Output Precision
			      CLIP_DEFAULT_PRECIS,		   // Clipping Precision
                  ANTIALIASED_QUALITY,		   // Output Quality
                  FF_DONTCARE|DEFAULT_PITCH,   // Family And Pitch
                  FontName);			       // Font Name
oldfont = (HFONT)SelectObject(DeviceContext, font);		// Selects The Font We Want
wglUseFontBitmaps(DeviceContext, 32, 96, *FontBase);			// Builds 96 Characters Starting At Character 32
SelectObject(DeviceContext, oldfont);				    // Selects The Font We Want
DeleteObject(font);					                    // Delete The Font


GLvoid KillFont(GLuint FontBase) {
glDeleteLists(FontBase, 96);

GLvoid PrintText(const GLuint FontBase, const char *fmt, …) // Custom GL “Print” Routine
char text[256]; // Holds Our String
va_list ap; // Pointer To List Of Arguments
if (fmt == NULL) // If There’s No Text
return; // Do Nothing

va_start(ap, fmt); // Parses The String For Variables
vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers
va_end(ap); // Results Are Stored In Text
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits ( NEW )
glListBase(FontBase - 32); // Sets The Base Character to 32 ( NEW )
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text ( NEW )
glPopAttrib(); // Pops The Display List Bits ( NEW )

Look at the spec on wglUseFontBitmaps and glBitmap. All you can do is change the raster position.

You could render the font/string into a texture and manipulate that on the texture matrix stack or rotate some quads.