Getting Colors and Textures together...

Started by
3 comments, last by djdynamic 23 years, 5 months ago
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.
Advertisement
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 =)
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
THANK YOU!!!!!!!!!!!!!!!!! IT''S WORKING !!!! HOORAY! THANKS A LOT!
)) I also just saw your nick.... Maximus...... My friendz at school call me Pontifex Daneius Maximus... hehe
hey, would we refer to ourselves as ''Maximi''?
~Gumpus P. Maximus~

This topic is closed to new replies.

Advertisement