diff --git a/src/gx/CGxDevice.hpp b/src/gx/CGxDevice.hpp index 9cf9609..d3e2699 100644 --- a/src/gx/CGxDevice.hpp +++ b/src/gx/CGxDevice.hpp @@ -4,6 +4,7 @@ #include "gx/Buffer.hpp" #include "gx/CGxCaps.hpp" #include "gx/CGxFormat.hpp" +#include "gx/CGxMonitorMode.hpp" #include "gx/CGxMatrixStack.hpp" #include "gx/CGxStateBom.hpp" #include "gx/Types.hpp" @@ -51,10 +52,13 @@ class CGxDevice { static CGxShader* s_uiPixelShader; // Static functions + static bool AdapterMonitorModes(TSGrowableArray& modes); + static void ICursorUpdate(EGxTexCommand, uint32_t, uint32_t, uint32_t, uint32_t, void*, uint32_t&, const void*&); static void LogOpen(); - static void LogClose(); static void Log(const char* format, ...); static void Log(const CGxFormat& format); + static void LogClose(); + static uint32_t PrimCalcCount(EGxPrim primType, uint32_t count); #if defined(WHOA_SYSTEM_WIN) static CGxDevice* NewD3d(); static CGxDevice* NewD3d9Ex(); @@ -66,8 +70,6 @@ class CGxDevice { static CGxDevice* NewGLSDL(); #endif static CGxDevice* NewOpenGl(); - static uint32_t PrimCalcCount(EGxPrim primType, uint32_t count); - static void ICursorUpdate(EGxTexCommand, uint32_t, uint32_t, uint32_t, uint32_t, void*, uint32_t&, const void*&); // Member variables TSGrowableArray m_pushedStates; @@ -84,7 +86,7 @@ class CGxDevice { int32_t intF5C = 0; int32_t m_windowVisible = 0; int32_t intF64 = 0; - int32_t intF6C = 1; + int32_t m_needsReset = 1; CBoundingBox m_viewport; C44Matrix m_projection; C44Matrix m_projNative; diff --git a/src/gx/CGxMonitorMode.cpp b/src/gx/CGxMonitorMode.cpp new file mode 100644 index 0000000..bd9e289 --- /dev/null +++ b/src/gx/CGxMonitorMode.cpp @@ -0,0 +1,8 @@ +#include "gx/CGxMonitorMode.hpp" + +int32_t CGxMonitorModeSort(const void* a, const void* b) { + auto i = static_cast(a); + auto j = static_cast(b); + + return (i->size.x * i->size.y) - (j->size.x * j->size.y); +} diff --git a/src/gx/CGxMonitorMode.hpp b/src/gx/CGxMonitorMode.hpp new file mode 100644 index 0000000..a1447cb --- /dev/null +++ b/src/gx/CGxMonitorMode.hpp @@ -0,0 +1,16 @@ +#ifndef GX_C_GX_MONITOR_MODE_HPP +#define GX_C_GX_MONITOR_MODE_HPP + +#include +#include + +class CGxMonitorMode { + public: + C2iVector size; + uint32_t bpp; + uint32_t refreshRate; +}; + +int32_t CGxMonitorModeSort(const void* i, const void* j); + +#endif diff --git a/src/gx/Device.cpp b/src/gx/Device.cpp index f1aac0c..5bb4c21 100644 --- a/src/gx/Device.cpp +++ b/src/gx/Device.cpp @@ -5,6 +5,22 @@ CGxDevice* g_theGxDevicePtr = nullptr; +// NOTE: this is a backport from later versions +// bitmask listing supported gxapis +uint32_t g_supportedApis = 0 +#if defined(WHOA_SYSTEM_WIN) + | (1 << GxApi_D3d9) +#endif + +#if defined(WHOA_SYSTEM_MAC) + | (1 << GxApi_GLL) +#endif + +#if defined(WHOA_BUILD_GLSDL) + | (1 << GxApi_GLSDL) +#endif +; + CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format) { CGxDevice* device = nullptr; @@ -55,13 +71,18 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t return g_theGxDevicePtr; } else { if (g_theGxDevicePtr) { - delete g_theGxDevicePtr; + DEL(g_theGxDevicePtr); } return nullptr; } } + +int32_t GxDevExists() { + return g_theGxDevicePtr != nullptr; +} + EGxApi GxDevApi() { return g_theGxDevicePtr->m_api; } @@ -73,3 +94,29 @@ void* GxDevWindow() { int32_t GxMasterEnable(EGxMasterEnables state) { return g_theGxDevicePtr->MasterEnable(state); } + +EGxApi GxApiDefault() { +#if defined(WHOA_SYSTEM_WIN) + return GxApi_D3d9; +#endif + +#if defined(WHOA_SYSTEM_MAC) + return GxApi_GLL; +#endif + +#if defined(WHOA_SYSTEM_LINUX) + return GxApi_GLSDL; +#endif +} + +bool GxApiSupported(EGxApi api) { + return (g_supportedApis & static_cast(api)) != 0; +} + +bool GxAdapterMonitorModes(TSGrowableArray& modes) { + return CGxDevice::AdapterMonitorModes(modes); +} + +void GxLogOpen() { + CGxDevice::LogOpen(); +} diff --git a/src/gx/Gx.cpp b/src/gx/Gx.cpp index 72a4ea9..566e582 100644 --- a/src/gx/Gx.cpp +++ b/src/gx/Gx.cpp @@ -34,6 +34,9 @@ const char** g_gxShaderProfileNames[GxShTargets_Last] = { csProfileNames }; +static uint32_t s_maxFPS; +static uint32_t s_maxFPSBk; + const CGxCaps& GxCaps() { return g_theGxDevicePtr->Caps(); } @@ -71,3 +74,19 @@ void GxLogClose() { void GxLog(const char* format, ...) { // TODO } + +void GxSetMaxFPS(uint32_t maxFPS) { + s_maxFPS = maxFPS; +} + +void GxSetMaxFPSBk(uint32_t maxFPSBk) { + s_maxFPSBk = maxFPSBk; +} + +uint32_t GxGetMaxFPS() { + return s_maxFPS; +} + +uint32_t GxGetMaxFPSBk() { + return s_maxFPSBk; +} diff --git a/src/gx/Gx.hpp b/src/gx/Gx.hpp index bd01c83..3efb3bb 100644 --- a/src/gx/Gx.hpp +++ b/src/gx/Gx.hpp @@ -24,4 +24,12 @@ void GxLogClose(); void GxLog(const char* format, ...); +void GxSetMaxFPS(uint32_t maxFPS); + +void GxSetMaxFPSBk(uint32_t maxFPSBk); + +uint32_t GxGetMaxFPS(); + +uint32_t GxGetMaxFPSBk(); + #endif