PDA

View Full Version : wglUseFontBitmaps Text blending problem.....



zadeh79
12-28-2009, 10:41 PM
I am using wglUseFontBitmaps to render my Text, and the text color which I set (via glColor3f), appears to be blending with my TGA texture. The original TGA is Red, but it is rendered as blue. (I have tried to change the original TGA to various colors, but it always gets rendered as a different color) I have played a little bit with the blending and alpha settings, and glcolor, but I have had no luck. Right now, I am only left with suspicion of my TGA loader (Tgaload) parameters. I would appreciate some help through this. :confused: CODE:







void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


// - Note color is set before the raster position
glColor3f(1.0f, 1.0f, 1.0f);
glRasterPos3f(30.0, 40.0, 0.0);
glListBase(nFontList);
glCallLists (14, GL_UNSIGNED_BYTE, "Martin Solheim");


glColor3f(0.0f, .70f, 1.0f);
glRasterPos3f(30.0, 50.0, 0.0);
glListBase(nFontList2);
glCallLists (19, GL_UNSIGNED_BYTE, "Michael Thomas Gaul");




image_t the_image0;

// Call the loading routine with the parameters we want
tgaLoad("test.tga", &the_image0, TGA_FREE | TGA_NO_MIPMAPS);

// Bind this loaded texture to GLuints
glBindTexture(GL_TEXTURE_2D, texture0);


// Quickly set the environment variables for this texture
tgaSetTexParams(GL_NEAREST, GL_NEAREST, GL_MODULATE );



glPushMatrix();


glScalef(25.8f, 25.8f, 0.0f);
glTranslatef(-5.0f, -5.0f, 0.0f);


glBegin(GL_QUAD_STRIP);

glTexCoord2f(12.0, 10.0);
glVertex3f(12.0, 10.0f, 0.00f);

glTexCoord2f(12.0 , 11.0);
glVertex3f(12.0 , 11.0f, 0.00f);

glTexCoord2f(11.0 , 10.0);
glVertex3f(11.0f, 10.0f, 0.00f);

glTexCoord2f(11.0, 11.0);
glVertex3f(11.0f, 11.0f, 0.00f);

glEnd();

glPopMatrix();



}







///////////////////////////////////////////////////
// Setup. Use a Windows font to create the bitmaps
void SetupRC(HDC hDC)
{

// Setup the FONTS

HFONT hFont;
HFONT hFont2;



hFont = CreateFont(20.0,0,0,0,FW_BLACK,FALSE,FALSE,FALSE,D EFAULT_CHARSET,OUT_TT_ONLY_PRECIS,
CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Arial"));

SelectObject (hDC, hFont);

//Create display lists for glyphs 0 through 128
nFontList = glGenLists(128);
wglUseFontBitmaps(hDC, 0, 128, nFontList);

DeleteObject(hFont); // Don't need original font anymore



hFont2 = CreateFont(18.0,0,0,0,FW_BLACK,FALSE,FALSE,FALSE,D EFAULT_CHARSET,OUT_TT_ONLY_PRECIS,
CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Arial"));

SelectObject (hDC, hFont2);


//Create display lists for glyphs 0 through 128
nFontList2 = glGenLists(128);
wglUseFontBitmaps(hDC, 0, 128, nFontList2);


DeleteObject(hFont2);




// Black Background
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
//glEnable(GL_DEPTH_TEST);
//glAlphaFunc(GL_GREATER, .01);
//glDisable(GL_ALPHA_TEST);
//glEnable(GL_POLYGON_SMOOTH);
//glDisable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_REPLACE);



glEnable(GL_TEXTURE_2D);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);




}