how to make shadowmaps from stencil shadow???

I’ve merged the NEHE tutorials, about stencil shadow in my 3D engine.everything looks very good,but the frame rate drop at around 15 fps(GeForce 2 GTS+320 megs Ram).

I’m wondering if there could be a ways to “save” the shadow in a textures and to use it as a shadow maps(multitexturing)???

If you use textures would the shadows be static and never change. Another idea is to precalculate the shadow volume, This will give the correct result for objects moving in out from the shadows but the light and shadow caster must be static.
Your fps seems to be low, are you sure that you are using a color depth that will give you a hardware stencil buffer?

Im running in 32 bits,“the stencil buffer should be actvated”.This the routine im using for shadow, mainly NEHE tuts midified to work with many object.

this is call each frame:
glDisable(GL_LIGHTING);
glDepthMask(GL_FALSE);
glDepthFunc(GL_LEQUAL);

glEnable(GL_STENCIL_TEST);
glColorMask(0, 0, 0, 0);
glStencilFunc(GL_ALWAYS, 1, 0xffffffff);

// first pass, stencil operation decreases stencil value
glFrontFace(GL_CCW);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
for(i=0;i<nbObject;i++)
	glCallList(2000+i);


// second pass, stencil operation increases stencil value
glFrontFace(GL_CW);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);

for(i=0;i<nbObject;i++)
	glCallList(2000+i);

glFrontFace(GL_CCW);
glColorMask(1, 1, 1, 1);

//draw a shadowing rectangle covering the entire screen
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glStencilFunc(GL_NOTEQUAL, 0, 0xffffffff);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glPushMatrix();
glLoadIdentity();
glBegin(GL_TRIANGLE_STRIP);
	glVertex3f(-0.1f, 0.1f,-0.10f);
	glVertex3f(-0.1f,-0.1f,-0.10f);
	glVertex3f( 0.1f, 0.1f,-0.10f);
	glVertex3f( 0.1f,-0.1f,-0.10f);
glEnd();
glPopMatrix();
glDisable(GL_BLEND);

glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
glEnable(GL_LIGHTING);
glDisable(GL_STENCIL_TEST);
glShadeModel(GL_SMOOTH);

the for loop just do all the shadow volume(they are compiled once at loading this ways)
void DrawShadow(t3DObject pObject,float lp)
{
unsigned int i, j/
,k
/;
unsigned int p2;
sPoint v1, v2;

for (i=0; i<pObject->numOfFaces;i++)
{
	if (object[i].visible)
	
		for (j=0;j<3;j++)
		{
			//k = object[i].neigh[j];
			//if ((!k) | | (!object[i].visible))
			//{
				// here we have an edge, we must draw a polygon
			
				p2 =(j+1)%3;

				//fprintf(fp,"%d

",(j+1)%3);

				//calculate the length of the vector
				v1.x = (object[i].p[j].x - lp[0])*100;
				v1.y = (object[i].p[j].y - lp[1])*100;
				v1.z = (object[i].p[j].z - lp[2])*100;

				v2.x = (object[i].p[p2].x - lp[0])*100;
				v2.y = (object[i].p[p2].y - lp[1])*100;
				v2.z = (object[i].p[p2].z - lp[2])*100;
				
				//draw the polygon
				glBegin(GL_TRIANGLE_STRIP);
					glVertex3f(object[i].p[j].x,
								object[i].p[j].y,
								object[i].p[j].z);
					glVertex3f(object[i].p[j].x + v1.x,
								object[i].p[j].y + v1.y,
								object[i].p[j].z + v1.z);

					glVertex3f(object[i].p[p2].x,
								object[i].p[p2].y,
								object[i].p[p2].z);
					glVertex3f(object[i].p[p2].x + v2.x,
								object[i].p[p2].y + v2.y,
								object[i].p[p2].z + v2.z);
				glEnd();
			//}
		}
		
}

}

I havent looked closly at your code but if you are using the stuff from NeHe should it be OK. A simple test like making the window smaller will give some hints there the bottleneck is. If the fps almost double with a halfed window is it the fill rate.
My guess is that the generation of the shadow volumes is the explanation.

Got 11 fps @ 12801024,31 fps @ 640480 and 60 fps @ 320*240(yark!!).I have tried just to call all the gl functions without drawing the “shadowed” objets and the frame rate is still the same;must be normal since im using glCallList the do the shadow poly…

(sorry for my bad english ,Im from Quebec and im trying to improve it.

At least at higher resolutions does the speed seems to be limited by the fillrate. Not much can be done about it. Check that you dont clear the screen if you are redrawing it anyway.
I guess that if you want shadows at 1280*1024 do you have to upgrade your hardware or try something different than shadow volumes. Easy choice if you have the money…

English is not my native language but I dont see anything bad about your language.