PDA

View Full Version : GL light or Color problem..



05-22-2006, 10:32 AM
I have one problem.

Opengl Light or Color Doesnt work.

fx 5200 run normal:

http://mosengine.inativa.com/tempx/normal.jpg

But fx 5500 doesnt work:

http://mosengine.inativa.com/tempx/normal.jpg

what is the problem.

edit:
Project: http://mosengine.inativa.com/dosya/honeybee.zip

code


//light

float d1light[]={ 0.7f, 0.7f, 0.7f, 1.0f };
float a1light[]= { 0.2f, 0.2f, 0.2f, 1.0f };
float s1light[] = {0.5f, 0.5f, 0.5f, 1.0f};
float p1light[] = { 100.0f, 100.0f, 100.0f,0.0 };
float dir1light[]= { 0.0f, -1.0f,0.0f, 1.0f };


float d2light[]={ 0.5f, 0.0f, 0.0f, 1.0f };
float p2light[] = { 0.0f, 15.0f, 15.0f, 0.0 };


float d3light[]={ 0.5f, 0.5f, 0.0f, 1.0f };
float p3light[] = { 15.0f, 15.0f, 0.0f, 0.0 };

void XXX:setLight()
{
glLightfv(GL_LIGHT0, GL_AMBIENT, a1light);
glLightfv(GL_LIGHT0, GL_DIFFUSE, d1light);
glLightfv(GL_LIGHT0, GL_POSITION,p1light);
glLightfv(GL_LIGHT0, GL_SPECULAR,s1light);
glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,dir1light);
glLightf(GL_LIGHT0,GL_SPOT_EXPONENT,70.0);
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,180.0);
glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION,1.0);
glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0);
glEnable(GL_LIGHT0);


glLightfv(GL_LIGHT1, GL_DIFFUSE, d2light);
glLightfv(GL_LIGHT1, GL_POSITION,p2light);
glEnable(GL_LIGHT1);

glLightfv(GL_LIGHT2, GL_DIFFUSE, d3light);
glLightfv(GL_LIGHT2 ,GL_POSITION,p3light);
glEnable(GL_LIGHT2);


glEnable(GL_LIGHTING);

}

//material
float d1mat[]={ 1.0f, 1.0f, 1.0f, 1.0f };
float a1mat[]={ 0.9f, 0.9f, 0.9f, 1.0f };
float s1mat[]={ 0.0f, 0.0f, 0.0f, 1.0f };
float e1mat[]={ 0.0f, 0.0f, 0.0f, 1.0f };
float shi1[] = { 0 };

void XXX:setHaritaMaterial()
{
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_D IFFUSE );
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, a1mat);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, d1mat);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, s1mat);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shi1);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, e1mat);
glEnable(GL_COLOR_MATERIAL);
}

05-22-2006, 10:34 AM
upss..
image:

normal: http://mosengine.inativa.com/tempx/normal.jpg

not normal:
http://mosengine.inativa.com/tempx/anormal.jpg

RigidBody
05-22-2006, 11:59 AM
if you use glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_D IFFUSE ), the ambient and diffuse material components are taken from glColor, not from glMaterial.

since you use glColorMaterial, but do not seem to specify a glColor, a driver default is used, i guess, which is probably different for both cards.

05-22-2006, 12:51 PM
ok.Thx.