Implement/match Tgl::View::Render (#566)

This commit is contained in:
Christian Semmler 2024-02-16 10:28:20 -05:00 committed by GitHub
parent efcb3cac2a
commit 5d80733cb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 27 deletions

View file

@ -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));

View file

@ -170,7 +170,7 @@ class ViewImpl : public View {
// 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 @@ class GroupImpl : public Group {
// vtable+0x30
Result Unknown() override;
inline IDirect3DRMFrame2* ImplementationData() const { return m_data; }
friend class RendererImpl;
private:

View file

@ -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<const LightImpl*>(pCamera)->ImplementationData();
pViewportAppData = reinterpret_cast<ViewportAppData*>(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<IDirect3DRMFrame2*>(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<IDirect3DRMFrame2*>(pGroup)));
return result;
}
// FUNCTION: LEGO1 0x100a2fd0
Result ViewImpl::Render(const Group* pGroup)
{
return ViewRender(m_data, static_cast<const GroupImpl*>(pGroup)->ImplementationData());
}
// FUNCTION: LEGO1 0x100a3080

View file

@ -189,7 +189,7 @@ class View : public Object {
// 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