Skip to main content
gamedev.net
🔒 Locked

GL settings effecting multiple objects

Started by daerom Oct 2, 2002 at 11:02 AM 5 replies 600+ views
Original Post
daerom
daerom
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
-Daerom
Shadow1234567890
Shadow1234567890
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
}
What do you mean ''Someday become a programmer?'' I'm a programmer right now!
daerom
daerom
Thanks

-Daerom
-Daerom
Fruny
Fruny
Have a look at glPushAttrib and glPopAttrib too.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
daerom
daerom
I looked at that glPushAttrib and PopAttrib, but I am a little confused as to what mask to use... could you help me out a little

Thanks

-Daerom
-Daerom
Fruny
Fruny
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 ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
daerom
daerom
Thanks a bunch...


-Daerom
-Daerom

Topic Locked

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

Sign in to reply to this topic.