• ### Announcements

#### Archived

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

# such thing as glPushColor() ?

## Recommended Posts

I think there was a function that pushed the color but i cant recall the name and i couldnt find it on google. It basically was a useful tool for temporarily storing the color. For example
glColor3f(1.0, 1.0, 1.0);    // color is nice and white

// draw a buncha white stuff

glPushColor();     // save the current color (white)

glColor3f(1.0, 0.0, 0.0); // change color to red

// draw a buncha red stuff

glPopColor();      // restore the previous color

// draw more stuff in white


The thing i liked about this function was that if you have a big long display function, and you suddenly have to draw something green right in the middle of it, you can save the current color, draw your green thing, and then restore teh current color without even having to know what the current color was. Does this function exist? what is it called? Thanks!

##### Share on other sites
JONSKI    122
Does this function exist? what is it called?

http://www.opengl.org/developers/documentation/man_pages/hardcopy/GL/html/gl/

I don''t think the function you are talking about exists.

##### Share on other sites
Rickwi22    212
I didnt check, but I can guess that might be useful, say you wanted to make everything in the entire scene a little redder, then you could do

glColor3f(0.1,0.0f,0.0f);
glPushColor();
//draw everything in the scene as normal, and whatever colors they want, but a little redder
glColor3f(1.0f,1.0f,1.0f); // actually shows up on screen as 1.1f, 1.0f, 1.0f
glPopColor();
glColor3f(1.0f, 1.0f, 1.0f); // actually shows up as 1.0f, 1.0f, 1.0f

at least thats my idea of how it may be useful to have those commands.

EDIT, at least to my understanding, your example of the Push and Pop commadns is not right, in your example the "red" stuff would actually be 2.0, 1.0, 1.0 (I think)

[edited by - rickwi22 on August 7, 2003 11:50:51 PM]

##### Share on other sites
4GR3V_-_NoD    122
quote:
Original post by AndreTheGiant
I think there was a function that pushed the color but i cant recall the name and i couldnt find it on google. It basically was a useful tool for temporarily storing the color. For example

there is no glPushColor, at least that i know, but for what u are trying to do, use attributes:

glPushAttrib(GL_CURRENT_BIT);
glColor3fv(color);
draw_object();
glPopAttrib();

in this way, the color set between push/pop attrib doesnt affect any other object in ur scene

##### Share on other sites
4GR3V_-_NoD    122
quote:
Original post by AndreTheGiant
I think there was a function that pushed the color but i cant recall the name and i couldnt find it on google. It basically was a useful tool for temporarily storing the color. For example

in ur code, u cant save the white color because the push is after u specify it, u have to do it, before set the color.

there is no glPushColor, at least that i know, but for what u are trying to do, use attributes:

glColor3fv(white); //set color to white
glPushAttrib(GL_CURRENT_BIT);
glColor3fv(blue);
draw_object(); //in blue

glPushAttrib(GL_CURRENT_BIT);
glColor3fv(red);
draw_object(); //in red
glPopAttrib(); pop the red color

draw_object(); //in blue

glPopAttrib(); //pop the blue color, then the color is white

draw_object(); //in white

in this way, the color set between push/pop attrib doesnt affect any other object in ur scene,