Archived

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

Weird texture problem

This topic is 5312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, whenever I call this code in my app the entire screen seems to take on a washed out pink colour. When I say everything, I mean everything: the items drawn before this code and the after. So weird, cos there's no glColor__() calls here! Argh!
void DrawTexturedQuad(float x, float y, int TextureId)
{
	glBegin(GL_QUADS);
		
		glTexCoord2f(TextureLeft(TextureId),	TextureTop(TextureId));	glVertex2f((float) x,		(float) (y+1.0f));
		glTexCoord2f(TextureRight(TextureId),	TextureTop(TextureId));	glVertex2f((float) (x+1.0f),(float) (y+1.0f));
		glTexCoord2f(TextureRight(TextureId),	TextureBottom(TextureId)); glVertex2f((float) (x+1.0f),(float) y);
		glTexCoord2f(TextureLeft(TextureId),	TextureBottom(TextureId)); glVertex2f((float) x,		(float) y);

	glEnd();

}
 
[edited by - zdlr on June 2, 2003 3:05:14 PM]

Share this post


Link to post
Share on other sites
Kinda figured most of the problem out: I've wrapped that code in glEnable(GL_TEXTURE_2D) and a corresponding glDisable(). Now only the texture is rendering odd. I think I've either got a glColor4f(...,...,...,<1.0f); stray, so the tile is showing up faint or the TGA loading code I've got is dodgy. Only one way to find out

edit:
And I have, I've now got this code:



void DrawTexturedQuad(float x, float y, int TextureId)
{
glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glBegin(GL_QUADS);

glTexCoord2f(TextureLeft(TextureId), TextureTop(TextureId));
glVertex2f((float) x, (float) (y+1.0f));

glTexCoord2f(TextureRight(TextureId), TextureTop(TextureId));
glVertex2f((float) (x+1.0f),(float) (y+1.0f));

glTexCoord2f(TextureRight(TextureId), TextureBottom(TextureId));
glVertex2f((float) (x+1.0f),(float) y);

glTexCoord2f(TextureLeft(TextureId), TextureBottom(TextureId));
glVertex2f((float) x, (float) y);

glEnd();
glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
}





[edited by - zdlr on June 2, 2003 3:38:43 PM]

Share this post


Link to post
Share on other sites