mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-07-23 17:11:48 +03:00
Compare commits
5 Commits
8adf3a0061
...
e77ed33b0c
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e77ed33b0c | ||
![]() |
0c50b0698d | ||
![]() |
c67ca6fba9 | ||
![]() |
12b405a4dd | ||
![]() |
7bd7d1ac9e |
@ -1 +1 @@
|
|||||||
Subproject commit cde3ed90ee64986c1721f7db428e841af518cda0
|
Subproject commit a654f25957979c381760916f6382b526ef024491
|
@ -1,4 +1,5 @@
|
|||||||
#include "gx/CGxDevice.hpp"
|
#include "gx/CGxDevice.hpp"
|
||||||
|
#include "gx/CGxMonitorMode.hpp"
|
||||||
#include "gx/Gx.hpp"
|
#include "gx/Gx.hpp"
|
||||||
#include "gx/Shader.hpp"
|
#include "gx/Shader.hpp"
|
||||||
#include "gx/texture/CGxTex.hpp"
|
#include "gx/texture/CGxTex.hpp"
|
||||||
@ -13,7 +14,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <new>
|
|
||||||
#include <storm/Error.hpp>
|
#include <storm/Error.hpp>
|
||||||
#include <bc/Memory.hpp>
|
#include <bc/Memory.hpp>
|
||||||
|
|
||||||
@ -168,6 +168,93 @@ void CGxDevice::ICursorUpdate(EGxTexCommand command, uint32_t width, uint32_t he
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
|
|
||||||
|
// TODO: replace this invented name
|
||||||
|
int32_t FindDisplayDevice(PDISPLAY_DEVICE device, uint32_t flag) {
|
||||||
|
DWORD i = 0;
|
||||||
|
device->cb = sizeof(DISPLAY_DEVICE);
|
||||||
|
while (EnumDisplayDevices(nullptr, i, device, 0)) {
|
||||||
|
if ((device->StateFlags & flag) == flag) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGxDevice::AdapterMonitorModes(TSGrowableArray<CGxMonitorMode>& modes) {
|
||||||
|
modes.SetCount(0);
|
||||||
|
|
||||||
|
DISPLAY_DEVICE device;
|
||||||
|
if (!FindDisplayDevice(&device, DISPLAY_DEVICE_PRIMARY_DEVICE)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEVMODE dm;
|
||||||
|
dm.dmSize = sizeof(DEVMODE);
|
||||||
|
|
||||||
|
DWORD i = 0;
|
||||||
|
while (EnumDisplaySettings(&device, i, &dm)) {
|
||||||
|
if ((dm.dmPelsWidth >= 640 && dm.dmPelsHeight >= 480)
|
||||||
|
&& dm.dmBitsPerPel >= 16) {
|
||||||
|
auto mode = modes.New();
|
||||||
|
|
||||||
|
mode->size.x = dm.dmPelsWidth;
|
||||||
|
mode->size.y = dm.dmPelsHeight;
|
||||||
|
mode->bpp = dm.dmBitsPerPel;
|
||||||
|
mode->refreshRate = dm.dmDisplayFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
qsort(modes.Ptr(), modes.Count(), sizeof(CGxMonitorMode), CGxMonitorModeSort);
|
||||||
|
|
||||||
|
return modes.Count() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif (WHOA_SYSTEM_MAC)
|
||||||
|
|
||||||
|
bool CGxDevice::AdapterMonitorModes(TSGrowableArray<CGxMonitorMode>& modes) {
|
||||||
|
// TODO: Mac support
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif (WHOA_BUILD_GLSDL)
|
||||||
|
|
||||||
|
bool CGxDevice::AdapterMonitorModes(TSGrowableArray<CGxMonitorMode>& modes) {
|
||||||
|
auto primaryDisplay = SDL_GetPrimaryDisplay();
|
||||||
|
if (!primaryDisplay) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t displayModeCount;
|
||||||
|
auto displayModes = SDL_GetFullscreenDisplayModes(primaryDisplay, &displayModeCount);
|
||||||
|
if (displayModes == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
modes.SetCount(displayModeCount);
|
||||||
|
for (auto i = 0; i < displayModeCount; i++) {
|
||||||
|
auto displayMode = displayModes[i];
|
||||||
|
CGxMonitorMode& mode = modes[i];
|
||||||
|
mode.size.x = displayMode->w;
|
||||||
|
mode.size.y = displayMode->h;
|
||||||
|
mode.bpp = displayMode->format.BitsPerPixel;
|
||||||
|
mode.refreshRate = static_cast<uint32_t>(displayMode->format.refresh_rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_free(displayModes);
|
||||||
|
|
||||||
|
qsort(modes.Ptr(), modes.Count(), sizeof(CGxMonitorMode), CGxMonitorModeSort);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
CGxDevice::CGxDevice() {
|
CGxDevice::CGxDevice() {
|
||||||
// TODO
|
// TODO
|
||||||
// - implement rest of constructor
|
// - implement rest of constructor
|
||||||
@ -287,9 +374,9 @@ const CRect& CGxDevice::DeviceDefWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGxDevice::ICursorCreate(const CGxFormat& format) {
|
void CGxDevice::ICursorCreate(const CGxFormat& format) {
|
||||||
int32_t hardwareCursor = format.hwCursor && this->m_caps.m_hardwareCursor;
|
int32_t hardwareCursor = format.hwCursor && this->m_caps.m_hwCursor;
|
||||||
|
|
||||||
this->m_hardwareCursor = hardwareCursor;
|
this->m_hwCursor = hardwareCursor;
|
||||||
|
|
||||||
// If hardware cursor is disabled, and there is no cursor texture yet, create one
|
// If hardware cursor is disabled, and there is no cursor texture yet, create one
|
||||||
if (!hardwareCursor && this->m_cursorTexture == nullptr) {
|
if (!hardwareCursor && this->m_cursorTexture == nullptr) {
|
||||||
@ -321,7 +408,7 @@ void CGxDevice::ICursorDraw() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->m_hardwareCursor) {
|
if (this->m_hwCursor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "gx/Buffer.hpp"
|
#include "gx/Buffer.hpp"
|
||||||
#include "gx/CGxCaps.hpp"
|
#include "gx/CGxCaps.hpp"
|
||||||
#include "gx/CGxFormat.hpp"
|
#include "gx/CGxFormat.hpp"
|
||||||
|
#include "gx/CGxMonitorMode.hpp"
|
||||||
#include "gx/CGxMatrixStack.hpp"
|
#include "gx/CGxMatrixStack.hpp"
|
||||||
#include "gx/CGxStateBom.hpp"
|
#include "gx/CGxStateBom.hpp"
|
||||||
#include "gx/Types.hpp"
|
#include "gx/Types.hpp"
|
||||||
@ -51,10 +52,13 @@ class CGxDevice {
|
|||||||
static CGxShader* s_uiPixelShader;
|
static CGxShader* s_uiPixelShader;
|
||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
|
static bool AdapterMonitorModes(TSGrowableArray<CGxMonitorMode>& modes);
|
||||||
|
static void ICursorUpdate(EGxTexCommand, uint32_t, uint32_t, uint32_t, uint32_t, void*, uint32_t&, const void*&);
|
||||||
static void LogOpen();
|
static void LogOpen();
|
||||||
static void LogClose();
|
|
||||||
static void Log(const char* format, ...);
|
static void Log(const char* format, ...);
|
||||||
static void Log(const CGxFormat& format);
|
static void Log(const CGxFormat& format);
|
||||||
|
static void LogClose();
|
||||||
|
static uint32_t PrimCalcCount(EGxPrim primType, uint32_t count);
|
||||||
#if defined(WHOA_SYSTEM_WIN)
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
static CGxDevice* NewD3d();
|
static CGxDevice* NewD3d();
|
||||||
static CGxDevice* NewD3d9Ex();
|
static CGxDevice* NewD3d9Ex();
|
||||||
@ -66,8 +70,6 @@ class CGxDevice {
|
|||||||
static CGxDevice* NewGLSDL();
|
static CGxDevice* NewGLSDL();
|
||||||
#endif
|
#endif
|
||||||
static CGxDevice* NewOpenGl();
|
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
|
// Member variables
|
||||||
TSGrowableArray<CGxPushedRenderState> m_pushedStates;
|
TSGrowableArray<CGxPushedRenderState> m_pushedStates;
|
||||||
@ -84,7 +86,7 @@ class CGxDevice {
|
|||||||
int32_t intF5C = 0;
|
int32_t intF5C = 0;
|
||||||
int32_t m_windowVisible = 0;
|
int32_t m_windowVisible = 0;
|
||||||
int32_t intF64 = 0;
|
int32_t intF64 = 0;
|
||||||
int32_t intF6C = 1;
|
int32_t m_needsReset = 1;
|
||||||
CBoundingBox m_viewport;
|
CBoundingBox m_viewport;
|
||||||
C44Matrix m_projection;
|
C44Matrix m_projection;
|
||||||
C44Matrix m_projNative;
|
C44Matrix m_projNative;
|
||||||
|
8
src/gx/CGxMonitorMode.cpp
Normal file
8
src/gx/CGxMonitorMode.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "gx/CGxMonitorMode.hpp"
|
||||||
|
|
||||||
|
int32_t CGxMonitorModeSort(const void* a, const void* b) {
|
||||||
|
auto i = static_cast<const CGxMonitorMode*>(a);
|
||||||
|
auto j = static_cast<const CGxMonitorMode*>(b);
|
||||||
|
|
||||||
|
return (i->size.x * i->size.y) - (j->size.x * j->size.y);
|
||||||
|
}
|
16
src/gx/CGxMonitorMode.hpp
Normal file
16
src/gx/CGxMonitorMode.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef GX_C_GX_MONITOR_MODE_HPP
|
||||||
|
#define GX_C_GX_MONITOR_MODE_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <tempest/Vector.hpp>
|
||||||
|
|
||||||
|
class CGxMonitorMode {
|
||||||
|
public:
|
||||||
|
C2iVector size;
|
||||||
|
uint32_t bpp;
|
||||||
|
uint32_t refreshRate;
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t CGxMonitorModeSort(const void* i, const void* j);
|
||||||
|
|
||||||
|
#endif
|
@ -5,6 +5,22 @@
|
|||||||
|
|
||||||
CGxDevice* g_theGxDevicePtr = nullptr;
|
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* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format) {
|
||||||
CGxDevice* device = nullptr;
|
CGxDevice* device = nullptr;
|
||||||
|
|
||||||
@ -55,13 +71,18 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t
|
|||||||
return g_theGxDevicePtr;
|
return g_theGxDevicePtr;
|
||||||
} else {
|
} else {
|
||||||
if (g_theGxDevicePtr) {
|
if (g_theGxDevicePtr) {
|
||||||
delete g_theGxDevicePtr;
|
DEL(g_theGxDevicePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t GxDevExists() {
|
||||||
|
return g_theGxDevicePtr != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
EGxApi GxDevApi() {
|
EGxApi GxDevApi() {
|
||||||
return g_theGxDevicePtr->m_api;
|
return g_theGxDevicePtr->m_api;
|
||||||
}
|
}
|
||||||
@ -73,3 +94,29 @@ void* GxDevWindow() {
|
|||||||
int32_t GxMasterEnable(EGxMasterEnables state) {
|
int32_t GxMasterEnable(EGxMasterEnables state) {
|
||||||
return g_theGxDevicePtr->MasterEnable(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<uint32_t>(api)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GxAdapterMonitorModes(TSGrowableArray<CGxMonitorMode>& modes) {
|
||||||
|
return CGxDevice::AdapterMonitorModes(modes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxLogOpen() {
|
||||||
|
CGxDevice::LogOpen();
|
||||||
|
}
|
||||||
|
@ -34,6 +34,9 @@ const char** g_gxShaderProfileNames[GxShTargets_Last] = {
|
|||||||
csProfileNames
|
csProfileNames
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static uint32_t s_maxFPS;
|
||||||
|
static uint32_t s_maxFPSBk;
|
||||||
|
|
||||||
const CGxCaps& GxCaps() {
|
const CGxCaps& GxCaps() {
|
||||||
return g_theGxDevicePtr->Caps();
|
return g_theGxDevicePtr->Caps();
|
||||||
}
|
}
|
||||||
@ -71,3 +74,19 @@ void GxLogClose() {
|
|||||||
void GxLog(const char* format, ...) {
|
void GxLog(const char* format, ...) {
|
||||||
// TODO
|
// 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;
|
||||||
|
}
|
||||||
|
@ -24,4 +24,12 @@ void GxLogClose();
|
|||||||
|
|
||||||
void GxLog(const char* format, ...);
|
void GxLog(const char* format, ...);
|
||||||
|
|
||||||
|
void GxSetMaxFPS(uint32_t maxFPS);
|
||||||
|
|
||||||
|
void GxSetMaxFPSBk(uint32_t maxFPSBk);
|
||||||
|
|
||||||
|
uint32_t GxGetMaxFPS();
|
||||||
|
|
||||||
|
uint32_t GxGetMaxFPSBk();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -88,6 +88,19 @@ enum EGxMasterEnables {
|
|||||||
GxMasterEnables_Last = 9
|
GxMasterEnables_Last = 9
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EGxOverride {
|
||||||
|
GxOverride_PixelShader = 0,
|
||||||
|
GxOverride_Unk1 = 1,
|
||||||
|
GxOverride_Unk2 = 2,
|
||||||
|
GxOverride_Unk3 = 3,
|
||||||
|
GxOverride_Unk4 = 4,
|
||||||
|
GxOverride_Unk5 = 5,
|
||||||
|
GxOverride_Unk6 = 6,
|
||||||
|
GxOverride_Unk7 = 7,
|
||||||
|
GxOverride_Unk8 = 8,
|
||||||
|
GxOverrides_Last = 9
|
||||||
|
};
|
||||||
|
|
||||||
enum EGxPrim {
|
enum EGxPrim {
|
||||||
GxPrim_Points = 0,
|
GxPrim_Points = 0,
|
||||||
GxPrim_Lines = 1,
|
GxPrim_Lines = 1,
|
||||||
|
@ -2200,9 +2200,12 @@ void CGxDeviceD3d::ShaderCreate(CGxShader* shaders[], EGxShTarget target, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CGxDeviceD3d::StereoEnabled() {
|
int32_t CGxDeviceD3d::StereoEnabled() {
|
||||||
|
return this->m_d3dStereoEnabled == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGxDeviceD3d::CursorUnlock() {
|
||||||
CGxDevice::CursorUnlock(x, y);
|
CGxDevice::CursorUnlock(x, y);
|
||||||
this->m_hwCursorNeedsUpdate = 1;
|
this->m_hwCursorNeedsUpdate = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGxDeviceD3d::XformSetProjection(const C44Matrix& matrix) {
|
void CGxDeviceD3d::XformSetProjection(const C44Matrix& matrix) {
|
||||||
|
Loading…
Reference in New Issue
Block a user