mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-24 04:26:55 -04:00
Add all TglImpl::ImplementationData
methods (#1436)
* ImplementationData methods and typedefs * RendererImpl::CreateView * RendererImpl::CreateMeshBuilder * DeepClone * CreateCamera and CreateTexture * CreateDevice * Disable static var annotation
This commit is contained in:
parent
451fd63eee
commit
2fef2858c9
@ -95,15 +95,44 @@ public:
|
||||
return m_data->CreateTextureFromSurface(pSurface, pTexture2);
|
||||
}
|
||||
|
||||
IDirect3DRM2* ImplementationData() const { return m_data; }
|
||||
typedef IDirect3DRM2* RendererDataType;
|
||||
|
||||
const RendererDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x10174c10
|
||||
RendererDataType& ImplementationData() { return m_data; }
|
||||
|
||||
public:
|
||||
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
|
||||
);
|
||||
inline Result CreateMeshBuilder(MeshBuilderImpl& rMesh);
|
||||
inline Result CreateCamera(CameraImpl& rCamera);
|
||||
inline Result CreateTexture(TextureImpl& rTexture);
|
||||
inline Result CreateTexture(
|
||||
TextureImpl& rTexture,
|
||||
int width,
|
||||
int height,
|
||||
int bitsPerTexel,
|
||||
const void* pTexels,
|
||||
int texelsArePersistent,
|
||||
int paletteEntryCount,
|
||||
const PaletteEntry* pEntries
|
||||
);
|
||||
inline Result CreateDevice(const DeviceDirect3DCreateData& rCreateData, DeviceImpl& rDevice);
|
||||
inline Result CreateDevice(const DeviceDirectDrawCreateData& rCreateData, DeviceImpl& rDevice);
|
||||
|
||||
private:
|
||||
IDirect3DRM2* m_data;
|
||||
RendererDataType m_data;
|
||||
};
|
||||
|
||||
extern IDirect3DRM2* g_pD3DRM;
|
||||
@ -154,7 +183,14 @@ public:
|
||||
void HandleActivate(WORD) override;
|
||||
void HandlePaint(HDC) override;
|
||||
|
||||
IDirect3DRMDevice2* ImplementationData() const { return m_data; }
|
||||
typedef IDirect3DRMDevice2* DeviceDataType;
|
||||
|
||||
// FUNCTION: BETA10 0x101708e0
|
||||
const DeviceDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x100d9540
|
||||
DeviceDataType& ImplementationData() { return m_data; }
|
||||
|
||||
void SetImplementationData(IDirect3DRMDevice2* device) { m_data = device; }
|
||||
|
||||
inline void Destroy();
|
||||
@ -162,7 +198,7 @@ public:
|
||||
friend class RendererImpl;
|
||||
|
||||
private:
|
||||
IDirect3DRMDevice2* m_data;
|
||||
DeviceDataType m_data;
|
||||
};
|
||||
|
||||
// FUNCTION: BETA10 0x101708c0
|
||||
@ -220,7 +256,13 @@ public:
|
||||
int& rPickedGroupCount
|
||||
) override;
|
||||
|
||||
IDirect3DRMViewport* ImplementationData() const { return m_data; }
|
||||
typedef IDirect3DRMViewport* ViewDataType;
|
||||
|
||||
const ViewDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x101711c0
|
||||
ViewDataType& ImplementationData() { return m_data; }
|
||||
|
||||
void SetImplementationData(IDirect3DRMViewport* viewport) { m_data = viewport; }
|
||||
|
||||
static Result ViewportCreateAppData(IDirect3DRM2*, IDirect3DRMViewport*, IDirect3DRMFrame2*);
|
||||
@ -242,7 +284,7 @@ public:
|
||||
friend class RendererImpl;
|
||||
|
||||
private:
|
||||
IDirect3DRMViewport* m_data;
|
||||
ViewDataType m_data;
|
||||
};
|
||||
|
||||
// FUNCTION: BETA10 0x101711a0
|
||||
@ -275,14 +317,20 @@ public:
|
||||
// vtable+0x08
|
||||
Result SetTransformation(FloatMatrix4&) override;
|
||||
|
||||
IDirect3DRMFrame2* ImplementationData() const { return m_data; }
|
||||
typedef IDirect3DRMFrame2* CameraDataType;
|
||||
|
||||
// FUNCTION: BETA10 0x10170960
|
||||
const CameraDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x10170980
|
||||
CameraDataType& ImplementationData() { return m_data; }
|
||||
|
||||
inline void Destroy();
|
||||
|
||||
friend class RendererImpl;
|
||||
|
||||
private:
|
||||
IDirect3DRMFrame2* m_data;
|
||||
CameraDataType m_data;
|
||||
};
|
||||
|
||||
// FUNCTION: BETA10 0x10170940
|
||||
@ -318,7 +366,10 @@ public:
|
||||
|
||||
typedef IDirect3DRMFrame2* LightDataType;
|
||||
|
||||
// FUNCTION: BETA10 0x10171b90
|
||||
const LightDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x10171240
|
||||
LightDataType& ImplementationData() { return m_data; }
|
||||
|
||||
inline void Destroy();
|
||||
@ -377,9 +428,12 @@ public:
|
||||
typedef MeshData* MeshDataType;
|
||||
|
||||
const MeshDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x10171b70
|
||||
MeshDataType& ImplementationData() { return m_data; }
|
||||
|
||||
inline void Destroy();
|
||||
inline Mesh* DeepClone(const MeshBuilderImpl& rMesh);
|
||||
|
||||
friend class RendererImpl;
|
||||
|
||||
@ -433,14 +487,20 @@ public:
|
||||
// vtable+0x30
|
||||
Result Bounds(D3DVECTOR* p_min, D3DVECTOR* p_max) override;
|
||||
|
||||
IDirect3DRMFrame2* ImplementationData() const { return m_data; }
|
||||
typedef IDirect3DRMFrame2* GroupDataType;
|
||||
|
||||
// FUNCTION: BETA10 0x1016fc20
|
||||
const GroupDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x1016fce0
|
||||
GroupDataType& ImplementationData() { return m_data; }
|
||||
|
||||
inline void Destroy();
|
||||
|
||||
friend class RendererImpl;
|
||||
|
||||
private:
|
||||
IDirect3DRMFrame2* m_data;
|
||||
GroupDataType m_data;
|
||||
};
|
||||
|
||||
// FUNCTION: BETA10 0x1016c2b0
|
||||
@ -486,7 +546,13 @@ public:
|
||||
// vtable+0x10
|
||||
MeshBuilder* Clone() override;
|
||||
|
||||
IDirect3DRMMesh* ImplementationData() const { return m_data; }
|
||||
typedef IDirect3DRMMesh* MeshBuilderDataType;
|
||||
|
||||
// FUNCTION: BETA10 0x10170420
|
||||
const MeshBuilderDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x10170440
|
||||
MeshBuilderDataType& ImplementationData() { return m_data; }
|
||||
|
||||
inline void Destroy();
|
||||
|
||||
@ -505,7 +571,7 @@ private:
|
||||
ShadingModel shadingModel
|
||||
);
|
||||
|
||||
IDirect3DRMMesh* m_data;
|
||||
MeshBuilderDataType m_data;
|
||||
};
|
||||
|
||||
// FUNCTION: BETA10 0x10170390
|
||||
@ -574,7 +640,14 @@ public:
|
||||
) override;
|
||||
Result SetPalette(int entryCount, PaletteEntry* entries) override;
|
||||
|
||||
IDirect3DRMTexture* ImplementationData() const { return m_data; }
|
||||
typedef IDirect3DRMTexture* TextureDataType;
|
||||
|
||||
// FUNCTION: BETA10 0x1016fd60
|
||||
const TextureDataType& ImplementationData() const { return m_data; }
|
||||
|
||||
// FUNCTION: BETA10 0x1016fe20
|
||||
TextureDataType& ImplementationData() { return m_data; }
|
||||
|
||||
void SetImplementation(IDirect3DRMTexture* pData) { m_data = pData; }
|
||||
|
||||
inline void Destroy();
|
||||
@ -584,7 +657,7 @@ public:
|
||||
static Result SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage);
|
||||
|
||||
private:
|
||||
IDirect3DRMTexture* m_data;
|
||||
TextureDataType m_data;
|
||||
};
|
||||
|
||||
// FUNCTION: BETA10 0x1016fd40
|
||||
@ -739,6 +812,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
|
||||
|
||||
|
@ -66,49 +66,97 @@ Result MeshImpl::SetShadingModel(ShadingModel model)
|
||||
return MeshSetShadingModel(m_data, model);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a4030
|
||||
Mesh* MeshImpl::DeepClone(MeshBuilder* pMeshBuilder)
|
||||
// FUNCTION: BETA10 0x101714e0
|
||||
inline Result MeshDeepClone(MeshImpl::MeshData* pSource, MeshImpl::MeshData*& rpTarget, IDirect3DRMMesh* pMesh)
|
||||
{
|
||||
// Create group
|
||||
MeshImpl* newMesh = new MeshImpl();
|
||||
MeshData* data = new MeshData();
|
||||
newMesh->m_data = data;
|
||||
rpTarget = new MeshImpl::MeshData();
|
||||
rpTarget->groupMesh = pMesh;
|
||||
|
||||
// Query information from old group
|
||||
DWORD dataSize;
|
||||
unsigned int vcount, fcount, vperface;
|
||||
m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL);
|
||||
|
||||
Result result =
|
||||
ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL));
|
||||
assert(Succeeded(result));
|
||||
|
||||
unsigned int* faceBuffer = new unsigned int[dataSize];
|
||||
m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer);
|
||||
result =
|
||||
ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer)
|
||||
);
|
||||
assert(Succeeded(result));
|
||||
|
||||
// We expect vertex to be sized 0x24, checked at start of file.
|
||||
D3DRMVERTEX* vertexBuffer = new D3DRMVERTEX[vcount];
|
||||
m_data->groupMesh->GetVertices(m_data->groupIndex, 0, vcount, vertexBuffer);
|
||||
result = ResultVal(pSource->groupMesh->GetVertices(pSource->groupIndex, 0, vcount, vertexBuffer));
|
||||
assert(Succeeded(result));
|
||||
|
||||
LPDIRECT3DRMTEXTURE textureRef;
|
||||
m_data->groupMesh->GetGroupTexture(m_data->groupIndex, &textureRef);
|
||||
D3DRMMAPPING mapping = m_data->groupMesh->GetGroupMapping(m_data->groupIndex);
|
||||
D3DRMRENDERQUALITY quality = m_data->groupMesh->GetGroupQuality(m_data->groupIndex);
|
||||
D3DCOLOR color = m_data->groupMesh->GetGroupColor(m_data->groupIndex);
|
||||
result = ResultVal(pSource->groupMesh->GetGroupTexture(pSource->groupIndex, &textureRef));
|
||||
assert(Succeeded(result));
|
||||
|
||||
D3DRMMAPPING mapping = pSource->groupMesh->GetGroupMapping(pSource->groupIndex);
|
||||
D3DRMRENDERQUALITY quality = pSource->groupMesh->GetGroupQuality(pSource->groupIndex);
|
||||
D3DCOLOR color = pSource->groupMesh->GetGroupColor(pSource->groupIndex);
|
||||
|
||||
// Push information to new group
|
||||
MeshBuilderImpl* target = static_cast<MeshBuilderImpl*>(pMeshBuilder);
|
||||
D3DRMGROUPINDEX index;
|
||||
target->ImplementationData()->AddGroup(vcount, fcount, vperface, faceBuffer, &index);
|
||||
newMesh->m_data->groupIndex = index;
|
||||
target->ImplementationData()->SetVertices(index, 0, vcount, vertexBuffer);
|
||||
target->ImplementationData()->SetGroupTexture(index, textureRef);
|
||||
target->ImplementationData()->SetGroupMapping(index, mapping);
|
||||
target->ImplementationData()->SetGroupQuality(index, quality);
|
||||
Result result = ResultVal(target->ImplementationData()->SetGroupColor(index, color));
|
||||
result = ResultVal(pMesh->AddGroup(vcount, fcount, 3, faceBuffer, &index));
|
||||
assert(Succeeded(result));
|
||||
|
||||
rpTarget->groupIndex = index;
|
||||
result = ResultVal(pMesh->SetVertices(index, 0, vcount, vertexBuffer));
|
||||
assert(Succeeded(result));
|
||||
|
||||
result = ResultVal(pMesh->SetGroupTexture(index, textureRef));
|
||||
assert(Succeeded(result));
|
||||
|
||||
result = ResultVal(pMesh->SetGroupMapping(index, mapping));
|
||||
assert(Succeeded(result));
|
||||
|
||||
result = ResultVal(pMesh->SetGroupQuality(index, quality));
|
||||
assert(Succeeded(result));
|
||||
|
||||
result = ResultVal(pMesh->SetGroupColor(index, color));
|
||||
assert(Succeeded(result));
|
||||
|
||||
// Cleanup
|
||||
delete[] faceBuffer;
|
||||
delete[] vertexBuffer;
|
||||
if (result == Error) {
|
||||
delete newMesh;
|
||||
newMesh = NULL;
|
||||
if (faceBuffer) {
|
||||
delete[] faceBuffer;
|
||||
}
|
||||
|
||||
return newMesh;
|
||||
if (vertexBuffer) {
|
||||
delete[] vertexBuffer;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x10171360
|
||||
inline Mesh* MeshImpl::DeepClone(const MeshBuilderImpl& rMesh)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(rMesh.ImplementationData());
|
||||
|
||||
MeshImpl* clone = new MeshImpl();
|
||||
assert(!clone->ImplementationData());
|
||||
|
||||
if (!MeshDeepClone(m_data, clone->ImplementationData(), rMesh.ImplementationData())) {
|
||||
delete clone;
|
||||
clone = NULL;
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a4030
|
||||
// FUNCTION: BETA10 0x101707a0
|
||||
Mesh* MeshImpl::DeepClone(MeshBuilder* pMesh)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(pMesh);
|
||||
|
||||
return DeepClone(*static_cast<MeshBuilderImpl*>(pMesh));
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a4240
|
||||
|
@ -36,64 +36,158 @@ Result RendererImpl::Create()
|
||||
return (m_data != NULL) ? Success : Error;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016cf00
|
||||
inline Result RendererCreateDevice(
|
||||
IDirect3DRM2* pD3DRM,
|
||||
const DeviceDirect3DCreateData& rCreateData,
|
||||
IDirect3DRMDevice2*& rpDevice
|
||||
)
|
||||
{
|
||||
Result result =
|
||||
ResultVal(pD3DRM->CreateDeviceFromD3D(rCreateData.m_pDirect3D, rCreateData.m_pDirect3DDevice, &rpDevice));
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016ce60
|
||||
inline Result RendererImpl::CreateDevice(const DeviceDirect3DCreateData& rCreateData, DeviceImpl& rDevice)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(!rDevice.ImplementationData());
|
||||
|
||||
return RendererCreateDevice(m_data, rCreateData, rDevice.ImplementationData());
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1830
|
||||
// FUNCTION: BETA10 0x10169d90
|
||||
Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& data)
|
||||
{
|
||||
assert(m_data);
|
||||
DeviceImpl* device = new DeviceImpl();
|
||||
HRESULT result = m_data->CreateDeviceFromD3D(data.m_pDirect3D, data.m_pDirect3DDevice, &device->m_data);
|
||||
if (!SUCCEEDED(result)) {
|
||||
|
||||
if (!CreateDevice(data, *device)) {
|
||||
delete device;
|
||||
device = NULL;
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016cfe0
|
||||
inline Result RendererCreateDevice(
|
||||
IDirect3DRM2* pD3DRM,
|
||||
const DeviceDirectDrawCreateData& rCreateData,
|
||||
IDirect3DRMDevice2*& rpDevice
|
||||
)
|
||||
{
|
||||
Result result = ResultVal(pD3DRM->CreateDeviceFromSurface(
|
||||
const_cast<GUID*>(rCreateData.m_driverGUID),
|
||||
rCreateData.m_pDirectDraw,
|
||||
rCreateData.m_pBackBuffer,
|
||||
&rpDevice
|
||||
));
|
||||
|
||||
if (Succeeded(result)) {
|
||||
if (rCreateData.m_pBackBuffer) {
|
||||
// LEGO1 0x10101040
|
||||
// GLOBAL: BETA10 0x102055f4
|
||||
static int g_setBufferCount = 1;
|
||||
if (g_setBufferCount) {
|
||||
Result result2 = ResultVal(rpDevice->SetBufferCount(2));
|
||||
assert(Succeeded(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016cf40
|
||||
inline Result RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& rCreateData, DeviceImpl& rDevice)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(!rDevice.ImplementationData());
|
||||
|
||||
return RendererCreateDevice(m_data, rCreateData, rDevice.ImplementationData());
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1900
|
||||
// FUNCTION: BETA10 0x10169ea0
|
||||
Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& data)
|
||||
{
|
||||
// at LEGO1 0x10101040, needs no annotation
|
||||
static int g_SetBufferCount = 1;
|
||||
|
||||
assert(m_data);
|
||||
DeviceImpl* device = new DeviceImpl();
|
||||
HRESULT result = m_data->CreateDeviceFromSurface(
|
||||
const_cast<LPGUID>(data.m_driverGUID),
|
||||
data.m_pDirectDraw,
|
||||
data.m_pBackBuffer,
|
||||
&device->m_data
|
||||
);
|
||||
if (SUCCEEDED(result) && data.m_pBackBuffer && g_SetBufferCount) {
|
||||
device->m_data->SetBufferCount(2);
|
||||
}
|
||||
if (!SUCCEEDED(result)) {
|
||||
|
||||
if (!CreateDevice(data, *device)) {
|
||||
delete device;
|
||||
device = NULL;
|
||||
}
|
||||
|
||||
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 +197,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;
|
||||
}
|
||||
|
||||
@ -147,14 +244,33 @@ Group* RendererImpl::CreateGroup(const Group* pParent)
|
||||
return group;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d4b0
|
||||
inline Result RendererCreateCamera(IDirect3DRM2* pD3DRM, IDirect3DRMFrame2*& rpCamera)
|
||||
{
|
||||
return ResultVal(pD3DRM->CreateFrame(NULL, &rpCamera));
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d420
|
||||
inline Result RendererImpl::CreateCamera(CameraImpl& rCamera)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(!rCamera.ImplementationData());
|
||||
|
||||
return RendererCreateCamera(m_data, rCamera.ImplementationData());
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1c30
|
||||
// FUNCTION: BETA10 0x1016a980
|
||||
Camera* RendererImpl::CreateCamera()
|
||||
{
|
||||
assert(m_data);
|
||||
CameraImpl* camera = new CameraImpl();
|
||||
if (FAILED(m_data->CreateFrame(NULL, &camera->m_data))) {
|
||||
|
||||
if (!CreateCamera(*camera)) {
|
||||
delete camera;
|
||||
camera = NULL;
|
||||
}
|
||||
|
||||
return camera;
|
||||
}
|
||||
|
||||
@ -236,50 +352,106 @@ Light* RendererImpl::CreateLight(LightType type, float r, float g, float b)
|
||||
return pLightImpl;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d8e0
|
||||
inline Result RendererCreateMeshBuilder(IDirect3DRM2* pD3DRM, IDirect3DRMMesh*& rpMesh)
|
||||
{
|
||||
return ResultVal(pD3DRM->CreateMesh(&rpMesh));
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d850
|
||||
inline Result RendererImpl::CreateMeshBuilder(MeshBuilderImpl& rMesh)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(!rMesh.ImplementationData());
|
||||
|
||||
return RendererCreateMeshBuilder(m_data, rMesh.ImplementationData());
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1e90
|
||||
// FUNCTION: BETA10 0x1016abf0
|
||||
MeshBuilder* RendererImpl::CreateMeshBuilder()
|
||||
{
|
||||
assert(m_data);
|
||||
MeshBuilderImpl* meshBuilder = new MeshBuilderImpl();
|
||||
if (FAILED(m_data->CreateMesh(&meshBuilder->m_data))) {
|
||||
|
||||
if (!CreateMeshBuilder(*static_cast<MeshBuilderImpl*>(meshBuilder))) {
|
||||
delete meshBuilder;
|
||||
meshBuilder = NULL;
|
||||
}
|
||||
|
||||
return meshBuilder;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d9c0
|
||||
inline Result RendererCreateTexture(
|
||||
IDirect3DRM2* renderer,
|
||||
IDirect3DRMTexture*& texture,
|
||||
IDirect3DRM2* pRenderer,
|
||||
int width,
|
||||
int height,
|
||||
int bytesPerPixel,
|
||||
void* pBuffer,
|
||||
int useBuffer,
|
||||
int paletteSize,
|
||||
PaletteEntry* pEntries
|
||||
PaletteEntry* pEntries,
|
||||
IDirect3DRMTexture*& rpTexture
|
||||
)
|
||||
{
|
||||
TglD3DRMIMAGE* image;
|
||||
Result result;
|
||||
|
||||
image = new TglD3DRMIMAGE(width, height, bytesPerPixel, pBuffer, useBuffer, paletteSize, pEntries);
|
||||
TglD3DRMIMAGE* pImage = new TglD3DRMIMAGE(width, height, bytesPerPixel, pBuffer, useBuffer, paletteSize, pEntries);
|
||||
assert(pImage);
|
||||
|
||||
// TODO: LPDIRECT3DRMTEXTURE2?
|
||||
result = ResultVal(renderer->CreateTexture(&image->m_image, (LPDIRECT3DRMTEXTURE2*) &texture));
|
||||
result = ResultVal(pRenderer->CreateTexture(&pImage->m_image, (LPDIRECT3DRMTEXTURE2*) &rpTexture));
|
||||
assert(Succeeded(result));
|
||||
assert((rpTexture->AddRef(), rpTexture->Release()) == 1);
|
||||
|
||||
if (Succeeded(result)) {
|
||||
result = TextureImpl::SetImage(texture, image);
|
||||
result = TextureImpl::SetImage(rpTexture, pImage);
|
||||
assert(Succeeded(result));
|
||||
|
||||
if (!Succeeded(result)) {
|
||||
texture->Release();
|
||||
texture = NULL;
|
||||
delete image;
|
||||
rpTexture->Release();
|
||||
rpTexture = NULL;
|
||||
delete pImage;
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete image;
|
||||
delete pImage;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016d910
|
||||
inline Result RendererImpl::CreateTexture(
|
||||
TextureImpl& rTexture,
|
||||
int width,
|
||||
int height,
|
||||
int bitsPerTexel,
|
||||
const void* pTexels,
|
||||
int texelsArePersistent,
|
||||
int paletteEntryCount,
|
||||
const PaletteEntry* pEntries
|
||||
)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(!rTexture.ImplementationData());
|
||||
|
||||
return RendererCreateTexture(
|
||||
m_data,
|
||||
width,
|
||||
height,
|
||||
bitsPerTexel,
|
||||
const_cast<void*>(pTexels),
|
||||
texelsArePersistent,
|
||||
paletteEntryCount,
|
||||
const_cast<PaletteEntry*>(pEntries),
|
||||
rTexture.ImplementationData()
|
||||
);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a1f50
|
||||
// FUNCTION: BETA10 0x1016ad00
|
||||
Texture* RendererImpl::CreateTexture(
|
||||
int width,
|
||||
int height,
|
||||
@ -290,10 +462,11 @@ Texture* RendererImpl::CreateTexture(
|
||||
const PaletteEntry* pEntries
|
||||
)
|
||||
{
|
||||
assert(m_data);
|
||||
|
||||
TextureImpl* texture = new TextureImpl();
|
||||
if (!Succeeded(RendererCreateTexture(
|
||||
m_data,
|
||||
texture->m_data,
|
||||
if (!CreateTexture(
|
||||
*texture,
|
||||
width,
|
||||
height,
|
||||
bitsPerTexel,
|
||||
@ -301,21 +474,40 @@ Texture* RendererImpl::CreateTexture(
|
||||
texelsArePersistent,
|
||||
paletteEntryCount,
|
||||
const_cast<PaletteEntry*>(pEntries)
|
||||
))) {
|
||||
)) {
|
||||
delete texture;
|
||||
texture = NULL;
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016dcb0
|
||||
inline Result RendererCreateTexture(IDirect3DRM2* pRenderer, IDirect3DRMTexture*& rpTexture)
|
||||
{
|
||||
return RendererCreateTexture(pRenderer, 0, 0, 0, NULL, FALSE, 0, NULL, rpTexture);
|
||||
}
|
||||
|
||||
// FUNCTION: BETA10 0x1016dc20
|
||||
inline Result RendererImpl::CreateTexture(TextureImpl& rTexture)
|
||||
{
|
||||
assert(m_data);
|
||||
assert(!rTexture.ImplementationData());
|
||||
|
||||
return RendererCreateTexture(m_data, rTexture.ImplementationData());
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100a20d0
|
||||
// FUNCTION: BETA10 0x1016ae20
|
||||
Texture* RendererImpl::CreateTexture()
|
||||
{
|
||||
assert(m_data);
|
||||
|
||||
TextureImpl* texture = new TextureImpl();
|
||||
if (!Succeeded(RendererCreateTexture(m_data, texture->m_data, 0, 0, 0, NULL, FALSE, 0, NULL))) {
|
||||
if (!CreateTexture(*texture)) {
|
||||
delete texture;
|
||||
texture = NULL;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
@ -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…
x
Reference in New Issue
Block a user