Skip to main content
gamedev.net
🔒 Locked

Problem with colors

Started by raghu_tum 0 replies 450+ views
Original Post
raghu_tum
raghu_tum
I have models of a car,earth,sun and sky.. In Drawsun function,I have wrote red color just before creating the sun.. When I am calling this function before Drawcar or Draw earth or draw sky..I am getting the red color of sun on the car sometimes on earth and and sometimes for all objects in the scene.. Please give me a solution for this problem
celestialVoid
celestialVoid
When you set a color with glColor*(), this color will be the current color until you change it with another call to glColor*() with different parameters.

For example:
glColor3f (1.0f, 0.0f, 0.0f);DrawCar ();DrawSun ();DrawEarth ();

Now, if there is no other call to glColor*() in DrawCar()/DrawSun()/DrawEarth(), all these models will have red color. If you want different color, you must change it BEFORE drawing.
glColor3f (1.0f, 0.0f, 0.0f); // redDrawCar ();glColor3f (1.0f, 1.0f, 1.0f); // whiteDrawSun ();glColor3f (0.0f, 1.0f, 0.0f); // greenDrawEarth ();


This way, you'll get red car, white sun and green earth.
So, the color you get depends on the last glColor*() call.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.