示例#1
0
void Display(){
	// main drawing routine - called every frame
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
	glLoadIdentity();
	// camera at default (zero) position and orientation
	RenderModel();
	PrintStats();
	glLoadIdentity();
	RenderStrings();
    glPopMatrix();
    glFlush();
    SwapBuffers(hDC);			/* nop if singlebuffered */
}
示例#2
0
文件: render.cpp 项目: Thyfate/melax
void RenderStuff()
{
	extern String techniqueoverride;
	culledlightcount=clippedcount=culledmeshcount=0;

    // Clear the backbuffer and the zbuffer
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,
						 D3DCOLOR_COLORVALUE(clearcolor.x,clearcolor.y,clearcolor.z,1.0f), 1.0f, 0L ); // color macro maps floating point channels (0.f to 1.f range) to D3DCOLOR
	int stencildirty=0;

	g_pd3dDevice->BeginScene();// Begin the scene

	techniqueoverride="";

		techniqueoverride= "unlit";

		drawmeshes(regmeshes);

		techniqueoverride="lightpass";
		extern int lightingpasses;
		lightingpasses=1;
		for(int i=0;i<lights.count;i++) // for each light
		{
			if(!lights[i]->enable || lights[i]->radius<=0.0f) continue;
			if(stencildirty) g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,D3DCOLOR_XRGB(0,0,255), 1.0f, 0L );
			stencildirty=0;
			lightposn   = lights[i]->position;
			lightradius = lights[i]->radius;
			lightradiusinv = 1.0f/lightradius;
			lightcolor  = lights[i]->color;
			if(!camera.SphereVisible(lightposn,lightradius)) {culledlightcount++;continue;}

			ScissorsSetUp();
			if(lights[i]->shadowcast)
			{
				drawmeshes_spherecull(shadowmeshes,lightposn,lightradius);// create shadow volumes for this light 
				stencildirty=1;
			}
			ClipPlanesSetUp();
			//g_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS,4) && VERIFY_RESULT;
			//g_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS,4) && VERIFY_RESULT;
			drawmeshes(regmeshes);

			//DWORD junk; g_pd3dDevice->GetRenderState(D3DRS_DEPTHBIAS,&junk);		
			//g_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS,0) && VERIFY_RESULT;
			//g_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS,0);
			if(stencildirty && stencilclearimmediate)
			{
				g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,D3DCOLOR_XRGB(0,0,255), 1.0f, 0L );
                stencildirty=0;
			}
			ClipPlanesRestore();
			ScissorsRestore();

		}
		techniqueoverride="";
		lightingpasses=0;


	extern int hack_usealpha;
	hack_usealpha++;
	drawmeshes(alphameshes);
	hack_usealpha--;

	RenderLines();

	RenderStrings();  // todo: rename to DrawStrings()


    g_pd3dDevice->EndScene(); 	// End the scene

}