Jump to content
  • Advertisement

Archived

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

djdynamic

Getting Colors and Textures together...

This topic is 6474 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

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
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 =)

Share this post


Link to post
Share on other sites

  • 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!