コード例 #1
0
ファイル: VoxRender.cpp プロジェクト: Clever-Boy/Vox
void VoxGame::Render()
{
	if (m_pVoxWindow->GetMinimized())
	{
		// Don't call any render functions if minimized
		return;
	}

	glShader* pShader = NULL;

	// Begin rendering
	m_pRenderer->BeginScene(true, true, true);

		// Shadow rendering to the shadow frame buffer
		if (m_shadows)
		{
			RenderShadows();
		}

		// SSAO frame buffer rendering start
		if (m_deferredRendering)
		{
			m_pRenderer->StartRenderingToFrameBuffer(m_SSAOFrameBuffer);
		}

		// ---------------------------------------
		// Render 3d
		// ---------------------------------------
		m_pRenderer->PushMatrix();
			// Set the default projection mode
			m_pRenderer->SetProjectionMode(PM_PERSPECTIVE, m_defaultViewport);

			// Set back culling as default
			m_pRenderer->SetCullMode(CM_BACK);

			// Set default depth test
			m_pRenderer->EnableDepthTest(DT_LESS);

			// Set the lookat camera
			m_pGameCamera->Look();

			// Enable the lights
			m_pRenderer->PushMatrix();
				m_pRenderer->EnableLight(m_defaultLight, 0);
			m_pRenderer->PopMatrix();

			// Multisampling MSAA
			if (m_multiSampling)
			{
				m_pRenderer->EnableMultiSampling();
			}
			else
			{
				m_pRenderer->DisableMultiSampling();
			}

			// Render the lights (DEBUG)
			m_pRenderer->PushMatrix();
				m_pRenderer->SetCullMode(CM_BACK);
				m_pRenderer->SetRenderMode(RM_SOLID);
				m_pRenderer->RenderLight(m_defaultLight);
			m_pRenderer->PopMatrix();

			if (m_shadows)
			{
				m_pRenderer->BeginGLSLShader(m_shadowShader);

				pShader = m_pRenderer->GetShader(m_shadowShader);
				GLuint shadowMapUniform = glGetUniformLocationARB(pShader->GetProgramObject(), "ShadowMap");
				m_pRenderer->PrepareShaderTexture(7, shadowMapUniform);
				m_pRenderer->BindRawTextureId(m_pRenderer->GetDepthTextureFromFrameBuffer(m_shadowFrameBuffer));
				glUniform1iARB(glGetUniformLocationARB(pShader->GetProgramObject(), "renderShadow"), m_shadows);
				glUniform1iARB(glGetUniformLocationARB(pShader->GetProgramObject(), "alwaysShadow"), false);
			}
			else
			{
				m_pRenderer->BeginGLSLShader(m_defaultShader);
			}

			// Render world
			//RenderWorld();

			// Render the chunks
			m_pChunkManager->Render();

			// Render the player
			if (m_cameraMode == CameraMode_FirstPerson)
			{
				m_pPlayer->RenderFirstPerson();
			}
			else
			{
				m_pPlayer->Render();
			}

			// Render the block particles
			m_pBlockParticleManager->Render();

			if (m_shadows)
			{
				m_pRenderer->EndGLSLShader(m_shadowShader);
			}
			else
			{
				m_pRenderer->EndGLSLShader(m_defaultShader);
			}

			// Debug rendering
			if(m_debugRender)
			{
				m_pLightingManager->DebugRender();

				m_pBlockParticleManager->RenderDebug();

				m_pPlayer->RenderDebug();

				m_pChunkManager->RenderDebug();
			}
		m_pRenderer->PopMatrix();

		// Render the deferred lighting pass
		if (m_dynamicLighting)
		{
			RenderDeferredLighting();
		}

		// ---------------------------------------
		// Render 2d
		// ---------------------------------------
		m_pRenderer->PushMatrix();
		m_pRenderer->PopMatrix();

		// SSAO frame buffer rendering stop
		if (m_deferredRendering)
		{
			m_pRenderer->StopRenderingToFrameBuffer(m_SSAOFrameBuffer);
		}

		// ---------------------------------------
		// Render transparency
		// ---------------------------------------
		RenderTransparency();

		// Render the SSAO texture
		if (m_deferredRendering)
		{
			RenderSSAOTexture();

			if (m_multiSampling && m_fxaaShader != -1)
			{
				RenderFXAATexture();
			}

			if(m_blur)
			{
				RenderFirstPassFullScreen();
				RenderSecondPassFullScreen();
			}
		}

		// Disable multisampling for 2d gui and text
		m_pRenderer->DisableMultiSampling();

		// Render debug information and text
		RenderDebugInformation();

		// Render the chunks 2d
		if (m_debugRender)
		{
			//m_pChunkManager->Render2D(m_pGameCamera, m_defaultViewport, m_defaultFont);
		}

		// Render the GUI
		RenderGUI();

	// End rendering
	m_pRenderer->EndScene();


	// Pass render call to the window class, allow to swap buffers
	m_pVoxWindow->Render();
}
コード例 #2
0
ファイル: VoxRender.cpp プロジェクト: Cyberbanan/Vox
void VoxGame::Render()
{
	if (m_pVoxWindow->GetMinimized())
	{
		// Don't call any render functions if minimized
		return;
	}

	// Begin rendering
	m_pRenderer->BeginScene(true, true, true);

		// Shadow rendering to the shadow frame buffer
		if (m_shadows)
		{
			RenderShadows();
		}

		// ---------------------------------------
		// Render 3d
		// ---------------------------------------
		m_pRenderer->PushMatrix();
			// Set the default projection mode
			m_pRenderer->SetProjectionMode(PM_PERSPECTIVE, m_defaultViewport);

			// Set back culling as default
			m_pRenderer->SetCullMode(CM_BACK);

			// Set default depth test
			m_pRenderer->EnableDepthTest(DT_LESS);

			// Set the lookat camera
			m_pGameCamera->Look();

			// Enable the lights
			m_pRenderer->PushMatrix();
				m_pRenderer->EnableLight(m_defaultLight, 0);
			m_pRenderer->PopMatrix();

			// Multisampling MSAA
			if (m_multiSampling)
			{
				m_pRenderer->EnableMultiSampling();
			}
			else
			{
				m_pRenderer->DisableMultiSampling();
			}

			// Water reflections
			if (m_waterRender && m_pChunkManager->IsUnderWater(m_pGameCamera->GetPosition()) == false && m_gameMode != GameMode_FrontEnd)
			{
				RenderWaterReflections();
			}

			// SSAO frame buffer rendering start
			if (m_deferredRendering)
			{
				m_pRenderer->StartRenderingToFrameBuffer(m_SSAOFrameBuffer);
			}

			m_pRenderer->SetClearColour(0.0f, 0.0f, 0.0f, 1.0f);
			m_pRenderer->ClearScene(true, true, true);

			// Render the lights (DEBUG)
			m_pRenderer->PushMatrix();
				m_pRenderer->SetCullMode(CM_BACK);
				m_pRenderer->SetRenderMode(RM_SOLID);
				m_pRenderer->RenderLight(m_defaultLight);
			m_pRenderer->PopMatrix();

			// Render the skybox
			RenderSkybox();

			BeginShaderRender();
			{
				// Render the chunks
				m_pChunkManager->Render(false);
			}
			EndShaderRender();

			// NPC sub selection - For character creation screen
			m_pNPCManager->RenderSubSelectionNormalNPCs();

			// Render items outline and silhouette before the world/chunks
			m_pItemManager->Render(true, false, false, false);
			m_pItemManager->Render(false, false, true, false);

			// NPCs (only non outline and hover)
			m_pNPCManager->RenderOutlineNPCs();
			m_pNPCManager->Render(false, false, true, false, false, false);

			// Enemies outline
			m_pEnemyManager->RenderOutlineEnemies();
			m_pEnemyManager->Render(false, false, true, false);

			BeginShaderRender();
			{
				// Scenery
				m_pSceneryManager->Render(false, false, false, false, false);

				// Projectiles
				m_pProjectileManager->Render();

				// Items
				m_pItemManager->Render(false, false, false, false);

				// NPCs
				m_pNPCManager->ResetNumRenderNPCs();
				m_pNPCManager->Render(false, false, false, false, true, false);

				// Enemies
				m_pEnemyManager->Render(false, false, false, false);

				// NPCs (only outline and hover)
				m_pNPCManager->Render(false, false, false, true, false, false);
				m_pNPCManager->RenderSubSelectionOverlayNPCs();
			}
			EndShaderRender();

			// Player selection block
			m_pPlayer->RenderSelectionBlock();

			// Render the block particles
			m_pBlockParticleManager->Render(false);

			// Render the instanced objects
			if(m_instanceRender)
			{
				m_pInstanceManager->Render();
			}

			// Frontend
			m_pFrontendManager->Render();

			BeginShaderRender();
			{

				if (m_gameMode != GameMode_FrontEnd)
				{
					// Render the player
					if (m_cameraMode != CameraMode_FirstPerson)
					{
						m_pPlayer->Render();
					}
				}
			}
			EndShaderRender();

			// Render the transparency items above the water render, so that they appear properly under water
			if (m_waterRender && m_gameMode != GameMode_FrontEnd)
			{
				if (m_cameraMode != CameraMode_FirstPerson)
				{
					m_pPlayer->RenderFace();
				}
				m_pNPCManager->RenderFaces();
				m_pEnemyManager->RenderFaces();

				if (m_cameraMode != CameraMode_FirstPerson)
				{
					m_pPlayer->RenderWeaponTrails();
				}
				m_pNPCManager->RenderWeaponTrails();
				m_pEnemyManager->RenderWeaponTrails();

				// Render water
				RenderWater();
			}

			// Debug rendering
			if(m_debugRender)
			{
				m_pLightingManager->DebugRender();

				m_pBlockParticleManager->RenderDebug();

				if (m_gameMode != GameMode_FrontEnd)
				{
					m_pPlayer->RenderDebug();
				}

				m_pNPCManager->RenderDebug();

				m_pEnemyManager->RenderDebug();

				m_pSceneryManager->RenderDebug();

				m_pItemManager->RenderDebug();

				m_pChunkManager->RenderDebug();

				m_pProjectileManager->RenderDebug();

				m_pBiomeManager->RenderDebug();

				if (m_gameMode == GameMode_FrontEnd)
				{
					m_pFrontendManager->RenderDebug();
				}
			}

			// Render player first person viewport
			if (m_gameMode != GameMode_FrontEnd)
			{
				if (m_cameraMode == CameraMode_FirstPerson)
				{
					RenderFirstPersonViewport();
				}
			}

			// SSAO frame buffer rendering stop
			if (m_deferredRendering)
			{
				m_pRenderer->StopRenderingToFrameBuffer(m_SSAOFrameBuffer);
			}
		m_pRenderer->PopMatrix();

		// Render the deferred lighting pass
		if (m_dynamicLighting)
		{
			RenderDeferredLighting();
		}

		// Render other viewports
		// Paperdoll for CharacterGUI
		RenderPaperdollViewport();
		// Portrait for HUD
		if (m_pVoxSettings->m_renderGUI)
		{
			RenderPortraitViewport();
		}

		// ---------------------------------------
		// Render transparency
		// ---------------------------------------
		RenderTransparency();

		// Render the SSAO texture
		if (m_deferredRendering)
		{
			RenderSSAOTexture();

			if (m_multiSampling && m_fxaaShader != -1)
			{
				RenderFXAATexture();
			}

			if(m_blur || m_pChunkManager->IsUnderWater(m_pGameCamera->GetPosition()))
			{
				RenderFirstPassFullScreen();
				RenderSecondPassFullScreen();
			}
		}

		// ---------------------------------------
		// Render 2d
		// ---------------------------------------
		m_pRenderer->PushMatrix();
			// Crosshair
			if (m_cameraMode == CameraMode_FirstPerson && m_bPaused == false)
			{
				if (m_pPlayer->IsDead() == false)
				{
					RenderCrosshair();
				}
			}

			// Text effects
			m_pTextEffectsManager->Render();

			// Cinematic mode (letter box)
			RenderCinematicLetterBox();

			// Render the HUD
			if (m_pVoxSettings->m_renderGUI)
			{
				RenderHUD();
			}
		m_pRenderer->PopMatrix();

		// Disable multisampling for 2d gui and text
		m_pRenderer->DisableMultiSampling();

		// Render other deferred rendering pipelines
		// Paperdoll SSAO for CharacterGUI
		RenderDeferredRenderingPaperDoll();
		// Portrait SSAO for HUD
		if (m_pVoxSettings->m_renderGUI)
		{
			RenderDeferredRenderingPortrait();
		}

		// Render the chunks 2d (debug text information)
		if (m_debugRender)
		{
			//m_pChunkManager->Render2D(m_pGameCamera, m_defaultViewport, m_defaultFont);
		}

		// Frontend 2D
		if(m_gameMode == GameMode_FrontEnd)
		{			
			m_pRenderer->PushMatrix();
				m_pRenderer->SetProjectionMode(PM_2D, m_defaultViewport);
				m_pRenderer->SetCullMode(CM_BACK);

				m_pRenderer->SetLookAtCamera(vec3(0.0f, 0.0f, 250.0f), vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f));

				m_pFrontendManager->Render2D();
			m_pRenderer->PopMatrix();
		}

		// Render the GUI
		RenderGUI();

		// Custom cursor
		if (m_pVoxSettings->m_customCursors && m_bCustomCursorOn)
		{
			if (m_gameMode != GameMode_FrontEnd || m_pFrontendManager->GetFrontendScreen() != FrontendScreen_Intro)
			{
				RenderCustomCursor();
			}
		}

		// Render debug information and text
		RenderDebugInformation();

		// Update the NPC screen positions for select character screen
		m_pNPCManager->UpdateScreenCoordinates2d(m_pGameCamera);

	// End rendering
	m_pRenderer->EndScene();


	// Pass render call to the window class, allow to swap buffers
	m_pVoxWindow->Render();
}