First Question: Unless I'm mistaken, when diffuse lighting hits a vertex, it's scattered evenly in all directions. This would seem to ignore normal vectors. When I use diffuse light though, a surface that is parallel to the viewing vector does not reflect at all. Here's the lighting display list I'm currently working with:
..and the surface that's parallel to the viewing vector:
Question 2: Can someone post up some working mipmapping code? I can't get mipmapping to work, either with explicitly define the mip layers with glTexImage2D() or glBuild2DMipmaps().
Thanks for any help in advance.
Code:
GLuint lighter(void)
{
GLuint list = 2;
const GLfloat diffu[] = {1,1,1,1};
const GLfloat lpos[] = {0,10,40,1};
const GLfloat attenu[] = {0.1};
const GLfloat gamb[] = {0,0,0,0};
glEnable(GL_LIGHT0);
glNewList(list,GL_COMPILE);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,gamb);
glPushAttrib(GL_LIGHTING_BIT);
glLightfv(GL_LIGHT0,GL_POSITION,lpos);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffu);
glLightfv(GL_LIGHT0,GL_CONSTANT_ATTENUATION,attenu);
glPopAttrib();
glEndList();
return list;
}
..and the surface that's parallel to the viewing vector:
Code:
GLuint ground(void)
{
GLuint list = 1;
const GLfloat ambdiffu[] = {0.5,0.5,0.5,1.0};
glNewList(list,GL_COMPILE);
glPushAttrib(GL_LIGHTING_BIT);
glVertexPointer(3,GL_INT,0,fl0verts);
glColorPointer(4,GL_FLOAT,0,fl0colors);
glNormalPointer(GL_FLOAT,0,fl0normals);
glTexCoordPointer(2,GL_INT,0,fl0tcoords);
glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,ambdiffu);
glDrawArrays(GL_POLYGON,0,4);
glPopAttrib();
glEndList();
return list;
}
Question 2: Can someone post up some working mipmapping code? I can't get mipmapping to work, either with explicitly define the mip layers with glTexImage2D() or glBuild2DMipmaps().
Thanks for any help in advance.