Textures and colors and spinning a cube

Started by
1 comment, last by Marco H 19 years, 3 months ago
Is it possible to glcolor and texture in same program? I tried to do a program with a cube with some faces having color and some having textures, but when i run the progam the texture faces becomes colors how can I have texture and colors? Another note, I tried to program to have a cube rotate directly on one of its corners, like how a top spins on one point except much slower. So how much rotation on which axis should I assign to get the result i desire.
Advertisement
To have a cube with textures and colors, just clear the color before the textureing. That way the textured quad will retain the color of the texture and then change the color for the quad without the texture.

If you want the cube to rotate on a corner, use a static rotate(glRotatef(90, 0.0f, 1.0f, 0.0f)) to position the cube, then call a dynamic rotate (glRotatef(angle, 0.0f, 1.0f, 0.0f)) to rotate around the y-axis.

dimebag
To use textures just call

glEnable(GL_TEXTURE_2D);

If you want to use colored faces after that, just disable the textures and go with your colors:

glDisable(GL_TEXTURE_2D);

Hope it helps :-)

This topic is closed to new replies.

Advertisement