Test one abstraction

This commit is contained in:
disinvite 2025-04-15 00:11:30 -04:00
parent 602c9f558d
commit 62a7d63400
2 changed files with 36 additions and 8 deletions

View File

@ -26,6 +26,7 @@ namespace TglImpl
using namespace Tgl; using namespace Tgl;
// Utility function used by implementations // Utility function used by implementations
// FUNCTION: BETA10 0x10169cf0
inline Result ResultVal(HRESULT result) inline Result ResultVal(HRESULT result)
{ {
return SUCCEEDED(result) ? Success : Error; return SUCCEEDED(result) ? Success : Error;
@ -224,6 +225,7 @@ class ViewImpl : public View {
static Result ViewportCreateAppData(IDirect3DRM2*, IDirect3DRMViewport*, IDirect3DRMFrame2*); static Result ViewportCreateAppData(IDirect3DRM2*, IDirect3DRMViewport*, IDirect3DRMFrame2*);
inline void Destroy(); inline void Destroy();
Result SetCamera(const CameraImpl& rCamera);
friend class RendererImpl; friend class RendererImpl;

View File

@ -1,5 +1,7 @@
#include "impl.h" #include "impl.h"
#include <assert.h>
using namespace TglImpl; using namespace TglImpl;
struct ViewportAppData { struct ViewportAppData {
@ -61,6 +63,7 @@ Result ViewImpl::ViewportCreateAppData(IDirect3DRM2* pDevice, IDirect3DRMViewpor
return result; return result;
} }
// FUNCTION: BETA10 0x1016bd80
inline Result ViewRestoreFrameAfterRender( inline Result ViewRestoreFrameAfterRender(
IDirect3DRMFrame* pFrame, IDirect3DRMFrame* pFrame,
IDirect3DRMFrame* pCamera, IDirect3DRMFrame* pCamera,
@ -72,7 +75,11 @@ inline Result ViewRestoreFrameAfterRender(
// remove camera and light frame from frame that was rendered // remove camera and light frame from frame that was rendered
// this doesn't destroy the camera as it is still the camera of the viewport... // this doesn't destroy the camera as it is still the camera of the viewport...
result = ResultVal(pFrame->DeleteChild(pCamera)); result = ResultVal(pFrame->DeleteChild(pCamera));
assert(Succeeded(result));
assert((pCamera->AddRef(), pCamera->Release()) > 0);
result = ResultVal(pFrame->DeleteChild(pLightFrame)); result = ResultVal(pFrame->DeleteChild(pLightFrame));
assert(Succeeded(result));
// decrease frame's ref count (it was increased in ViewPrepareFrameForRender()) // decrease frame's ref count (it was increased in ViewPrepareFrameForRender())
pFrame->Release(); pFrame->Release();
@ -144,25 +151,44 @@ Result ViewImpl::Remove(const Light* pLight)
return ResultVal(ViewportGetLightFrame(m_data)->DeleteChild(frame)); return ResultVal(ViewportGetLightFrame(m_data)->DeleteChild(frame));
} }
// FUNCTION: LEGO1 0x100a2df0 // FUNCTION: BETA10 0x10170cc0
Result ViewImpl::SetCamera(const Camera* pCamera) inline Result ViewSetCamera(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame2* pCamera)
{ {
const CameraImpl* camera = static_cast<const CameraImpl*>(pCamera);
IDirect3DRMFrame2* frame = camera->ImplementationData();
ViewportAppData* pViewportAppData; ViewportAppData* pViewportAppData;
Result result; Result result;
pViewportAppData = reinterpret_cast<ViewportAppData*>(m_data->GetAppData()); pViewportAppData = reinterpret_cast<ViewportAppData*>(pViewport->GetAppData());
assert(pViewportAppData);
result = ViewRestoreFrameAfterRender( result = ViewRestoreFrameAfterRender(
pViewportAppData->m_pLastRenderedFrame, pViewportAppData->m_pLastRenderedFrame,
pViewportAppData->m_pCamera, pViewportAppData->m_pCamera,
pViewportAppData->m_pLightFrame pViewportAppData->m_pLightFrame
); );
pViewportAppData->m_pCamera = frame; assert(Succeeded(result));
pViewportAppData->m_pCamera = const_cast<IDirect3DRMFrame2*>(pCamera);
pViewportAppData->m_pLastRenderedFrame = 0; pViewportAppData->m_pLastRenderedFrame = 0;
return ResultVal(m_data->SetCamera(frame)); return ResultVal(pViewport->SetCamera(const_cast<IDirect3DRMFrame2*>(pCamera)));
}
// FUNCTION: BETA10 0x10170c20
inline Result ViewImpl::SetCamera(const CameraImpl& rCamera)
{
assert(m_data);
assert(rCamera.ImplementationData());
return ViewSetCamera(m_data, rCamera.ImplementationData());
}
// FUNCTION: LEGO1 0x100a2df0
// FUNCTION: BETA10 0x1016e790
Result ViewImpl::SetCamera(const Camera* pCamera)
{
assert(m_data);
assert(pCamera);
return SetCamera(*static_cast<const CameraImpl*>(pCamera));
} }
// FUNCTION: LEGO1 0x100a2e70 // FUNCTION: LEGO1 0x100a2e70