Archived

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

daerom

GL settings effecting multiple objects

Recommended Posts

Ok, lets say I do a glColor3f(1, 1, 0); to make some text print out Yellow, but I don''t want it to effect anything else. How would I do that? I tried doing this, but it doesn''t even work on the text in the first place, it actually works on the next thing I render, which happends to be my skybox, wich is now tinted yellow. -Daerom

Share this post


Link to post
Share on other sites
You have to set the color to what you want before you draw every object

i.e

void DrawObject1() {
glColor3f(0.0f, 1.0f, 0.0f);//sets color to green
//drawing code here
}

void DrawObject2() {
glColor3f(1.0f, 0.0f, 0.0f);//sets color to red
//drawing code here
}

Share this post


Link to post
Share on other sites
You probably need GL_CURRENT_BIT, which will save/restore (Blue Book p415)

- current RGBA color
- current color index
- current normal vector
- current texture coordinates
- current raster position
- GL_CURRENT_RASTER_POSITION_VALID flag
- RGBA color associated with current raster position
- color index associated with current raster position
- texture coordinates associated with current raster position
- GL_EDGE_FLAG flag

The attribute stack is guaranteed at least 16 levels.
Of course the save/restore operation MAY be expensive if a pipeline flush is needed. Think whether you really need it or if a call to glColor() is enough

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites