mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-07-29 19:58:29 +03:00
Compare commits
No commits in common. "e77ed33b0cd811ca9acbeeb681846e884a8d6892" and "8adf3a0061121b6d1a86a57faa1f339e386ab9f2" have entirely different histories.
e77ed33b0c
...
8adf3a0061
@ -1 +1 @@
|
||||
Subproject commit a654f25957979c381760916f6382b526ef024491
|
||||
Subproject commit cde3ed90ee64986c1721f7db428e841af518cda0
|
@ -1,5 +1,4 @@
|
||||
#include "gx/CGxDevice.hpp"
|
||||
#include "gx/CGxMonitorMode.hpp"
|
||||
#include "gx/Gx.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
#include "gx/texture/CGxTex.hpp"
|
||||
@ -14,6 +13,7 @@
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
#include <storm/Error.hpp>
|
||||
#include <bc/Memory.hpp>
|
||||
|
||||
@ -168,93 +168,6 @@ 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() {
|
||||
// TODO
|
||||
// - implement rest of constructor
|
||||
@ -374,9 +287,9 @@ const CRect& CGxDevice::DeviceDefWindow() {
|
||||
}
|
||||
|
||||
void CGxDevice::ICursorCreate(const CGxFormat& format) {
|
||||
int32_t hardwareCursor = format.hwCursor && this->m_caps.m_hwCursor;
|
||||
int32_t hardwareCursor = format.hwCursor && this->m_caps.m_hardwareCursor;
|
||||
|
||||
this->m_hwCursor = hardwareCursor;
|
||||
this->m_hardwareCursor = hardwareCursor;
|
||||
|
||||
// If hardware cursor is disabled, and there is no cursor texture yet, create one
|
||||
if (!hardwareCursor && this->m_cursorTexture == nullptr) {
|
||||
@ -408,7 +321,7 @@ void CGxDevice::ICursorDraw() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->m_hwCursor) {
|
||||
if (this->m_hardwareCursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#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"
|
||||
@ -52,13 +51,10 @@ class CGxDevice {
|
||||
static CGxShader* s_uiPixelShader;
|
||||
|
||||
// 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 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();
|
||||
@ -70,6 +66,8 @@ 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<CGxPushedRenderState> m_pushedStates;
|
||||
@ -86,7 +84,7 @@ class CGxDevice {
|
||||
int32_t intF5C = 0;
|
||||
int32_t m_windowVisible = 0;
|
||||
int32_t intF64 = 0;
|
||||
int32_t m_needsReset = 1;
|
||||
int32_t intF6C = 1;
|
||||
CBoundingBox m_viewport;
|
||||
C44Matrix m_projection;
|
||||
C44Matrix m_projNative;
|
||||
|
@ -1,8 +0,0 @@
|
||||
#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);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#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,22 +5,6 @@
|
||||
|
||||
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;
|
||||
|
||||
@ -71,18 +55,13 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t
|
||||
return g_theGxDevicePtr;
|
||||
} else {
|
||||
if (g_theGxDevicePtr) {
|
||||
DEL(g_theGxDevicePtr);
|
||||
delete g_theGxDevicePtr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t GxDevExists() {
|
||||
return g_theGxDevicePtr != nullptr;
|
||||
}
|
||||
|
||||
EGxApi GxDevApi() {
|
||||
return g_theGxDevicePtr->m_api;
|
||||
}
|
||||
@ -94,29 +73,3 @@ 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<uint32_t>(api)) != 0;
|
||||
}
|
||||
|
||||
bool GxAdapterMonitorModes(TSGrowableArray<CGxMonitorMode>& modes) {
|
||||
return CGxDevice::AdapterMonitorModes(modes);
|
||||
}
|
||||
|
||||
void GxLogOpen() {
|
||||
CGxDevice::LogOpen();
|
||||
}
|
||||
|
@ -34,9 +34,6 @@ const char** g_gxShaderProfileNames[GxShTargets_Last] = {
|
||||
csProfileNames
|
||||
};
|
||||
|
||||
static uint32_t s_maxFPS;
|
||||
static uint32_t s_maxFPSBk;
|
||||
|
||||
const CGxCaps& GxCaps() {
|
||||
return g_theGxDevicePtr->Caps();
|
||||
}
|
||||
@ -74,19 +71,3 @@ 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;
|
||||
}
|
||||
|
@ -24,12 +24,4 @@ void GxLogClose();
|
||||
|
||||
void GxLog(const char* format, ...);
|
||||
|
||||
void GxSetMaxFPS(uint32_t maxFPS);
|
||||
|
||||
void GxSetMaxFPSBk(uint32_t maxFPSBk);
|
||||
|
||||
uint32_t GxGetMaxFPS();
|
||||
|
||||
uint32_t GxGetMaxFPSBk();
|
||||
|
||||
#endif
|
||||
|
@ -88,19 +88,6 @@ enum EGxMasterEnables {
|
||||
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 {
|
||||
GxPrim_Points = 0,
|
||||
GxPrim_Lines = 1,
|
||||
|
@ -2200,12 +2200,9 @@ void CGxDeviceD3d::ShaderCreate(CGxShader* shaders[], EGxShTarget target, const
|
||||
}
|
||||
|
||||
int32_t CGxDeviceD3d::StereoEnabled() {
|
||||
return this->m_d3dStereoEnabled == 1;
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::CursorUnlock() {
|
||||
CGxDevice::CursorUnlock(x, y);
|
||||
this->m_hwCursorNeedsUpdate = 1;
|
||||
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::XformSetProjection(const C44Matrix& matrix) {
|
||||
|
Loading…
Reference in New Issue
Block a user