mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-26 22:21:50 -04:00
Implement/match MxDirect3D::D3DSetMode (#403)
* Implement/match MxDirect3D::D3DSetMode * Match
This commit is contained in:
parent
a899b06f5a
commit
54ed98b9d6
@ -19,8 +19,8 @@ public:
|
|||||||
IDirectDrawPalette* m_ddPalette; // 0x14
|
IDirectDrawPalette* m_ddPalette; // 0x14
|
||||||
BOOL m_isFullScreen; // 0x18
|
BOOL m_isFullScreen; // 0x18
|
||||||
MxU32 m_flags; // 0x1c
|
MxU32 m_flags; // 0x1c
|
||||||
IDirect3D* m_direct3d; // 0x20
|
IDirect3D2* m_direct3d; // 0x20
|
||||||
IDirect3DDevice* m_d3dDevice; // 0x24
|
IDirect3DDevice2* m_d3dDevice; // 0x24
|
||||||
};
|
};
|
||||||
|
|
||||||
Lego3DManager();
|
Lego3DManager();
|
||||||
|
@ -111,14 +111,89 @@ BOOL MxDirect3D::CreateIDirect3D()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x1009b310
|
// FUNCTION: LEGO1 0x1009b310
|
||||||
BOOL MxDirect3D::D3DSetMode()
|
BOOL MxDirect3D::D3DSetMode()
|
||||||
{
|
{
|
||||||
// TODO
|
if (m_assignedDevice->m_flags & MxAssignedDevice::Flag_HardwareMode) {
|
||||||
// if (m_assignedDevice)
|
if (m_bOnlySoftRender) {
|
||||||
Error("This device cannot support the current display mode", 0);
|
Error("Failed to place vital surfaces in video memory for hardware driver", DDERR_GENERIC);
|
||||||
OutputDebugString("MxDirect3D::D3DSetMode() front lock failed\n");
|
return FALSE;
|
||||||
OutputDebugString("MxDirect3D::D3DSetMode() back lock failed\n");
|
}
|
||||||
|
|
||||||
|
if (m_assignedDevice->m_desc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE)
|
||||||
|
m_unk0x88c = FALSE;
|
||||||
|
else
|
||||||
|
m_unk0x88c = TRUE;
|
||||||
|
|
||||||
|
DWORD bitDepth = GetZBufferBitDepth(m_assignedDevice);
|
||||||
|
if (!CreateZBuffer(DDSCAPS_VIDEOMEMORY, bitDepth))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (m_assignedDevice->m_desc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE)
|
||||||
|
m_unk0x88c = FALSE;
|
||||||
|
else
|
||||||
|
m_unk0x88c = TRUE;
|
||||||
|
|
||||||
|
DWORD bitDepth = GetZBufferBitDepth(m_assignedDevice);
|
||||||
|
if (!CreateZBuffer(DDSCAPS_SYSTEMMEMORY, bitDepth))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT result = m_pDirect3d->CreateDevice(m_assignedDevice->m_guid, m_pBackBuffer, &m_pDirect3dDevice);
|
||||||
|
|
||||||
|
if (result != DD_OK) {
|
||||||
|
Error("Create D3D device failed", result);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MxDirectDraw::Mode mode = m_currentMode;
|
||||||
|
|
||||||
|
if (m_bFullScreen && !IsSupportedMode(mode.m_width, mode.m_height, mode.m_bitsPerPixel)) {
|
||||||
|
Error("This device cannot support the current display mode", DDERR_GENERIC);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPDIRECTDRAWSURFACE frontBuffer = m_pFrontBuffer;
|
||||||
|
LPDIRECTDRAWSURFACE backBuffer = m_pBackBuffer;
|
||||||
|
|
||||||
|
DDSURFACEDESC desc;
|
||||||
|
memset(&desc, 0, sizeof(desc));
|
||||||
|
desc.dwSize = sizeof(desc);
|
||||||
|
|
||||||
|
if (backBuffer->Lock(NULL, &desc, DDLOCK_WAIT, NULL) == DD_OK) {
|
||||||
|
MxU8* surface = (MxU8*) desc.lpSurface;
|
||||||
|
|
||||||
|
for (MxS32 i = mode.m_height; i > 0; i--) {
|
||||||
|
memset(surface, 0, mode.m_width * desc.ddpfPixelFormat.dwRGBBitCount / 8);
|
||||||
|
surface += desc.lPitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
backBuffer->Unlock(desc.lpSurface);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OutputDebugString("MxDirect3D::D3DSetMode() back lock failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_bFullScreen) {
|
||||||
|
memset(&desc, 0, sizeof(desc));
|
||||||
|
desc.dwSize = sizeof(desc);
|
||||||
|
|
||||||
|
if (frontBuffer->Lock(NULL, &desc, DDLOCK_WAIT, NULL) == DD_OK) {
|
||||||
|
MxU8* surface = (MxU8*) desc.lpSurface;
|
||||||
|
|
||||||
|
for (MxS32 i = mode.m_height; i > 0; i--) {
|
||||||
|
memset(surface, 0, mode.m_width * desc.ddpfPixelFormat.dwRGBBitCount / 8);
|
||||||
|
surface += desc.lPitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
frontBuffer->Unlock(desc.lpSurface);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OutputDebugString("MxDirect3D::D3DSetMode() front lock failed\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,15 +61,15 @@ public:
|
|||||||
BOOL SetDevice(MxDeviceEnumerate& p_deviceEnumerate, MxDriver* p_driver, MxDevice* p_device);
|
BOOL SetDevice(MxDeviceEnumerate& p_deviceEnumerate, MxDriver* p_driver, MxDevice* p_device);
|
||||||
|
|
||||||
inline MxAssignedDevice* GetAssignedDevice() { return this->m_assignedDevice; };
|
inline MxAssignedDevice* GetAssignedDevice() { return this->m_assignedDevice; };
|
||||||
inline IDirect3D* GetDirect3D() { return this->m_pDirect3d; }
|
inline IDirect3D2* GetDirect3D() { return this->m_pDirect3d; }
|
||||||
inline IDirect3DDevice* GetDirect3DDevice() { return this->m_pDirect3dDevice; }
|
inline IDirect3DDevice2* GetDirect3DDevice() { return this->m_pDirect3dDevice; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MxAssignedDevice* m_assignedDevice; // 0x880
|
MxAssignedDevice* m_assignedDevice; // 0x880
|
||||||
IDirect3D* m_pDirect3d; // 0x884
|
IDirect3D2* m_pDirect3d; // 0x884
|
||||||
IDirect3DDevice* m_pDirect3dDevice; // 0x888
|
IDirect3DDevice2* m_pDirect3dDevice; // 0x888
|
||||||
undefined4 m_unk0x88c; // 0x88c
|
BOOL m_unk0x88c; // 0x88c
|
||||||
undefined4 m_unk0x890; // 0x890
|
undefined4 m_unk0x890; // 0x890
|
||||||
};
|
};
|
||||||
|
|
||||||
// SIZE 0x1a4
|
// SIZE 0x1a4
|
||||||
|
@ -68,7 +68,7 @@ protected:
|
|||||||
void* m_pFatalErrorHandlerArg; // 0x868
|
void* m_pFatalErrorHandlerArg; // 0x868
|
||||||
int m_pauseCount; // 0x86c
|
int m_pauseCount; // 0x86c
|
||||||
DeviceModesInfo* m_pCurrentDeviceModesList; // 0x870
|
DeviceModesInfo* m_pCurrentDeviceModesList; // 0x870
|
||||||
Mode m_currentMode; // 0x87c
|
Mode m_currentMode; // 0x874
|
||||||
|
|
||||||
public:
|
public:
|
||||||
__declspec(dllexport) int FlipToGDISurface();
|
__declspec(dllexport) int FlipToGDISurface();
|
||||||
|
@ -120,7 +120,7 @@ void MxVideoManager::SortPresenterList()
|
|||||||
MxResult MxVideoManager::VTable0x28(
|
MxResult MxVideoManager::VTable0x28(
|
||||||
MxVideoParam& p_videoParam,
|
MxVideoParam& p_videoParam,
|
||||||
LPDIRECTDRAW p_pDirectDraw,
|
LPDIRECTDRAW p_pDirectDraw,
|
||||||
LPDIRECT3D p_pDirect3D,
|
LPDIRECT3D2 p_pDirect3D,
|
||||||
LPDIRECTDRAWSURFACE p_ddSurface1,
|
LPDIRECTDRAWSURFACE p_ddSurface1,
|
||||||
LPDIRECTDRAWSURFACE p_ddSurface2,
|
LPDIRECTDRAWSURFACE p_ddSurface2,
|
||||||
LPDIRECTDRAWCLIPPER p_ddClipper,
|
LPDIRECTDRAWCLIPPER p_ddClipper,
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
virtual MxResult VTable0x28(
|
virtual MxResult VTable0x28(
|
||||||
MxVideoParam& p_videoParam,
|
MxVideoParam& p_videoParam,
|
||||||
LPDIRECTDRAW p_pDirectDraw,
|
LPDIRECTDRAW p_pDirectDraw,
|
||||||
LPDIRECT3D p_pDirect3D,
|
LPDIRECT3D2 p_pDirect3D,
|
||||||
LPDIRECTDRAWSURFACE p_ddSurface1,
|
LPDIRECTDRAWSURFACE p_ddSurface1,
|
||||||
LPDIRECTDRAWSURFACE p_ddSurface2,
|
LPDIRECTDRAWSURFACE p_ddSurface2,
|
||||||
LPDIRECTDRAWCLIPPER p_ddClipper,
|
LPDIRECTDRAWCLIPPER p_ddClipper,
|
||||||
@ -47,7 +47,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
MxVideoParam m_videoParam; // 0x2c
|
MxVideoParam m_videoParam; // 0x2c
|
||||||
LPDIRECTDRAW m_pDirectDraw; // 0x50
|
LPDIRECTDRAW m_pDirectDraw; // 0x50
|
||||||
LPDIRECT3D m_pDirect3D; // 0x54
|
LPDIRECT3D2 m_pDirect3D; // 0x54
|
||||||
MxDisplaySurface* m_displaySurface; // 0x58
|
MxDisplaySurface* m_displaySurface; // 0x58
|
||||||
MxRegion* m_region; // 0x5c
|
MxRegion* m_region; // 0x5c
|
||||||
MxBool m_unk0x60; // 0x60
|
MxBool m_unk0x60; // 0x60
|
||||||
|
@ -19,8 +19,8 @@ public:
|
|||||||
IDirectDrawPalette* m_ddPalette; // 0x14
|
IDirectDrawPalette* m_ddPalette; // 0x14
|
||||||
BOOL m_isFullScreen; // 0x18
|
BOOL m_isFullScreen; // 0x18
|
||||||
MxU32 m_flags; // 0x1c
|
MxU32 m_flags; // 0x1c
|
||||||
IDirect3D* m_direct3d; // 0x20
|
IDirect3D2* m_direct3d; // 0x20
|
||||||
IDirect3DDevice* m_d3dDevice; // 0x24
|
IDirect3DDevice2* m_d3dDevice; // 0x24
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user