alpha testing & lighting don't go together

In my scene I do alpha testing on objects with glAlphaFunc(GL_GREATER, 0). The scene is rendered as I wanted.(a house with see thru windows. Alpha testing is to make the windows see thru). Then I enabled the lighting and ‘*’ , the whole house dissapears!. light setting is as follows

float amb[] = {0.5, 0.5, 0.5};
float dif[] = {1, 1, 1};

glLightfv(GL_LIGHT0, GL_AMBIENT, amb);
glLightfv(GL_LIGHT0, GL_DIFFUSE, dif);

I don’t see any problem in my code. Probably I miss to do some setting but I do not know what. Anyone please guide me…

glLightfv takes 4 floats for inputs. so thats your first problem :slight_smile:

and the diffuse alpha value is used for alpha if you dont have a texture overriding that.


I did the correction for the light setting. But still the house doesn’t get drawn. And I just notice that objects behind the house are visible. they shouldn’t be because I enabled depth testing. That means that color buffer and depth buffer are not updated when the house is drawn with lighting & alpha testing enabled. The house model is store in display list and when I set the house to be drawn the frame rate will drop and that make me believe that the model is actually processed by the display card. I use rgba texture for the house.

I just read the red book and it says that depth buffer isn’t affected if alpha testing failed. that explained why the objects behind the house are visible but the main problem here still unsolved.

what value do you put in material and light diffuse alpha?