GL settings effecting multiple objects
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
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
}
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
}
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 ]
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
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
Thanks
-Daerom
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 ]
- 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 ]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement