I am trying to display some text on a loaded bitmap. I tried all possible things I can think of but nothing helped me. Herebelow I show you briefly how I am trying to do it:
// Loaded the image…
load_image("***.bmp");
// Build Font
HFONT font;
HFONT oldfont;
base = glGenLists(96);
font = CreateFont(-24, 0, 0, 0, FW_BOLD, FALSE,
FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE|DEFAULT_PITCH, “Courier New”);
oldfont = (HFONT)SelectObject(hDC, font);
wglUseFontBitmaps(hDC, 32, 96, base);
SelectObject(hDC, oldfont);
DeleteObject(font);
glListBase(base - 32);
while(1){
DrawGLScene();
}
…
…
…
DrawGLScene(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.05f,-7.5f);
glBindTexture(GL_TEXTURE_2D, texture[0]);
//////// Part A ///////////
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-4.0f, -4.55f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f( 4.0f, -4.55f, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f( 4.0f, 3.05f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-4.0f, 3.05F, 0.0f);
glEnd();
///////////////////////////
/////// PART B ////////////
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, 8.0, 6.0, 0.0);
glPushAttrib(GL_LIST_BIT | GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
glListBase(base);
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(1, 1);
glCallLists(6, GL_UNSIGNED_BYTE, “a”);
glPopAttrib();
glPopMatrix();
glPopMatrix();
SwapBuffers(hDC);
/////////////////////////////
Now I noticed one weired thing happening in my code. When I have both ‘PART A’ and ‘PART B’ in my code, the output is a black screen with a letter ‘Q’ displayed at the raster position rather then ‘a’…
The same thing happens when I comment ‘PART A’ and just have ‘PART B’ in my code.
When I have ‘PART A’ in the code and comment out ‘PART B’, the output just showes me the bitmap loaded and does not have the letter displayed.
Can anyone help me with this. Any kind of help with be highly appreciated.
Thanks.
Sappy