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