Original Post
Ok my main problem is with text and color. I can't get text to work period, no matter what I do! I have used the tutorials here, even downloaded the source, compiled, and ran. With no more affect then my own apps have. Here is included the BuildFont, KillFont and glPrint functions from the tuturials, with a small modification being MainApp.m_hDC. This is not a global variable in my app.
Secondly, in my DrawScene function, I do everything first, translate, rotate, bind texture, draw a cube, or what have you. THen after all that is done, I translate to top left, reverse the rotation so (supposedly the text will stay put - no proof since it doesn't show) it doesn't move then set the color, and print. Example:
glTranslate(-3.0f, -2.0f. 0.0f);
glRotate(xrot, 1.0f, 0.0f, 0.0f);
glRotate(yrot, 0.0f, 1.0f, 0.0f);
glColor3f(1.0f,1.0f 0.0f);
glPrint("Hello World");
This results in.... Well nothing... as far as the text goes. Most unfortunatly it colors the textures and objects in my display, which I would like to know how to solve that problem, as I want the call to only effect the text(when I get text).
Can anyone, please help?
Below is code for my build and kill font functions, as well as Print.
-----------------------------
What doesn't kill me today,
will be there tomorrow..
Edited by - OpenGLNewbie on 10/20/00 7:17:03 PM
GLvoid BuildFont(GLvoid) // Build Our Bitmap Font
{
HFONT font; // Windows Font ID
base = glGenLists(96); // Storage For 96 Characters ( NEW )
font = CreateFont( -24, // Height Of Font ( NEW )
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FW_BOLD, // 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
"Courier New"); // Font Name
if(font)
{
SelectObject(MainApp.m_hDC, font); // Selects The Font We Created ( NEW )
wglUseFontBitmaps(MainApp.m_hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32 ( NEW )
return;
}
// If were to this point, something failed. Lets display a message.
MessageBox(NULL, "Errer in BuildFont();", "Error", MB_OK);
}
GLvoid KillFont(GLvoid) // Delete The Font
{
glDeleteLists(base, 96); // Delete All 96 Characters ( NEW )
}
GLvoid glPrint(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(base - 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 )
}
|