mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-19 22:31:15 +00:00
RendererImpl::CreateView
This commit is contained in:
parent
e84abc3fe4
commit
f00f793ab5
@ -105,6 +105,15 @@ class RendererImpl : public Renderer {
|
||||
inline Result Create();
|
||||
inline void Destroy();
|
||||
inline Result CreateLight(LightType type, float r, float g, float b, LightImpl& rLight);
|
||||
inline Result CreateView(
|
||||
const DeviceImpl& rDevice,
|
||||
const CameraImpl& rCamera,
|
||||
unsigned long x,
|
||||
unsigned long y,
|
||||
unsigned long width,
|
||||
unsigned long height,
|
||||
ViewImpl& rView
|
||||
);
|
||||
|
||||
private:
|
||||
RendererDataType m_data;
|
||||
@ -233,8 +242,9 @@ class ViewImpl : public View {
|
||||
|
||||
typedef IDirect3DRMViewport* ViewDataType;
|
||||
|
||||
// FUNCTION: BETA10 0x101711c0
|
||||
const ViewDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x101711c0
|
||||
ViewDataType& ImplementationData() { return m_data; }
|
||||
|
||||
void SetImplementationData(IDirect3DRMViewport* viewport) { m_data = viewport; }
|
||||
@ -783,6 +793,9 @@ inline D3DRMLIGHTTYPE Translate(LightType tglLightType)
|
||||
// SYNTHETIC: BETA10 0x1016fa90
|
||||
// TglImpl::MeshImpl::`scalar deleting destructor'
|
||||
|
||||
// SYNTHETIC: BETA10 0x10169960
|
||||
// ViewportAppData::`scalar deleting destructor'
|
||||
|
||||
// GLOBAL: LEGO1 0x100dd1e0
|
||||
// IID_IDirect3DRMMeshBuilder
|
||||
|
||||
|
||||
@ -71,29 +71,69 @@ Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& data)
|
||||
return device;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d1d0
|
||||
inline Result RendererCreateView(
|
||||
IDirect3DRM2* pRenderer,
|
||||
IDirect3DRMDevice2* pDevice,
|
||||
IDirect3DRMFrame2* pCamera,
|
||||
IDirect3DRMViewport*& rpView,
|
||||
const IDirect3DRMDevice2* pDevice,
|
||||
const IDirect3DRMFrame2* pCamera,
|
||||
unsigned long x,
|
||||
unsigned long y,
|
||||
unsigned long width,
|
||||
unsigned long height
|
||||
unsigned long height,
|
||||
IDirect3DRMViewport*& rpView
|
||||
)
|
||||
{
|
||||
Result result = ResultVal(pRenderer->CreateViewport(pDevice, pCamera, x, y, width, height, &rpView));
|
||||
Result result = ResultVal(pRenderer->CreateViewport(
|
||||
const_cast<IDirect3DRMDevice2*>(pDevice),
|
||||
const_cast<IDirect3DRMFrame2*>(pCamera),
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
&rpView
|
||||
));
|
||||
|
||||
if (Succeeded(result)) {
|
||||
result = ViewImpl::ViewportCreateAppData(pRenderer, rpView, pCamera);
|
||||
result = ViewImpl::ViewportCreateAppData(pRenderer, rpView, const_cast<IDirect3DRMFrame2*>(pCamera));
|
||||
if (!Succeeded(result)) {
|
||||
rpView->Release();
|
||||
rpView = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d0b0
|
||||
inline Result RendererImpl::CreateView(
|
||||
const DeviceImpl& rDevice,
|
||||
const CameraImpl& rCamera,
|
||||
unsigned long x,
|
||||
unsigned long y,
|
||||
unsigned long width,
|
||||
unsigned long height,
|
||||
ViewImpl& rView
|
||||
)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(rDevice.ImplementationData());
|
||||
assert(rCamera.ImplementationData());
|
||||
assert(!rView.ImplementationData());
|
||||
|
||||
return RendererCreateView(
|
||||
m_data,
|
||||
rDevice.ImplementationData(),
|
||||
rCamera.ImplementationData(),
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
rView.ImplementationData()
|
||||
);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1a00
|
||||
// FUNCTION: BETA10 0x10169fb0
|
||||
View* RendererImpl::CreateView(
|
||||
const Device* pDevice,
|
||||
const Camera* pCamera,
|
||||
@ -103,21 +143,24 @@ View* RendererImpl::CreateView(
|
||||
unsigned long height
|
||||
)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(pDevice);
|
||||
assert(pCamera);
|
||||
|
||||
ViewImpl* view = new ViewImpl();
|
||||
Result result = RendererCreateView(
|
||||
m_data,
|
||||
static_cast<const DeviceImpl*>(pDevice)->m_data,
|
||||
static_cast<const CameraImpl*>(pCamera)->m_data,
|
||||
view->m_data,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
);
|
||||
if (!result) {
|
||||
if (!CreateView(
|
||||
*static_cast<const DeviceImpl*>(pDevice),
|
||||
*static_cast<const CameraImpl*>(pCamera),
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
*view
|
||||
)) {
|
||||
delete view;
|
||||
view = NULL;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@ -19,9 +19,12 @@ struct ViewportAppData {
|
||||
DECOMP_SIZE_ASSERT(ViewportAppData, 0x18);
|
||||
|
||||
// FUNCTION: LEGO1 0x100a10b0
|
||||
// FUNCTION: BETA10 0x10168920
|
||||
ViewportAppData::ViewportAppData(IDirect3DRM2* pRenderer)
|
||||
{
|
||||
pRenderer->CreateFrame(NULL, &m_pLightFrame);
|
||||
Result result = ResultVal(pRenderer->CreateFrame(NULL, &m_pLightFrame));
|
||||
assert(Succeeded(result));
|
||||
|
||||
m_pCamera = NULL;
|
||||
m_pLastRenderedFrame = NULL;
|
||||
m_backgroundColorRed = 0.0f;
|
||||
@ -30,36 +33,64 @@ ViewportAppData::ViewportAppData(IDirect3DRM2* pRenderer)
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a10e0
|
||||
// FUNCTION: BETA10 0x101689bd
|
||||
ViewportAppData::~ViewportAppData()
|
||||
{
|
||||
int refCount;
|
||||
IDirect3DRMFrameArray* pChildFrames;
|
||||
IDirect3DRMFrame* pChildFrame = NULL;
|
||||
m_pLightFrame->GetChildren(&pChildFrames);
|
||||
Result result = ResultVal(m_pLightFrame->GetChildren(&pChildFrames));
|
||||
assert(Succeeded(result));
|
||||
|
||||
for (int i = 0; i < (int) pChildFrames->GetSize(); i++) {
|
||||
pChildFrames->GetElement(i, &pChildFrame);
|
||||
m_pLightFrame->DeleteChild(pChildFrame);
|
||||
pChildFrame->Release(); // GetElement() does AddRef()
|
||||
result = ResultVal(pChildFrames->GetElement(i, &pChildFrame));
|
||||
assert(Succeeded(result));
|
||||
|
||||
result = ResultVal(m_pLightFrame->DeleteChild(pChildFrame));
|
||||
assert(Succeeded(result));
|
||||
|
||||
refCount = pChildFrame->Release(); // GetElement() does AddRef()
|
||||
assert(refCount >= 1);
|
||||
}
|
||||
pChildFrames->Release();
|
||||
m_pLightFrame->Release();
|
||||
|
||||
refCount = pChildFrames->Release();
|
||||
assert(refCount == 0);
|
||||
|
||||
refCount = m_pLightFrame->Release();
|
||||
assert(refCount == 0);
|
||||
}
|
||||
|
||||
// Forward declare to satisfy order check
|
||||
void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg);
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1160
|
||||
Result ViewImpl::ViewportCreateAppData(IDirect3DRM2* pDevice, IDirect3DRMViewport* pView, IDirect3DRMFrame2* pCamera)
|
||||
// FUNCTION: BETA10 0x10168ba5
|
||||
Result ViewImpl::ViewportCreateAppData(
|
||||
IDirect3DRM2* pDevice,
|
||||
IDirect3DRMViewport* pViewport,
|
||||
IDirect3DRMFrame2* pCamera
|
||||
)
|
||||
{
|
||||
ViewportAppData* data = new ViewportAppData(pDevice);
|
||||
data->m_pCamera = pCamera;
|
||||
Result result = ResultVal(pView->SetAppData(reinterpret_cast<LPD3DRM_APPDATA>(data)));
|
||||
ViewportAppData* pViewportAppData = new ViewportAppData(pDevice);
|
||||
assert(pViewportAppData);
|
||||
|
||||
pViewportAppData->m_pCamera = pCamera;
|
||||
assert(!pViewport->GetAppData());
|
||||
|
||||
Result result = ResultVal(pViewport->SetAppData(reinterpret_cast<LPD3DRM_APPDATA>(pViewportAppData)));
|
||||
assert(Succeeded(result));
|
||||
assert(reinterpret_cast<ViewportAppData*>(pViewport->GetAppData()) == pViewportAppData);
|
||||
|
||||
if (Succeeded(result)) {
|
||||
result = ResultVal(pView->AddDestroyCallback(ViewportDestroyCallback, data));
|
||||
result = ResultVal(pViewport->AddDestroyCallback(ViewportDestroyCallback, pViewportAppData));
|
||||
assert(Succeeded(result));
|
||||
}
|
||||
|
||||
if (!Succeeded(result)) {
|
||||
delete data;
|
||||
pView->SetAppData(0);
|
||||
delete pViewportAppData;
|
||||
pViewport->SetAppData(0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -90,16 +121,21 @@ inline Result ViewRestoreFrameAfterRender(
|
||||
// FIXME: from LEGO1/tgl/d3drm/view.cpp
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1240
|
||||
// FUNCTION: BETA10 0x10168dc9
|
||||
void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg)
|
||||
{
|
||||
ViewportAppData* pViewportAppData = reinterpret_cast<ViewportAppData*>(pArg);
|
||||
assert(static_cast<ViewImpl::ViewDataType>(pObject));
|
||||
assert(pViewportAppData);
|
||||
|
||||
ViewRestoreFrameAfterRender(
|
||||
Result result = ViewRestoreFrameAfterRender(
|
||||
pViewportAppData->m_pLastRenderedFrame,
|
||||
pViewportAppData->m_pCamera,
|
||||
pViewportAppData->m_pLightFrame
|
||||
);
|
||||
|
||||
assert(Succeeded(result));
|
||||
|
||||
delete pViewportAppData;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user