View Full Version : 'unsetting' the color
I have a program that currently just displays a textured cube. To get an idea of what various translations did in 3d space, I started drawing a grid behind this cube, using a couple of nested loops and drawing using GL_LINES. Before the grid is drawn, I also called glColor3f(0.0f, 1.0f, 0.0f); to make the grid appear green.
Trouble is, everything after this also comes out green (including the cube, which previously was just the color of the texture). I can't work out how to 'unset' the color so that things drawn after the grid aren't affected. Any help much appreciated.
07-10-2004, 10:33 PM
You can't "unset" any color, what you can do is to set it to black glColor3f( 0.0f, 0.0f, 0.0f); for example when you are done with the green stuff.
Right, that's what occured to me first as well, but doing that makes everything after it come out black (eg: the textured cube was now just plain black - no sign of the texture anymore). Tried the same with white and got the same results.
07-11-2004, 12:17 AM
Are you using lighting or not when you render the cube ? ( glEnable( GL_LIGHTING); glEnable( GL_LIGHT0); ).
07-11-2004, 11:05 AM
Try to put the color to full white instead.
glColor3f(0.0f, 1.0f, 0.0f);
DrawMyFancyCube();If that still dosent work check out the documentation about glPushAttrib()/glPopAttrib() to see what states you can also save/restore.
Thanks for all the suggestions.
Are you using lighting or not when you render the cube ? ( glEnable( GL_LIGHTING); glEnable( GL_LIGHT0); ).I wasn't at first. I've just tried it with both those things enabled, and now the cube looks textured again, which is great. The grid lines appear black though, and not green (I don't know if this is because they're strictly 2-dimensional, and hence the light doesn't show up on them or something?)
Is it possible to do a combination of textured objects and coloured lines/other shapes without lighting enabled?
07-14-2004, 01:20 PM
disable the lighting with glDisable(GL_LIGHTING)before you draw the lines
Before you draw the textured object:
glBindTexture ($$GL_TEXTURE_2D, yourTexture)
After you draw the textured object:
also, after you draw the primitive reset the color to bright white:
The colors of one is affecting the other and vica versa.
I think there is a GL Material call or something similar to tint the textured objects with whatever color you wish also, but, i can´t remember exactly.
Also, take out those double $$ dollar signs. They´re not for C++.
Ahhh, thanks Wisdrum. It hadn't occured to me to do glDisable(GLTEXTURE2D) at any point. It still seems slightly odd that setting the color back to full white is neccessary, as if it was some kind of 'magic' value.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.