hi,
I am just trying to make some text appear with my opengl stuff in the background. I am in the process of making my opengl vizualization for winamp a bit more exciting by adding some text to show whats playing. I have the text and need to display it. I'm using a camera to rotate around the focused object and also trying to display text on the screen.
When I try to display the text, the text does not show, but everything else does ok? The listBase is valid (1) and the hFont is valid when made in CreateBitmapFont (taking stuff from gamedev's opengl Book)
But when I use PrintString, which does this stuff -->
glPushAttrib(GL_LIST_BIT);
glListBase(base-32);
glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);
glPopAttrib();
the text isnt shown at all.
here is the code I am using:
initGL
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glShadeModel (GL_SMOOTH);
// Enable Smooth Shading
glEnable(GL_DEPTH_TEST); // hidden surface removal
glClearColor (0.0f,0.0f,0.0f,0.0f); // Black Background
glClearDepth (1.0f); // Depth Buffer Setup
//glEnable (GL_LIGHT0); // enable light0
//glEnable (GL_LIGHTING); // enable lighting
//glEnable (GL_COLOR_MATERIAL); // enable color for material
// listBase = CreateOutlineFont("Arial", 10, 0.25f); // load 10pt Arial font
glEnable (GL_BLEND); // Enable Blending
glBlendFunc (GL_SRC_ALPHA,GL_ONE); // Type Of Blending To Perform
glHint (GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); // Really Nice Perspective Calculations
glHint (GL_POINT_SMOOTH_HINT,GL_NICEST); // Really Nice Point Smoothing
glEnable (GL_CULL_FACE); // Enable Face Culling
glEnable (GL_TEXTURE_2D); // Enable Texture Mapping
glBindTexture (GL_TEXTURE_2D,texture[0]); // Select Our Texture
listBase = CreateBitmapFont("Courier New",24);
.
.
.
Render() (szCurrent Track is VALID btw...)
...
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity();
Camera.UpdatePosition();
...
if ( szCurrentTrack && listBase )
{
glColor3f(1.0f,1.0f,1.0f);
glRasterPos2i(10,10);
PrintString(listBase,szCurrentTrack);
}
... other opengl stuff
oh yeah and this is what I do to make the font, listBase = this function.
unsigned int CreateBitmapFont(char * fontName, int fontSize)
{
HFONT hFont; // windows font
unsigned int base;
base = glGenLists(256); // generate string length of 256
hFont = CreateFont( fontSize,
0,
0,
0,
FW_NORMAL,
FALSE,
FALSE,
FALSE,
ANSI_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_DONTCARE | DEFAULT_PITCH,
fontName);
if ( !hFont )
return 0;
SelectObject(hDC,hFont);
wglUseFontBitmaps(hDC,32,256,base);
return base;
}
do you think because I am using a camera that the fonts are getting drawn but are drawn somewhere where I can't see them? How can I draw them where I can see them in that case, or are the font's just not drawing because of something I missed out or an incompatibility somewhere? (as I have noticed that openGL wont draw things sometimes if they are not configured properly..)
Thanks!!!
[edited by - cheeseh on February 11, 2004 5:30:44 PM]