Archived

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

djdynamic

Getting Colors and Textures together...

Recommended Posts

djdynamic    122
I''m totally stuck! I''ve been playing around for over a week trying to get the First Texture tutorial work with a colored triangle. I added the code from the color tutorial to the texture tutorial, and the triangle comes up as black (it shouldn''t be black!) and the cube is textured... When i disable texturing, the cube is white, and the triangle becomes colored like i wanted it to be.... So how do i have both texturing and coloring together!? Thankz.

Share this post


Link to post
Share on other sites
Maximus    124
Simple =)

First, disable textures and draw your coloured polygons.
Second, enable textures and draw your textured polygons.

ie:

// Draw coloured triangle
glDisable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
glColor3f(1.0f,0,0); glVertex3f(0,0,0);
glColor3f(0,1.0f,0); glVertex3f(1.0f,0,0);
glColor3f(0,0,1.0f); glVertex3f(1.0f,1.0f,0);
glEnd();

// Draw textured triangle
glEnable(GL_TEXTURE_2D);
glColor3f(1,1,1);
glBindTexture(GL_TEXTURE_2D,1);
glBegin(GL_TRIANGLES);
glTexCoord2f(0,0); glVertex3f(0,0,0);
glTexCoord2f(1,0); glVertex3f(1.0f,0,0);
glTexCoord2f(1,1); glVertex3f(1.0f,1.0f,0);
glEnd();


Hope that helps =)

Share this post


Link to post
Share on other sites