Jump to content
  • Advertisement
Sign in to follow this  
JY

Mixing textures and flat shading

This topic is 4734 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 guys, sorry for the dumb question - i must be missing something simple but I just don't know what. I've managed to get a texture mapped quad on the screen. However, if I then try to draw another shape without a texture nothing gets displayed. If I take the texture out everything is fine. I'm working in orthogonal mode as it's a 2D project i'm gearing up for. My init code contains:
	glEnable(GL_TEXTURE_2D);						glShadeModel(GL_SMOOTH);						glClearColor(0.0f, 0.0f, 0.0f, 0.0f);					glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			glEnable(GL_BLEND);
	glDisable(GL_DEPTH_TEST);						glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

and my drawing code contains:
	glBindTexture(GL_TEXTURE_2D, textures[0]);
	glLoadIdentity();
	glTranslatef(320.0f, 240.0f, 0.0f);
	glRotatef(rtri,0.0f,0.0f,1.0f);
	glColor4f(1, 1, 1, 1);
	glBegin(GL_QUADS);
		glTexCoord2f(1, 1);
		glVertex2f( 100, 100);
		glTexCoord2f(1, 0);
		glVertex2f(100, 0.0f);
		glTexCoord2f(0, 0);
		glVertex2f(0.0f,0.0f);
		glTexCoord2f(0, 1);
		glVertex2f( 0.0f, 100);
	glEnd();

	glBindTexture(GL_TEXTURE_2D, 0);
	glLoadIdentity();
	glTranslatef(320.0f, 240.0f, 0.0f);
	glBegin(GL_TRIANGLES);
		glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
		glVertex3f(0.0f, 100.0f, 0.0f);
		glColor4f(0.0f, 1.0f, 0.0f, 0.5f);
		glVertex3f(-100.0f,-100.0f, 0.0f);
		glColor4f(0.0f, 0.0f, 1.0f, 0.0f);
		glVertex3f( 100.0f,-100.0f, 0.0f);
	glEnd();

Could anyone give me some pointers as to where i'm going wrong please? TIA [Edited by - phantom on November 4, 2005 8:15:25 AM]

Share this post


Link to post
Share on other sites
Advertisement
I don't see anything wrong with it. Instead of binding a NULL texture have you tried to disable 2d texturing and drawing and the enabling the 2d texture after drawing the quad with no texture ?

Does that work for you ?

Share this post


Link to post
Share on other sites
Yes! That fixed it, thank you. I didn't realise that I had to disable texturing in order to draw a solid shape - especially if i've selected no texture and specified the colours of the vertices.

Thanks CRACK.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!