Example #1
0
void Draw( void )
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();

	glTranslatef( 0.0, 0.0, -3.0 );
	
	smokeParticles.Draw();
	fireParticles.Draw();

	SDL_GL_SwapBuffers();
}
Example #2
0
void DrawParticles ()
{
	Shaders::SetShader("Particles");
	EnableTexturing();
	EnableBlending();
	Matrices::SetViewMatrix(matrix2x3::Identity());
	Matrices::SetModelMatrix(matrix2x3::Identity());
	for (std::list<ParticleSystem*>::iterator iter = particleSystems.begin();
	                                          iter != particleSystems.end();
	                                          ++iter)
	{
		ParticleSystem* ps = *iter;
		bool isDead = ps->Update();
		if (isDead)
		{
			std::list<ParticleSystem*>::iterator iterCopy = iter;
			++iter;
			particleSystems.erase(iterCopy);
			delete ps;
			if (iter == particleSystems.end())
				break;
		}
		ps->Draw();
	}
}
Example #3
0
/* redisplaying graphics */
void Display(void)
{
    hlBeginFrame();

    hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, 0.1);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, 0.8);

    hlCheckEvents();

	/* clear the display */
	//glClear(GL_COLOR_BUFFER_BIT);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	//materialsTest();

	if (mDrawSurface)
		mSurface.DrawSurface();

    // draw the haptic surface
    hlHintb(HL_SHAPE_DYNAMIC_SURFACE_CHANGE, HL_TRUE);
    hlTouchableFace(HL_BACK);
    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, mSurfaceShapeId);
        mSurface.DrawSurface();
    hlEndShape();
	
	glDisable(GL_LIGHTING);

	if (mDrawSystem)
		mPS.Draw();

	if (mDrawNormals)
		mSurface.DrawSurfaceNormals();

	glEnable(GL_LIGHTING);

    // draw the 3D cursor
    RedrawCursor();

	// show FPS
	if (mDrawInfo != drawInfo_None)
		DisplayInfo();

	// swap the double buffers
	glutSwapBuffers();  

    hlEndFrame();

}
//*************************************************************************************************************
void Render(float alpha, float elapsedtime)
{
	D3DXMATRIX		world, view, proj;
	D3DXMATRIX		skyworld, viewproj;
	D3DXVECTOR3		eye(0, 0, -5);
	D3DXVECTOR3		look(0, 0, 0);
	D3DXVECTOR3		up(0, 1, 0);
	D3DXVECTOR2		orient = cameraangle.smooth(alpha);

	D3DXMatrixRotationYawPitchRoll(&view, orient.x, orient.y, 0);
	D3DXVec3TransformCoord(&eye, &eye, &view);

	D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4, (float)screenwidth / (float)screenheight, 0.1f, 50);
	D3DXMatrixLookAtLH(&view, &eye, &look, &up);
	D3DXMatrixMultiply(&viewproj, &view, &proj);

	device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
	device->SetTransform(D3DTS_VIEW, &view);
	device->SetTransform(D3DTS_PROJECTION, &proj);

	for( int i = 0; i < NUM_DWARFS; ++i )
		dwarfs[i].Update(elapsedtime, &dwarfmatrices[i]);

	effect->SetMatrix("matViewProj", &viewproj);

	if( SUCCEEDED(device->BeginScene()) )
	{
		// render sky
		device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);

		D3DXMatrixScaling(&skyworld, 20, 20, 20);
		skyeffect->SetMatrix("matWorld", &skyworld);

		D3DXMatrixIdentity(&skyworld);
		skyeffect->SetMatrix("matWorldSky", &skyworld);

		skyeffect->SetMatrix("matViewProj", &viewproj);
		skyeffect->SetVector("eyePos", (D3DXVECTOR4*)&eye);

		skyeffect->Begin(0, 0);
		skyeffect->BeginPass(0);
		{
			device->SetTexture(0, skytex);
			skymesh->DrawSubset(0);
		}
		skyeffect->EndPass();
		skyeffect->End();

		device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);

		// render ground
		D3DXMatrixScaling(&world, 5, 0.1f, 5);
		world._42 = -0.05f;

		device->SetTransform(D3DTS_WORLD, &world);
		device->SetTexture(0, texture2);
		mesh->DrawSubset(0);

		// dwarfs
		for( int i = 0; i < NUM_DWARFS; ++i )
			dwarfs[i].Draw();

		// fire
		D3DXMatrixTranslation(&world, 0, 0.25f, 0);
		device->SetTransform(D3DTS_WORLD, &world);

		system1.Draw(world, view);

		// render text
		device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1);
		device->SetRenderState(D3DRS_ZENABLE, FALSE);
		device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
		device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
		device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

		device->SetTexture(0, text);
		device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, textvertices, 6 * sizeof(float));

		device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
		device->SetRenderState(D3DRS_ZENABLE, TRUE);

		device->EndScene();
	}

	device->Present(NULL, NULL, NULL, NULL);
}