From a37f536ae9b18e5cece7cfa5afbf84b550a64429 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 20 Feb 2016 02:26:43 -0800 Subject: [PATCH] Use rendertarget --- Runtime/MP1/main.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Runtime/MP1/main.cpp b/Runtime/MP1/main.cpp index e1d0c3036..883b91f56 100644 --- a/Runtime/MP1/main.cpp +++ b/Runtime/MP1/main.cpp @@ -109,6 +109,8 @@ class CGameArchitectureSupport : public boo::IWindowCallback CMainFlow m_mainFlow; CConsoleOutputWindow m_consoleWindow; CAudioStateWin m_audioStateWin; + boo::SWindowRect m_windowRect; + bool m_rectIsDirty; void mouseDown(const boo::SWindowCoord &coord, boo::EMouseButton button, boo::EModifierKey mods) { m_inputGenerator.mouseDown(coord, button, mods); } @@ -133,6 +135,12 @@ class CGameArchitectureSupport : public boo::IWindowCallback void destroyed() { m_archQueue.Push(std::move(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport))); } + void resized(const boo::SWindowRect &rect) + { + m_windowRect = rect; + m_rectIsDirty = true; + } + public: CGameArchitectureSupport() : m_audioSys(0,0,0,0,0), @@ -164,6 +172,13 @@ public: } return finished; } + + bool isRectDirty() { return m_rectIsDirty; } + const boo::SWindowRect& getWindowRect() + { + m_rectIsDirty = false; + return m_windowRect; + } }; CMain::CMain() @@ -222,6 +237,8 @@ int CMain::appMain(boo::IApplication* app) mainWindow->setCallback(archSupport.GetAllocSpace()); boo::IGraphicsCommandQueue* gfxQ = mainWindow->getCommandQueue(); + boo::SWindowRect windowRect = mainWindow->getWindowFrame(); + boo::ITextureR* renderTex = mainWindow->getMainContextDataFactory()->newRenderTexture(windowRect.size[0], windowRect.size[1], 1); float rgba[4] = { 0.2f, 0.2f, 0.2f, 1.0f}; gfxQ->setClearColor(rgba); @@ -229,9 +246,18 @@ int CMain::appMain(boo::IApplication* app) { mainWindow->waitForRetrace(); xe8_b24_finished = archSupport->Update(); - gfxQ->clearTarget(); - gfxQ->resolveDisplay(nullptr); + if (archSupport->isRectDirty()) + { + const boo::SWindowRect& windowRect = archSupport->getWindowRect(); + gfxQ->resizeRenderTexture(renderTex, + windowRect.size[0], + windowRect.size[1]); + } + + gfxQ->setRenderTarget(renderTex); + gfxQ->clearTarget(); + gfxQ->resolveDisplay(renderTex); gfxQ->execute(); } return 0;