fix(gx): simplified gx device creation according to api enum

This commit is contained in:
phaneron 2024-07-22 01:21:08 -04:00
parent 45f23fb3ba
commit 1b4f1dba86
3 changed files with 34 additions and 31 deletions

View file

@ -122,7 +122,7 @@ pub fn build(b: *std.Build) void {
// GLSDL // GLSDL
const build_glsdl_option = b.option(bool, "WHOA_BUILD_GLSDL", "Enable"); const build_glsdl_option = b.option(bool, "WHOA_BUILD_GLSDL", "Enable");
switch (target.result.os) { switch (t.os.tag) {
.windows => { .windows => {
// SDL is off by default // SDL is off by default
build_glsdl = build_glsdl_option orelse false; build_glsdl = build_glsdl_option orelse false;

View file

@ -5,6 +5,7 @@
#include "util/SFile.hpp" #include "util/SFile.hpp"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <cstdio>
#include <limits> #include <limits>
#include <new> #include <new>
#include <storm/Error.hpp> #include <storm/Error.hpp>
@ -14,7 +15,7 @@
#include "gx/d3d/CGxDeviceD3d.hpp" #include "gx/d3d/CGxDeviceD3d.hpp"
#endif #endif
#if defined(WHOA_SYSTEM_LINUX) || defined(WHOA_SYSTEM_WIN) #if defined(WHOA_BUILD_GLSDL)
#include "gx/glsdl/CGxDeviceGLSDL.hpp" #include "gx/glsdl/CGxDeviceGLSDL.hpp"
#endif #endif

View file

@ -7,37 +7,39 @@ CGxDevice* g_theGxDevicePtr = nullptr;
CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format) { CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format) {
CGxDevice* device; CGxDevice* device;
#if defined(WHOA_SYSTEM_WIN) switch (api) {
if (api == GxApi_OpenGl) { case GxApi_OpenGl:
device = CGxDevice::NewOpenGl(); device = CGxDevice::NewOpenGl();
} else if (api == GxApi_D3d9) {
#if defined(WHOA_SYSTEM_WIN)
case GxApi_D3d9:
device = CGxDevice::NewD3d(); device = CGxDevice::NewD3d();
} else if (api == GxApi_D3d9Ex) { break;
case GxApi_D3d9Ex:
device = CGxDevice::NewD3d9Ex(); device = CGxDevice::NewD3d9Ex();
} else if (api == GxApi_GLSDL) { break;
device = CGxDevice::NewGLSDL(); case GxApi_D3d10:
} else { case GxApi_D3d11:
// Error // Error
} break;
#endif #endif
#if defined(WHOA_SYSTEM_MAC) #if defined(WHOA_SYSTEM_MAC)
if (api == GxApi_OpenGl) { case GxApi_GLL:
device = CGxDevice::NewOpenGl();
} else if (api == GxApi_GLL) {
device = CGxDevice::NewGLL(); device = CGxDevice::NewGLL();
} else { break;
// Error #endif
}
#endif
#if defined(WHOA_SYSTEM_LINUX) #if defined(WHOA_BUILD_GLSDL)
if (api == GxApi_GLSDL) { case GxApi_GLSDL:
device = CGxDevice::NewGLSDL(); device = CGxDevice::NewGLSDL();
} else { break;
#endif
default:
// Error // Error
break;
} }
#endif
g_theGxDevicePtr = device; g_theGxDevicePtr = device;