From eab2386ff6f740fb1b1fc50ecfa816bec56f7550 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 5 Jul 2013 03:42:38 +0200 Subject: [PATCH] Don't render to texture when in wireframe mode, re #43 --HG-- branch : multipass-stereo --- code/nel/src/3d/stereo_debugger.cpp | 59 ++++++++----- code/nel/src/3d/stereo_ovr.cpp | 123 ++++++++++++++++------------ code/ryzom/client/src/main_loop.cpp | 11 +-- 3 files changed, 114 insertions(+), 79 deletions(-) diff --git a/code/nel/src/3d/stereo_debugger.cpp b/code/nel/src/3d/stereo_debugger.cpp index 036cb7e1b..9255fa812 100644 --- a/code/nel/src/3d/stereo_debugger.cpp +++ b/code/nel/src/3d/stereo_debugger.cpp @@ -257,20 +257,41 @@ void CStereoDebugger::getClippingFrustum(uint cid, NL3D::UCamera *camera) const /// Is there a next pass bool CStereoDebugger::nextPass() { - switch (m_Stage) + if (m_Driver->getPolygonMode() == UDriver::Filled) { - case 0: - ++m_Stage; - m_SubStage = 0; - return true; - case 1: - ++m_Stage; - m_SubStage = 0; - return true; - case 2: - m_Stage = 0; - m_SubStage = 0; - return false; + switch (m_Stage) + { + case 0: + ++m_Stage; + m_SubStage = 0; + return true; + case 1: + ++m_Stage; + m_SubStage = 0; + return true; + case 2: + ++m_Stage; + m_SubStage = 0; + return true; + case 3: + m_Stage = 0; + m_SubStage = 0; + return false; + } + } + else + { + switch (m_Stage) + { + case 0: + ++m_Stage; + m_SubStage = 0; + return true; + case 1: + m_Stage = 0; + m_SubStage = 0; + return false; + } } } @@ -303,34 +324,34 @@ void CStereoDebugger::getCurrentMatrix(uint cid, NL3D::UCamera *camera) const bool CStereoDebugger::wantClear() { m_SubStage = 1; - return true; + return m_Stage != 3; } /// The 3D scene bool CStereoDebugger::wantScene() { m_SubStage = 2; - return true; + return m_Stage != 3; } /// Interface within the 3D scene bool CStereoDebugger::wantInterface3D() { m_SubStage = 3; - return true; + return m_Stage == 3; } /// 2D Interface bool CStereoDebugger::wantInterface2D() { m_SubStage = 4; - return true; + return m_Stage == 3; } /// Returns true if a new render target was set, always fase if not using render targets bool CStereoDebugger::beginRenderTarget() { - if (m_Driver) + if (m_Stage != 3 && m_Driver && (m_Driver->getPolygonMode() == UDriver::Filled)) { if (m_Stage % 2) static_cast(m_Driver)->setRenderTarget(*m_RightTexU, 0, 0, 0, 0); else static_cast(m_Driver)->setRenderTarget(*m_LeftTexU, 0, 0, 0, 0); @@ -342,7 +363,7 @@ bool CStereoDebugger::beginRenderTarget() /// Returns true if a render target was fully drawn, always false if not using render targets bool CStereoDebugger::endRenderTarget() { - if (m_Driver) + if (m_Stage != 3 && m_Driver && (m_Driver->getPolygonMode() == UDriver::Filled)) { CTextureUser cu; (static_cast(m_Driver))->setRenderTarget(cu); diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index e7e31d557..2b91e1836 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -359,54 +359,71 @@ bool CStereoOVR::nextPass() nlassert(width == m_DevicePtr->HMDInfo.HResolution); nlassert(height == m_DevicePtr->HMDInfo.VResolution); - switch (m_Stage) + if (m_Driver->getPolygonMode() == UDriver::Filled) { - case 0: - ++m_Stage; - m_SubStage = 0; - // stage 1: - // (initBloom) - // clear buffer - // draw scene left - return true; - case 1: - ++m_Stage; - m_SubStage = 0; - // stage 2: - // draw scene right - return true; - case 2: - ++m_Stage; - m_SubStage = 0; - // stage 3: - // (endBloom) - // draw interface 3d left - return true; - case 3: - ++m_Stage; - m_SubStage = 0; - // stage 4: - // draw interface 3d right - return true; - case 4: - ++m_Stage; - m_SubStage = 0; - // stage 5: - // (endInterfacesDisplayBloom) - // draw interface 2d left - return true; - case 5: - ++m_Stage; - m_SubStage = 0; - // stage 6: - // draw interface 2d right - return true; - case 6: - m_Stage = 0; - m_SubStage = 0; - // present - m_OrientationCached = false; - return false; + switch (m_Stage) + { + case 0: + ++m_Stage; + m_SubStage = 0; + // stage 1: + // (initBloom) + // clear buffer + // draw scene left + return true; + case 1: + ++m_Stage; + m_SubStage = 0; + // stage 2: + // draw scene right + return true; + case 2: + ++m_Stage; + m_SubStage = 0; + // stage 3: + // (endBloom) + // draw interface 3d left + return true; + case 3: + ++m_Stage; + m_SubStage = 0; + // stage 4: + // draw interface 3d right + return true; + case 4: + ++m_Stage; + m_SubStage = 0; + // stage 5: + // (endInterfacesDisplayBloom) + // draw interface 2d left + return true; + case 5: + ++m_Stage; + m_SubStage = 0; + // stage 6: + // draw interface 2d right + return true; + case 6: + m_Stage = 0; + m_SubStage = 0; + // present + m_OrientationCached = false; + return false; + } + } + else + { + switch (m_Stage) + { + case 0: + ++m_Stage; + m_SubStage = 0; + return true; + case 1: + m_Stage = 0; + m_SubStage = 0; + return false; + } } nlerror("Invalid stage"); m_Stage = 0; @@ -459,7 +476,7 @@ bool CStereoOVR::wantClear() m_SubStage = 1; return true; } - return false; + return m_Driver->getPolygonMode() != UDriver::Filled; } bool CStereoOVR::wantScene() @@ -471,7 +488,7 @@ bool CStereoOVR::wantScene() m_SubStage = 2; return true; } - return false; + return m_Driver->getPolygonMode() != UDriver::Filled; } bool CStereoOVR::wantInterface3D() @@ -483,7 +500,7 @@ bool CStereoOVR::wantInterface3D() m_SubStage = 3; return true; } - return false; + return m_Driver->getPolygonMode() != UDriver::Filled; } bool CStereoOVR::wantInterface2D() @@ -495,7 +512,7 @@ bool CStereoOVR::wantInterface2D() m_SubStage = 4; return true; } - return false; + return m_Driver->getPolygonMode() != UDriver::Filled; } @@ -504,7 +521,7 @@ bool CStereoOVR::beginRenderTarget() { // render target always set before driver clear // nlassert(m_SubStage <= 1); - if (m_Driver && m_Stage == 1) + if (m_Driver && m_Stage == 1 && (m_Driver->getPolygonMode() == UDriver::Filled)) { static_cast(m_Driver)->setRenderTarget(*m_BarrelTexU, 0, 0, 0, 0); return true; @@ -517,7 +534,7 @@ bool CStereoOVR::endRenderTarget() { // after rendering of course // nlassert(m_SubStage > 1); - if (m_Driver && m_Stage == 6) // set to 4 to turn off distortion of 2d gui + if (m_Driver && m_Stage == 6 && (m_Driver->getPolygonMode() == UDriver::Filled)) // set to 4 to turn off distortion of 2d gui { CTextureUser cu; (static_cast(m_Driver))->setRenderTarget(cu); diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 095236ef0..7b7c0bd9c 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1627,14 +1627,11 @@ bool mainLoop() // RENDER THE FRAME 3D // ////////////////////////// - if (StereoDisplay) - { - StereoDisplay->beginRenderTarget(); - } + bool stereoRenderTarget = (StereoDisplay != NULL) && StereoDisplay->beginRenderTarget(); if (!StereoDisplay || StereoDisplay->wantClear()) { - if(Render) + if (Render) { if (ClientCfg.Bloom) { @@ -1777,14 +1774,14 @@ bool mainLoop() Driver->setMatrixMode2D11(); // draw a big quad to represent thunder strokes - if (Render && WeatherManager.getThunderLevel() != 0.f) + /*if (Render && WeatherManager.getThunderLevel() != 0.f) { H_AUTO_USE ( RZ_Client_Main_Loop_Render_Thunder ) Driver->drawQuad(0, 0, 1, 1, ThunderColor); // TODO : boris : add sound here ! // Needs more explosions - } + }*/ // Update the contextual menu {