Question

Just what it says: I have some code that's drawing GLUT cubes, but they're all grey. How do I make them different colors?

Everything I've tried so far has failed. I think my problem is that I'm trying to use OpenGL functions to change their colors, but GLUT is maintaining it's own internal color or material data and I don't know how to make it change that data.

This is just filler graphics for a test-client for an online game, so they don't have to look good, I just need to be able to tell things apart. I know GLUT isn't considered great, so if anyone wants to post an example of drawing a cube with plain OpenGL instead of glutCube I'm all ears. I don't really care how I get the cubes on the screen, and it's not a part of the code I want to spend a lot of time on. I have a partner who's doing the real graphics; I just need to get something showing so that I can visualize what my code is doing.

The language I'm using OpenGL/GLUT from is called Io, but the API it exposes should be the same as if I were calling it from C.

Was it helpful?

Solution

It turns out that if I just do:

            glEnable(GL_COLOR_MATERIAL)

then it makes the material track whatever color I set with glColor, even when lighting is enabled.

OTHER TIPS

Just set the color beforehand with glColor(). If you're using lighting (i.e. GL_LIGHTING is enabled), though, then you'll instead have to use glMaterial() to set the cube's color.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top