Archived

This topic is now archived and is closed to further replies.

Cipher3D

problem with displaying wgl bitmap fonts when rendering textures before it

Recommended Posts

i''m creating a 2d engine using OpenGL, and all is fine: i can load a texture, and render it via a textured quad. next, i have a font system, the same font system as described in NeHe''s bitmap fonts tutorial. When I print something using the font system by itself, it renders correctly - with whatever color I set it to. However, whenever I print some text and draw a textured quad to the screen at the same time, the font doesn''t pick up the color - instead, it just displays as white. my font function...

	glDisable(GL_TEXTURE_2D);
	
	int r = (color & 0xff000000) >> 24;
	int g = (color & 0x00ff0000) >> 16;
	int b = (color & 0x0000ff00) >> 8;

	glLoadIdentity();

	glScalef(size/16.0f,size/16.0f,1);
	glRasterPos2f(x,y+size);

	char buffer[256];
	va_list args;

	va_start(args,text);
	vsprintf(buffer,text,args);
	va_end(args);


	glBlendFunc(GL_SRC_COLOR,GL_ZERO);
	glColor3f(r/255.0f,g/255.0f,b/255.0f);

	glPushAttrib(GL_LIST_BIT);
	glListBase(m_uList-32);

	glCallLists(strlen(buffer),GL_UNSIGNED_BYTE,buffer);

	glPopAttrib();

my sprite rendering function....
void CTexture::Draw()
{
	glEnable(GL_TEXTURE_2D);

	glLoadIdentity();
	//set the color

	int r = (m_dwModulate & 0xff000000) >> 24;
	int g = (m_dwModulate & 0x00ff0000) >> 16;
	int b = (m_dwModulate & 0x0000ff00) >> 8;

	glColor4f(r/255.0f,g/255.0f,b/255.0f,1);

	//set the blending function

	glBlendFunc(GL_SRC_COLOR,GL_ZERO);

	glBindTexture(GL_TEXTURE_2D,m_uTexture[0]);

	//calculate the texture coords

	float u0 = m_rcSrc.left/(float)m_nWidth;
	float v0 = m_rcSrc.top/(float)m_nHeight;
	float u1 = m_rcSrc.right/(float)m_nWidth;
	float v1 = m_rcSrc.bottom/(float)m_nHeight;

	
	glRasterPos2f(m_rcDest.left+m_fCX,m_rcDest.top+m_fCY);
	glRotatef(m_fRot,0,0,-1);
	glRasterPos2f(-m_fCX,-m_fCY);


	glBegin(GL_QUADS);
		glTexCoord2f(u0,v0);
		glVertex2f(m_rcDest.left,m_rcDest.top);

		glTexCoord2f(u1,v0);
		glVertex2f(m_rcDest.right,m_rcDest.top);

		
		glTexCoord2f(u1,v1);
		glVertex2f(m_rcDest.right,m_rcDest.bottom);

		glTexCoord2f(u0,v1);
		glVertex2f(m_rcDest.left,m_rcDest.bottom);


	glEnd();

	glLoadIdentity();
}

here''s what the text looks like all by itself: and here''s what the text looks like with a texture rendered with it: thanks in advance!

Share this post


Link to post
Share on other sites