Skip to main content
gamedev.net
🔒 Locked

Setting color

Started by danrip Apr 11, 2002 at 5:34 AM 6 replies 200+ views
Original Post
danrip
danrip
I''ve loaded a Q2 model that renders very nicely. But when I try to draw a simple grid in the same scene, colors get mixed up. The model turns green (my color for the grid) and the grid color is black? Here''s the (pseudo)code =) public void RenderScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBegin(GL_LINES); loop through 3dmodel object and draw all its vertexes glEnd(); glBegin(GL_LINES); glColor3ub() draw some vertexes glEnd(); } What I really would like to know is : a) shouldn''t the glClear "reset" the color? b) if not, how do I avoid turning my model green? /daniel
/daniel
Yann L
Yann L
a) no.
b) Put another glColor3ub(whatever) before your 3d model drawing loop. OpenGL is a state machine, don''t forget that. Once you set a colour, it will be valid for all times, until you set a different one.
danrip
danrip
tried that, the model gets rendered ok, but with the color that I set.
/daniel
Yann L
Yann L
Of course it does, that''s what glColor* is meant to do

What exactly do you want to achieve ? Perhaps post the relevant parts of your model render code (the gl* calls).

/ Yann
eldee
eldee
quote:
Original post by danrip
tried that, the model gets rendered ok, but with the color that I set.


right before you make the call to render your model,
set the color to a shade of white.

ie)
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
DrawGrid();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
DrawModel();


-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

danrip
danrip
Ok, messed around a bit (tips given didn''t seem to help) and found that if I glEnable texturemaps it doesn''t matter what color I give the grid it comes out black.

Does this mean that I can''t mix a textured model with non-textured glVertexes?

/d

/daniel
rgirard413
rgirard413
if you are drawing untextured objects, you need to glDisable(2d_texture whatever it is) before you draw the objects and then glEnable(2d_texture whatever) after
http://www.thedizzle.com
danrip
danrip
Thanks, that was it!


/daniel
/daniel

Topic Locked

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

Sign in to reply to this topic.