Advertisement

glMaterialiv

Started by December 14, 2000 01:00 PM
7 comments, last by Id 23 years, 11 months ago
int mat[4] = {1,1,1,1}; glMaterialiv(GL_FRONT_AND_BACK,GL_DIFFUSE,mat); gives a grey color... no mater what i change the elements of mat to the result is always a dark grey... this thing is glMaterialfv works fine int mat[4] = {1.0,1.0,1.0,1.0}; glMaterialiv(GL_FRONT_AND_BACK,GL_DIFFUSE,mat); gives me white... any replies would be appreciated
quote: Original post by Id

int mat[4] = {1,1,1,1};
glMaterialiv(GL_FRONT_AND_BACK,GL_DIFFUSE,mat);

gives a grey color...
no mater what i change the elements of mat to
the result is always a dark grey...

this thing is glMaterialfv works fine

int mat[4] = {1.0,1.0,1.0,1.0};
glMaterialiv(GL_FRONT_AND_BACK,GL_DIFFUSE,mat);

gives me white...

any replies would be appreciated



Did you enable the color tracking ?
skyline
Advertisement
int mat[4] = {1.0,1.0,1.0,1.0};
u mean float dont you?
also check what colour your lights are

http://members.xoom.com/myBollux
Oops, yea that should be float
I just copied it real quick

heres the lights...

float LightAmbient[] = { 0.1f, 0.1f, 0.1f, 1.0f };
float LightDiffuse[] = { 0.9f, 0.9f, 0.9f, 1.0f };
float LightSpecular[] = { 0.9f, 0.9f, 0.9f, 1.0f };

glLightfv (GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv (GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv (GL_LIGHT0, GL_SPECULAR, LightSpecular);
glEnable (GL_LIGHT0);
glEnable (GL_LIGHTING);

GL_COLOR_MATERIAL is not enabled...


Shouldn''t that be:

int mat[4] = {255,255,255,255};

I am not shure about glMaterialiv, but that is the way it works for glColoriv.

ANDREW RUSSELL STUDIOS
Web site coming soon...
Yea it could be and I''ve tried that,
just no change at all....

I''ve just converted them all to a float
approximation and used glMaterialfv

which completely sux but it glMaterialfv
works fine...
Advertisement
quote: Original post by Id

Yea it could be and I''ve tried that,
just no change at all....

I''ve just converted them all to a float
approximation and used glMaterialfv

which completely sux but it glMaterialfv
works fine...


If we use the integer , then the indivisual light component will be (0-255) instead of (0.0 - 1.0).

Just a thought.
skyline
quote: Original post by Id

Yea it could be and I''ve tried that,
just no change at all....

I''ve just converted them all to a float
approximation and used glMaterialfv

which completely sux but it glMaterialfv
works fine...


If we use the integer , then the indivisual light component will be (0-255) instead of (0.0 - 1.0).

Just a thought.
skyline
Yes, the approximation is...

1/255 = 0.0039215....
and
128 * 0.0039215 = 0.501952
so...

Material->diffuse[0] = Material->diffuse[0] * 0.0039215;
Material->diffuse[1] = Material->diffuse[1] * 0.0039215;
Material->diffuse[2] = Material->diffuse[2] * 0.0039215;

glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Material->diffuse);

and this works... but theres a function for ints!
anyway I''m completely frusterated with it...

I''ve only tested this on NT and 2000 btw
has anyone successfully used glMaterialiv?

This topic is closed to new replies.

Advertisement