port: GrpDetector verbatim 40250 over a host IDirect3D8 (Direct3DCreate8); GrpDevice::Create verbatim

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-30 15:02:12 +09:00
co-authored by Claude Opus 5.5
parent 65c43a84cd
commit fd4d9a39df
12 changed files with 1127 additions and 173 deletions
+4 -45
View File
@@ -33,58 +33,17 @@ CPythonGraphic::~CPythonGraphic()
Tracef("Python Graphic Clear\n");
}
namespace
{
class CDummyDirect3D8 : public IDirect3D8
{
public:
HRESULT GetAdapterIdentifier(UINT, DWORD, D3DADAPTER_IDENTIFIER8* pIdentifier) override
{
if (!pIdentifier) return E_FAIL;
memset(pIdentifier, 0, sizeof(D3DADAPTER_IDENTIFIER8));
strncpy(pIdentifier->Driver, "dummy", sizeof(pIdentifier->Driver));
strncpy(pIdentifier->Description, "Dummy Direct3D8", sizeof(pIdentifier->Description));
return S_OK;
}
HRESULT GetAdapterDisplayMode(UINT, D3DDISPLAYMODE* pMode) override
{
if (!pMode) return E_FAIL;
pMode->Width = 1024;
pMode->Height = 768;
pMode->RefreshRate = 60;
pMode->Format = D3DFMT_X8R8G8B8;
return S_OK;
}
UINT GetAdapterModeCount(UINT) override
{
return 3;
}
HRESULT EnumAdapterModes(UINT, UINT Mode, D3DDISPLAYMODE* pMode) override
{
if (!pMode) return E_FAIL;
static const D3DDISPLAYMODE s_modes[] = {
{ 800, 600, 60, D3DFMT_X8R8G8B8 },
{ 1024, 768, 60, D3DFMT_X8R8G8B8 },
{ 1280, 1024, 60, D3DFMT_X8R8G8B8 },
};
if (Mode >= 3) return E_FAIL;
*pMode = s_modes[Mode];
return S_OK;
}
};
}
// 40250 PythonGraphic.cpp:8
void CPythonGraphic::Destroy()
{
}
// 40250 PythonGraphic.cpp:12. PORT: no IDirect3D8 exists; a stand-in reports the adapter modes CPythonSystem
// lists as resolutions.
// 40250 PythonGraphic.cpp:12 returns ms_lpd3d. PORT: PythonBoot::Start runs CPythonSystem::GetDisplaySettings
// before app.Create makes the device (40250 runs it after, in CPythonApplication::Create), so this hands out
// the host adapter Direct3DCreate8 returns, the same object CGraphicDevice::Create keeps in ms_lpd3d.
LPDIRECT3D8 CPythonGraphic::GetD3D()
{
static CDummyDirect3D8 s_dummyD3D;
return &s_dummyD3D;
return Direct3DCreate8(D3D_SDK_VERSION);
}
void CPythonGraphic::SetViewport(float x, float y, float width, float height)