PDA

C17_H19_NO3_H2O
03-21-2002, 04:05 AM
Guyz I've a Quadric Object (Sphere) and I wanna set it's color 2 Yellow , or whatever , How Can I Set It's Color is there's any other way Insted of using Light or Texture?

T2k
03-21-2002, 04:20 AM
do you tried to call glColor before drawing the object ???

C17_H19_NO3_H2O
03-21-2002, 04:30 AM
Yea I did , but all I get is z a White Sphere ..

T2k
03-21-2002, 05:03 AM
thats not normal, even if you have texturing enabled (and no texture bound) you should get the color defined in glColor ... maybe you call it the wrong way ???
glColor<3/4><f/d> accepts values from -1.0 to 1.0
and
glColor<3/4><u><i/s/b> accept values from 0 to 255

so you have too choose the correct function calling glColor3f(10,5,255) will produce white color, because the call is clamped to glColor3f(1.0f, 1.0f, 1.0f); !!! and in this case glColor3<i/s/b> would be correct ...

Bob
03-21-2002, 05:33 AM
glColor<3/4><u><i/s/b> accept values from 0 to 255

Almost correct. The integer types maps the value 0 to the floatingpoint value 0.0. The largest possible value that can be represented by the integer type is mapped to the floatingpoint value 1.0.

That means, for an unsigned byte (glColor3ub), the range [0.0 1.0] is mapped to [0 255], since 255 is the largest value an unsigned byte can represent.

For signed byte (glColor3b), the range [0.0 1.0] is mapped to [0, 127], since 127 is the largest value a signed byte can represent.

For unsigned integers (glColor3ui), the range is [0, 4294967295], since that is the largest value a signed integer (32-bit) can represent (2^32 - 1).

An example. These six calls all have the same parameters, but they are all mapped to different floatingpoint values in the range [0.0 1.0], because their [0 MAX_VALUE] is different.

glColor3b (127, 0, 0); // r = 1.0
glColor3ub(127, 0, 0); // r = 0.5
glColor3s (127, 0, 0); // r = 0.004
glColor3us(127, 0, 0); // r = 0.002
glColor3i (127, 0, 0); // r = 0.00000006
glColor3ui(127, 0, 0); // r = 0.00000003

r is the floatingpoint value the red component is mapped to, rounded to one significant digit.

Of course, due to finite precision, the last four calls will probably end up in zero once in the frame buffer.

bChambers
03-21-2002, 09:27 AM
Originally posted by C17_H19_NO3_H2O:
Guyz I've a Quadric Object (Sphere) and I wanna set it's color 2 Yellow , or whatever , How Can I Set It's Color is there's any other way Insted of using Light or Texture?

If you have texturing enabled, you might want to try

glEnable(GL_COLOR_MATERIAL);

...Chambers

C17_H19_NO3_H2O
03-21-2002, 12:56 PM
I tried z GlEnable(GL_COLOR_MATRIAL) n' It worked , Thnx alot Guyz , U were a great Help ... http://www.opengl.org/discussion_boards/ubb/smile.gif

C17_H19_NO3_H2O
03-21-2002, 01:06 PM
I tried z GlEnable(GL_COLOR_MATRIAL) n' It worked , Thnx alot Guyz , U were a great Help ... http://www.opengl.org/discussion_boards/ubb/smile.gif

Korval
03-21-2002, 03:03 PM
To clear something up, glEnable(GL_COLOR_MATERIAL) works because lighting was on. It has nothing to do with textures.