HELP WITH SHADOWS

Please help me with this,
I am trying to create shadow

of a simple chair, not the legs - only the seat and the back, but it doesn’t work, I don’t see any shadow and the compiler doesn’t complain the code is as follows:

Note that I have 2 light sources & below i use the one at 3,3,3.

float xl =3.0;
float yl =3.0;
float zl =3.0;
GLfloat m[16];
for(int i=0; i<15; i++) m[i] =0.0;
m[0]=m[5]=m[10]=1.0;
m[7] =-1.0/yl; //light //position: {3, 3, 3, 1.0};

//float polygoncolor[]={0.6,0.6,0.6};
//glColor3fv(polygoncolor);
glMaterialfv (GL_FRONT, GL_AMBIENT, ambient2); //somecolor
glMaterialfv (GL_FRONT, GL_DIFFUSE, diffuse2);
glMaterialfv (GL_FRONT, GL_SPECULAR, specular2);
glMaterialfv (GL_FRONT, GL_SHININESS, &shine2);

//THE SEAT ITSELF

glBegin(GL_POLYGON);
glVertex3f( -0.53,-0.5,0.0); // FRONT LEFT RELATIVE TO THIS
glVertex3f( -10.33,-0.5,0.0); // FRONT RIGHT, change x
glVertex3f( -0.33,-0.5,-0.23); // BACK RIGHT, change x & z
glVertex3f( -0.53,-0.5,-0.23); // BACK LEFT, change z only
glEnd();

//THE BACK OF THE SEAT
glBegin(GL_POLYGON);
glVertex3f( -0.33,-0.5,0.0); // FRONT BOTTOM, & RELATIVE TO THIS
glVertex3f( -10.33,-0.2,0.0); // FRONT TOP, change the y(+)
glVertex3f( -0.33,-0.2,-0.23); // BACK TOP, change y & z
glVertex3f( -0.33,-0.5,-0.23); // BACK BOTTOM, change z only
glEnd();

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(xl,yl,zl);
glMultMatrixf(m);
glTranslatef(-xl,-yl,-zl);

glMaterialfv (GL_FRONT, GL_AMBIENT, ambient3); // white colors
glMaterialfv (GL_FRONT, GL_DIFFUSE, diffuse3);
glMaterialfv (GL_FRONT, GL_SPECULAR, specular3);
glMaterialfv (GL_FRONT, GL_SHININESS, &shine3);

//THE SEAT ITSELF 2
glBegin(GL_POLYGON);
glVertex3f( -0.53,-0.5,0.0); // FRONT LEFT RELATIVE TO THIS
glVertex3f( -10.33,-0.5,0.0); // FRONT RIGHT, change x
glVertex3f( -0.33,-0.5,-0.23); // BACK RIGHT, change x & z
glVertex3f( -0.53,-0.5,-0.23); // BACK LEFT, change z only
glEnd();

//THE BACK OF THE SEAT 2
glBegin(GL_POLYGON);
glVertex3f( -0.33,-0.5,0.0); // FRONT BOTTOM, & RELATIVE TO THIS
glVertex3f( -10.33,-0.2,0.0); // FRONT TOP, change the y(+)
glVertex3f( -0.33,-0.2,-0.23); // BACK TOP, change y & z
glVertex3f( -0.33,-0.5,-0.23); // BACK BOTTOM, change z only
glEnd();

glPopMatrix();

At a quick glance it looks to me like you are simply setting up lighting and expecting shadows to appear (as I don’t see anything that actually looks like the necessary code for - unless the use of m[] is intended for projection of the geometry onto a plane?).

Go to the nVidia developer site and look into shadow buffers and stencil volume shadows. (Or use google)

Another thing you need to look up is the glNormal() function. Without normals your lighting will not calculate correctly.

Shadows don’t come automatically for free, you have to compute them yourself using one of the many algorithms for shadows. The two rgpc mentioned are the ones I’d look into if I were you.

Also, just because your syntax is correct (resulting in the compiler not throwing errors) doesn’t mean your program is correct.

-SirKnight

yep !
Shadows are not handled by the lighting setting of Opengl.
There’s a lot of brain coding to manbage to get shadows.
Go to nvidia developper website.
You will find what you want !!