Exemplo n.º 1
0
	// -----------------------------------------------------
	void CGraphicsRenderer::RenderScene()
	{
		// render scene to diffuse RT
		CRenderer::cGraphicsDevice()->BeginRendering(1, m_mrt_diffuse);
		//CRenderer::cGraphicsDevice()->Clear(ColorRGB(0,1,1));

		for (unsigned int i=0; i<m_chunks.Size(); i++)
		{
			const GeometryChunk& chunk = m_chunks[i];

			CIndexBuffer* ib = CRenderer::cGraphicsManager()->GetCachedIndexBuffer(chunk.Data->ibId);
			CVertexBuffer* vb = CRenderer::cGraphicsManager()->GetCachedVertexBuffer(chunk.Data->vbId);

			ib->Use();
			vb->Use();

			// OPTIM: if we ensure valid pointer every time, remove this if-s
			if (chunk.Subset->materialPtr)
			{
				CShader *vs = (CShader*)chunk.Subset->materialPtr->vsPtr;
				CShader *ps = (CShader*)chunk.Subset->materialPtr->psPtr;

				if (ps) 
					ps->Use();

				if (vs)
				{
					vs->Use();
				}
			}


			vb->RenderIndexed(P3DPT_TRIANGLELIST, chunk.Subset->StartIndex, chunk.Subset->NumTriangles);
			
		}

		CRenderer::cGraphicsDevice()->EndRendering();

		// render diffuse RT on standard backbuffer
		CRenderer::cGraphicsDevice()->BeginRendering();
			
			CRenderer::cPrimitiveRenderer()->AddRectangleRel(Vec2(0.0f, 0.0f), Vec2(1.0f, -1.0f), ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), m_mrt_diffuse);
			CRenderer::cPrimitiveRenderer()->Render();

		CRenderer::cGraphicsDevice()->EndRendering();
	}
Exemplo n.º 2
0
	// -----------------------------------------------------
	void CGraphicsRenderer::RenderScene(sFrameBufferUnit *FBUnits, UINT numUnits)
	{
		if(FBUnits != NULL) 
		{
			//TODO: setup the appropriate render targets
			CRenderer::cGraphicsDevice()->BeginRendering(1, m_mrt_diffuse);
			//CRenderer::cGraphicsDevice()->Clear(ColorRGB(0,1,1));
		}
		else CRenderer::cGraphicsDevice()->BeginRendering(); //render to back buffer

		for (unsigned int i=0; i<m_chunks.Size(); i++)
		{
			const GeometryChunk& chunk = m_chunks[i];

			CIndexBuffer* ib = CRenderer::cGraphicsManager()->GetCachedIndexBuffer(chunk.Data->ibId);
			CVertexBuffer* vb = CRenderer::cGraphicsManager()->GetCachedVertexBuffer(chunk.Data->vbId);

			ib->Use();
			vb->Use();

			// OPTIM: if we ensure valid pointer every time, remove this if-s
			if (chunk.Subset->materialPtr)
			{
				CShader *vs = (CShader*)chunk.Subset->materialPtr->vsPtr;
				CShader *ps = (CShader*)chunk.Subset->materialPtr->psPtr;

				if (ps) 
					ps->Use();

				if (vs)
				{
					vs->Use();
				}
			}


			vb->RenderIndexed(P3DPT_TRIANGLELIST, chunk.Subset->StartIndex, chunk.Subset->NumTriangles);

		}

		CRenderer::cGraphicsDevice()->EndRendering();

	}