miniwin: Compartmentalize EnumDevices (#222)

This compartmentalizes everything to a corresponding function
for each renderer backend.
This commit is contained in:
AllMeatball 2025-06-03 00:18:20 +00:00 committed by GitHub
parent 2affbdfcc7
commit 1ab11ed091
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 8 deletions

View File

@ -223,14 +223,8 @@ void EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx, Direct3DRMRenderer* devi
HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
{
Direct3DRMRenderer* device = Direct3DRMSDL3GPURenderer::Create(640, 480);
if (device) {
EnumDevice(cb, ctx, device, SDL3_GPU_GUID);
delete device;
}
device = new Direct3DRMSoftwareRenderer(640, 480);
EnumDevice(cb, ctx, device, SOFTWARE_GUID);
delete device;
Direct3DRMSDL3GPU_EnumDevice(cb, ctx);
Direct3DRMSoftware_EnumDevice(cb, ctx);
return S_OK;
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "d3drmrenderer.h"
#include "ddraw_impl.h"
#include <SDL3/SDL.h>
@ -60,3 +61,12 @@ class Direct3DRMSDL3GPURenderer : public Direct3DRMRenderer {
SDL_GPUBuffer* m_vertexBuffer = nullptr;
SDL_Surface* m_renderedImage = nullptr;
};
inline static void Direct3DRMSDL3GPU_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
{
Direct3DRMRenderer* device = Direct3DRMSDL3GPURenderer::Create(640, 480);
if (device) {
EnumDevice(cb, ctx, device, SDL3_GPU_GUID);
delete device;
}
}

View File

@ -2,6 +2,7 @@
#include "d3drmrenderer.h"
#include "d3drmtexture_impl.h"
#include "ddraw_impl.h"
#include <SDL3/SDL.h>
#include <cstddef>
@ -56,3 +57,11 @@ class Direct3DRMSoftwareRenderer : public Direct3DRMRenderer {
float proj[4][4] = {0};
std::vector<float> m_zBuffer;
};
inline static void Direct3DRMSoftware_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
{
Direct3DRMRenderer* device = nullptr;
device = new Direct3DRMSoftwareRenderer(640, 480);
EnumDevice(cb, ctx, device, SOFTWARE_GUID);
delete device;
}

View File

@ -1,5 +1,6 @@
#pragma once
#include "d3drmrenderer.h"
#include "miniwin/d3d.h"
#include "miniwin/ddraw.h"
@ -43,3 +44,5 @@ struct DirectDrawImpl : public IDirectDraw2, public IDirect3D2 {
HRESULT DirectDrawEnumerate(LPDDENUMCALLBACKA cb, void* context);
HRESULT DirectDrawCreate(LPGUID lpGuid, LPDIRECTDRAW* lplpDD, IUnknown* pUnkOuter);
void EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx, Direct3DRMRenderer* device, GUID deviceGuid);