void ZombieForce::DrawScene()
{
	md3dImmediateContext->ClearRenderTargetView(mRenderTargetView, reinterpret_cast<const float*>(&Colors::Blue));
	md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0);

	md3dImmediateContext->IASetInputLayout(InputLayouts::Basic32);
    md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
 
	UINT stride = sizeof(Vertex::Basic32);
    UINT offset = 0;
	
	mCam.UpdateViewMatrix();

	XMMATRIX view  = mCam.View();
	XMMATRIX proj  = mCam.Proj();
	XMMATRIX viewProj = mCam.ViewProj();

	// Set per frame constants.
	Effects::BillboardFX->SetDirLights(mDirLights);
	Effects::BillboardFX->SetEyePosW(mCam.GetPosition());
	Effects::BillboardFX->SetCubeMap(mSky->CubeMapSRV());

	//ID3DX11EffectTechnique* activeTech = Effects::BasicFX->Light2TexTech;
	ID3DX11EffectTechnique* activeTech = Effects::BillboardFX->Light2TexTech;

    D3DX11_TECHNIQUE_DESC techDesc;
	activeTech->GetDesc( &techDesc );
    for(UINT p = 0; p < techDesc.Passes; ++p)
    {
		pyramid->DrawPyramid(md3dImmediateContext,activeTech, mCam);
		//myFirstSphere->DrawSphere(md3dImmediateContext,activeTech, mCam);
		myFirstPlane->DrawPlane(md3dImmediateContext,activeTech, mCam);
		//myFirstGeoSphere->DrawGeoSphere(md3dImmediateContext,activeTech, mCam);
		//myFirstCylinder->DrawCylinder(md3dImmediateContext,activeTech, mCam);
		for(unsigned int i = 0; i < spheres.size(); ++i)
		{
			spheres[i]->DrawSphere(md3dImmediateContext,activeTech, mCam);
		}
		for(unsigned int i = 0; i < boxes.size(); ++i)
		{
			boxes[i]->DrawBox(md3dImmediateContext,activeTech, mCam);
		}
		CMESHMANAGER->Render(md3dImmediateContext, activeTech, mCam);
    }

	mSky->Draw(md3dImmediateContext, mCam);

	// restore default states, as the SkyFX changes them in the effect file.
	md3dImmediateContext->RSSetState(0);
	md3dImmediateContext->OMSetDepthStencilState(0, 0);

	HR(mSwapChain->Present(0, 0));
}
Example #2
0
int main(int argc, char ** argv[])
{

	Display display(800, 600, "TSBK07 Level of Detail on Terrain");
	Basic_Shader base_shader("./shaders/space");
	Phong_Shader phong("./shaders/phong");
	Texture texture("./textures/dirt.tga");
	Camera camera(glm::vec3(0, 1, 0), 70.0f, display.GetAspectRation(), 0.01f, 1000.0f);

	Terrain terr("./textures/terrain2.jpg", "./textures/terrain2.jpg");
	
	Skybox sky;
	sky.SkyboxInit("./textures/skybox/", "back.jpg", "front.jpg", "left.jpg", "right.jpg", "top.jpg", "bottom.jpg");
	Transform transform;
	Keyboard keyboard;
	Mouse mouse;

	float counter = 0.0f;
	Mesh monkey("./models/monkey3.obj");
	Mesh box("./models/box.obj");

	std::cout << "init complete" << std::endl;

	bool wireframe = true;
	bool lock = false;

	while (!display.IsClosed())
	{
		display.Clear(1, 0, 1, 1);

		SDL_Event e;

		while (SDL_PollEvent(&e))
		{
			if (e.type == SDL_QUIT)
			{
				display.HandleEvent(e);
			}
			if (e.type == SDL_MOUSEMOTION || e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP)
			{
				mouse.HandleEvent(e, camera);
			}
		}

		const Uint8* currentKeyStates = SDL_GetKeyboardState(NULL);

		keyboard.HandleEvent(currentKeyStates, camera);
		
		sky.Draw(transform, camera);

		if (currentKeyStates[SDL_SCANCODE_B])
		{
			lock = !lock;
		}
		if (currentKeyStates[SDL_SCANCODE_F])
		{
			wireframe = !wireframe;
		}
	
		terr.Draw(transform, camera, lock, wireframe);

		display.Update();

		counter += 0.001f;
	}
	return 0;
}