mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-13 11:11:15 +00:00
move backend selection and enum to its own functions
This commit is contained in:
parent
e58b351822
commit
6754f93c43
@ -19,6 +19,7 @@ add_library(miniwin STATIC EXCLUDE_FROM_ALL
|
||||
src/d3drm/d3drmmesh.cpp
|
||||
src/d3drm/d3drmtexture.cpp
|
||||
src/d3drm/d3drmviewport.cpp
|
||||
src/d3drm/d3drmrenderer.cpp
|
||||
src/internal/meshutils.cpp
|
||||
)
|
||||
|
||||
|
||||
@ -7,24 +7,6 @@
|
||||
#include "d3drmmesh_impl.h"
|
||||
#include "d3drmobject_impl.h"
|
||||
#include "d3drmrenderer.h"
|
||||
#ifdef USE_OPENGL1
|
||||
#include "d3drmrenderer_opengl1.h"
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
#include "d3drmrenderer_opengles2.h"
|
||||
#endif
|
||||
#ifdef USE_CITRO3D
|
||||
#include "d3drmrenderer_citro3d.h"
|
||||
#endif
|
||||
#ifdef USE_DIRECTX9
|
||||
#include "d3drmrenderer_directx9.h"
|
||||
#endif
|
||||
#ifdef USE_SDL_GPU
|
||||
#include "d3drmrenderer_sdl3gpu.h"
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
#include "d3drmrenderer_software.h"
|
||||
#endif
|
||||
#include "d3drmtexture_impl.h"
|
||||
#include "d3drmviewport_impl.h"
|
||||
#include "ddraw_impl.h"
|
||||
@ -150,39 +132,8 @@ HRESULT Direct3DRMImpl::CreateDeviceFromSurface(
|
||||
DDSDesc.dwSize = sizeof(DDSURFACEDESC);
|
||||
surface->GetSurfaceDesc(&DDSDesc);
|
||||
|
||||
if (false) {
|
||||
}
|
||||
#ifdef USE_SDL_GPU
|
||||
else if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
else if (SDL_memcmp(&guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_OPENGL1
|
||||
else if (SDL_memcmp(&guid, &OpenGL1_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = OpenGL1Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_CITRO3D
|
||||
else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_DIRECTX9
|
||||
else if (SDL_memcmp(&guid, &DirectX9_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
DDRenderer = CreateDirect3DRMRenderer(DDSDesc, guid);
|
||||
if (!DDRenderer) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device GUID not recognized");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
76
miniwin/src/d3drm/d3drmrenderer.cpp
Normal file
76
miniwin/src/d3drm/d3drmrenderer.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include "d3drmrenderer.h"
|
||||
#ifdef USE_OPENGL1
|
||||
#include "d3drmrenderer_opengl1.h"
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
#include "d3drmrenderer_opengles2.h"
|
||||
#endif
|
||||
#ifdef USE_CITRO3D
|
||||
#include "d3drmrenderer_citro3d.h"
|
||||
#endif
|
||||
#ifdef USE_DIRECTX9
|
||||
#include "d3drmrenderer_directx9.h"
|
||||
#endif
|
||||
#ifdef USE_SDL_GPU
|
||||
#include "d3drmrenderer_sdl3gpu.h"
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
#include "d3drmrenderer_software.h"
|
||||
#endif
|
||||
|
||||
Direct3DRMRenderer* CreateDirect3DRMRenderer(const DDSURFACEDESC& DDSDesc, const GUID* guid)
|
||||
{
|
||||
#ifdef USE_SDL_GPU
|
||||
if (SDL_memcmp(guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) {
|
||||
return Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
if (SDL_memcmp(guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) {
|
||||
return new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
if (SDL_memcmp(guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) {
|
||||
return OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_OPENGL1
|
||||
if (SDL_memcmp(guid, &OpenGL1_GUID, sizeof(GUID)) == 0) {
|
||||
return OpenGL1Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_CITRO3D
|
||||
if (SDL_memcmp(guid, &Citro3D_GUID, sizeof(GUID)) == 0) {
|
||||
return new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_DIRECTX9
|
||||
if (SDL_memcmp(guid, &DirectX9_GUID, sizeof(GUID)) == 0) {
|
||||
return DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Direct3DRMRenderer_EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
||||
{
|
||||
#ifdef USE_SDL_GPU
|
||||
Direct3DRMSDL3GPU_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
OpenGLES2Renderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_OPENGL1
|
||||
OpenGL1Renderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_CITRO3D
|
||||
Citro3DRenderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_DIRECTX9
|
||||
DirectX9Renderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
Direct3DRMSoftware_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
}
|
||||
@ -1,21 +1,5 @@
|
||||
#ifdef USE_OPENGL1
|
||||
#include "d3drmrenderer_opengl1.h"
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
#include "d3drmrenderer_opengles2.h"
|
||||
#endif
|
||||
#ifdef USE_CITRO3D
|
||||
#include "d3drmrenderer_citro3d.h"
|
||||
#endif
|
||||
#if USE_DIRECTX9
|
||||
#include "d3drmrenderer_directx9.h"
|
||||
#endif
|
||||
#ifdef USE_SDL_GPU
|
||||
#include "d3drmrenderer_sdl3gpu.h"
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
#include "d3drmrenderer_software.h"
|
||||
#endif
|
||||
|
||||
#include "d3drmrenderer.h"
|
||||
#include "ddpalette_impl.h"
|
||||
#include "ddraw_impl.h"
|
||||
#include "ddsurface_impl.h"
|
||||
@ -236,24 +220,7 @@ void EnumDevice(
|
||||
|
||||
HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
||||
{
|
||||
#ifdef USE_SDL_GPU
|
||||
Direct3DRMSDL3GPU_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
OpenGLES2Renderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_OPENGL1
|
||||
OpenGL1Renderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_CITRO3D
|
||||
Citro3DRenderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_DIRECTX9
|
||||
DirectX9Renderer_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
Direct3DRMSoftware_EnumDevice(cb, ctx);
|
||||
#endif
|
||||
Direct3DRMRenderer_EnumDevices(cb, ctx);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -350,39 +317,8 @@ HRESULT DirectDrawImpl::CreateDevice(
|
||||
DDSDesc.dwSize = sizeof(DDSURFACEDESC);
|
||||
pBackBuffer->GetSurfaceDesc(&DDSDesc);
|
||||
|
||||
if (false) {
|
||||
}
|
||||
#ifdef USE_SDL_GPU
|
||||
else if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_OPENGLES2
|
||||
else if (SDL_memcmp(&guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_OPENGL1
|
||||
else if (SDL_memcmp(&guid, &OpenGL1_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = OpenGL1Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef __3DS__
|
||||
else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_DIRECTX9
|
||||
else if (SDL_memcmp(&guid, &DirectX9_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SOFTWARE_RENDER
|
||||
else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) {
|
||||
DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
DDRenderer = CreateDirect3DRMRenderer(DDSDesc, &guid);
|
||||
if (!DDRenderer) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device GUID not recognized");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
@ -60,3 +60,6 @@ class Direct3DRMRenderer : public IDirect3DDevice2 {
|
||||
int m_virtualWidth, m_virtualHeight;
|
||||
ViewportTransform m_viewportTransform;
|
||||
};
|
||||
|
||||
Direct3DRMRenderer* CreateDirect3DRMRenderer(const DDSURFACEDESC& DDSDesc, const GUID* guid);
|
||||
void Direct3DRMRenderer_EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user