From 5d80733cb1d1cdd08b71b117b2a0ce8821a76c55 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 16 Feb 2024 10:28:20 -0500 Subject: [PATCH] Implement/match Tgl::View::Render (#566) --- LEGO1/lego/sources/3dmanager/tglsurface.cpp | 3 +- LEGO1/tgl/d3drm/impl.h | 4 +- LEGO1/tgl/d3drm/view.cpp | 53 ++++++++++++--------- LEGO1/tgl/tgl.h | 2 +- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/LEGO1/lego/sources/3dmanager/tglsurface.cpp b/LEGO1/lego/sources/3dmanager/tglsurface.cpp index 394e03e5..9664b2b2 100644 --- a/LEGO1/lego/sources/3dmanager/tglsurface.cpp +++ b/LEGO1/lego/sources/3dmanager/tglsurface.cpp @@ -181,8 +181,7 @@ double TglSurface::Render() m_renderingRateMeter.StartOperation(); renderTimer.Start(); - // TODO: Wrong interface - result = m_pView->Render((Tgl::Light*) m_pScene); + result = m_pView->Render(m_pScene); renderTimer.Stop(); assert(Succeeded(result)); diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index d1e2e7fc..d3cb7440 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -170,7 +170,7 @@ public: // vtable+0x20 Result GetBackgroundColor(float* r, float* g, float* b) override; Result Clear() override; - Result Render(const Light*) override; + Result Render(const Group*) override; Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height) override; // vtable+0x30 @@ -319,6 +319,8 @@ public: // vtable+0x30 Result Unknown() override; + inline IDirect3DRMFrame2* ImplementationData() const { return m_data; } + friend class RendererImpl; private: diff --git a/LEGO1/tgl/d3drm/view.cpp b/LEGO1/tgl/d3drm/view.cpp index dcaa21ae..457c54d2 100644 --- a/LEGO1/tgl/d3drm/view.cpp +++ b/LEGO1/tgl/d3drm/view.cpp @@ -244,33 +244,40 @@ inline Result ViewPrepareFrameForRender( return result; } -// FUNCTION: LEGO1 0x100a2fd0 -Result ViewImpl::Render(const Light* pCamera) +inline Result ViewRender(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame2* pGroup) { - ViewportAppData* appdata = ViewportGetData(m_data); + ViewportAppData* pViewportAppData; + Result result; - IDirect3DRMFrame2* light = static_cast(pCamera)->ImplementationData(); + pViewportAppData = reinterpret_cast(pViewport->GetAppData()); - IDirect3DRMFrame2* lastRendered = appdata->m_pLastRenderedFrame; - if (light != lastRendered) { - if (lastRendered) { - lastRendered->DeleteChild(appdata->m_pCamera); - // Some other call goes here, not sure what. - lastRendered->Release(); - } - appdata->m_pLastRenderedFrame = light; - if (light) { - light->SetSceneBackgroundRGB( - appdata->m_backgroundColorRed, - appdata->m_backgroundColorGreen, - appdata->m_backgroundColorBlue - ); - light->AddChild(appdata->m_pCamera); - // Some other call goes here, not sure what. - light->AddRef(); - } + if (pViewportAppData->m_pLastRenderedFrame != pGroup) { + result = ViewRestoreFrameAfterRender( + pViewportAppData->m_pLastRenderedFrame, + pViewportAppData->m_pCamera, + pViewportAppData->m_pLightFrame + ); + + pViewportAppData->m_pLastRenderedFrame = const_cast(pGroup); + + result = ViewPrepareFrameForRender( + pViewportAppData->m_pLastRenderedFrame, + pViewportAppData->m_pCamera, + pViewportAppData->m_pLightFrame, + pViewportAppData->m_backgroundColorRed, + pViewportAppData->m_backgroundColorGreen, + pViewportAppData->m_backgroundColorBlue + ); } - return ResultVal(m_data->Render(light)); + + result = ResultVal(pViewport->Render(const_cast(pGroup))); + return result; +} + +// FUNCTION: LEGO1 0x100a2fd0 +Result ViewImpl::Render(const Group* pGroup) +{ + return ViewRender(m_data, static_cast(pGroup)->ImplementationData()); } // FUNCTION: LEGO1 0x100a3080 diff --git a/LEGO1/tgl/tgl.h b/LEGO1/tgl/tgl.h index 630510b9..d03eecbc 100644 --- a/LEGO1/tgl/tgl.h +++ b/LEGO1/tgl/tgl.h @@ -189,7 +189,7 @@ public: // vtable+0x20 virtual Result GetBackgroundColor(float* r, float* g, float* b) = 0; virtual Result Clear() = 0; - virtual Result Render(const Light*) = 0; + virtual Result Render(const Group*) = 0; virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height) = 0; // vtable+0x30