mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 03:02:30 +00:00
chore(build): make Thunderbrew zig-buildable
This commit is contained in:
parent
c6e2947506
commit
20f392cd74
10 changed files with 934 additions and 33 deletions
|
|
@ -538,6 +538,8 @@ void CGxDeviceD3d::DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2) {
|
|||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -727,6 +729,9 @@ void CGxDeviceD3d::DsSet(EDeviceState state, uint32_t val) {
|
|||
case Ds_ZFunc: {
|
||||
this->m_d3dDevice->SetRenderState(D3DRS_ZFUNC, val);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1915,6 +1920,7 @@ UNLOCK:
|
|||
}
|
||||
|
||||
void CGxDeviceD3d::IXformSetProjection(const C44Matrix& matrix) {
|
||||
#if defined(_MSC_VER)
|
||||
DirectX::XMMATRIX projNative;
|
||||
memcpy(&projNative, &matrix, sizeof(projNative));
|
||||
|
||||
|
|
@ -1948,6 +1954,41 @@ void CGxDeviceD3d::IXformSetProjection(const C44Matrix& matrix) {
|
|||
|
||||
this->m_xforms[GxXform_Projection].m_dirty = 1;
|
||||
memcpy(&this->m_projNative, &projNative, sizeof(this->m_projNative));
|
||||
#else
|
||||
C44Matrix projNative;
|
||||
memcpy(&projNative, &matrix, sizeof(projNative));
|
||||
|
||||
if (NotEqual(projNative.c3, 1.0f, WHOA_EPSILON_1) && NotEqual(projNative.c3, 0.0f, WHOA_EPSILON_1)) {
|
||||
projNative = projNative * (1.0f / projNative.c3);
|
||||
}
|
||||
|
||||
if (projNative.d3 == 0.0f) {
|
||||
auto v5 = -(projNative.d2 / (projNative.c2 + 1.0f));
|
||||
auto v6 = -(projNative.d2 / (projNative.c2 - 1.0f));
|
||||
projNative.c2 = v6 / (v6 - v5);
|
||||
projNative.d2 = v6 * v5 / (v5 - v6);
|
||||
} else {
|
||||
auto v8 = 1.0f / projNative.c2;
|
||||
auto v9 = (-1.0f - projNative.d2) * v8;
|
||||
auto v10 = v8 * (1.0f - projNative.d2);
|
||||
projNative.c2 = 1.0f / (v10 - v9);
|
||||
projNative.d2 = v9 / (v9 - v10);
|
||||
}
|
||||
|
||||
if (!this->MasterEnable(GxMasterEnable_NormalProjection) && projNative.d3 != 1.0f) {
|
||||
C44Matrix shrink = {
|
||||
0.2f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.2f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.2f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
};
|
||||
|
||||
projNative = projNative * shrink;
|
||||
}
|
||||
|
||||
this->m_xforms[GxXform_Projection].m_dirty = 1;
|
||||
memcpy(&this->m_projNative, &projNative, sizeof(this->m_projNative));
|
||||
#endif
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::IXformSetViewport() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef GX_GL_SDL_GL_SDL_CONTEXT_HPP
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "gx/glsdl/GLSDLWindow.hpp"
|
||||
#include "gx/glsdl/GLTypes.hpp"
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextu
|
|||
|
||||
this->m_sdlWindow = SDL_CreateWindow(
|
||||
title,
|
||||
0,
|
||||
0,
|
||||
static_cast<int>(rect.size.width), static_cast<int>(rect.size.height),
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
|
||||
);
|
||||
|
|
@ -229,17 +231,15 @@ GLSDLWindowRect GLSDLWindow::GetRect() {
|
|||
|
||||
int origin_x = 0;
|
||||
int origin_y = 0;
|
||||
if (SDL_GetWindowPosition(this->m_sdlWindow, &origin_x, &origin_y) == 0) {
|
||||
rect.origin.x = static_cast<int32_t>(origin_x);
|
||||
rect.origin.y = static_cast<int32_t>(origin_y);
|
||||
}
|
||||
SDL_GetWindowPosition(this->m_sdlWindow, &origin_x, &origin_y);
|
||||
rect.origin.x = static_cast<int32_t>(origin_x);
|
||||
rect.origin.y = static_cast<int32_t>(origin_y);
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
if (SDL_GetWindowSize(this->m_sdlWindow, &width, &height) == 0) {
|
||||
rect.size.width = static_cast<int32_t>(width);
|
||||
rect.size.height = static_cast<int32_t>(height);
|
||||
}
|
||||
SDL_GetWindowSize(this->m_sdlWindow, &width, &height);
|
||||
rect.size.width = static_cast<int32_t>(width);
|
||||
rect.size.height = static_cast<int32_t>(height);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
|
@ -251,10 +251,9 @@ GLSDLWindowRect GLSDLWindow::GetBackingRect() {
|
|||
// Query backing width/height
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
if (SDL_GetWindowSizeInPixels(this->m_sdlWindow, &width, &height) == 0) {
|
||||
rect.size.width = static_cast<int32_t>(width);
|
||||
rect.size.height = static_cast<int32_t>(height);
|
||||
}
|
||||
SDL_GetWindowSizeInPixels(this->m_sdlWindow, &width, &height);
|
||||
rect.size.width = static_cast<int32_t>(width);
|
||||
rect.size.height = static_cast<int32_t>(height);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
|
@ -263,8 +262,8 @@ void GLSDLWindow::Resize(const GLSDLWindowRect& rect) {
|
|||
auto current = this->GetBackingRect();
|
||||
|
||||
if (current.size.width != rect.size.width || current.size.height != rect.size.width) {
|
||||
auto status = SDL_SetWindowSize(this->m_sdlWindow, rect.size.width, rect.size.height);
|
||||
BLIZZARD_ASSERT(status == 0);
|
||||
SDL_SetWindowSize(this->m_sdlWindow, rect.size.width, rect.size.height);
|
||||
// BLIZZARD_ASSERT(status == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -278,24 +277,24 @@ int32_t GLSDLWindow::GetHeight() {
|
|||
|
||||
void GLSDLWindow::DispatchSDLEvent(const SDL_Event& event) {
|
||||
switch (event.type) {
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
this->DispatchSDLKeyboardEvent(event);
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
this->DispatchSDLMouseButtonEvent(event);
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
case SDL_MOUSEMOTION:
|
||||
this->DispatchSDLMouseMotionEvent(event);
|
||||
break;
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
case SDL_TEXTINPUT:
|
||||
this->DispatchSDLTextInputEvent(event);
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
this->DispatchSDLWindowResizedEvent(event);
|
||||
break;
|
||||
case SDL_EVENT_QUIT:
|
||||
case SDL_QUIT:
|
||||
EventPostClose();
|
||||
break;
|
||||
default:
|
||||
|
|
@ -305,7 +304,7 @@ void GLSDLWindow::DispatchSDLEvent(const SDL_Event& event) {
|
|||
|
||||
void GLSDLWindow::DispatchSDLKeyboardEvent(const SDL_Event& event) {
|
||||
// Is this an up or down keypress?
|
||||
OSINPUT inputclass = event.type == SDL_EVENT_KEY_UP ? OS_INPUT_KEY_UP : OS_INPUT_KEY_DOWN;
|
||||
OSINPUT inputclass = event.type == SDL_KEYUP ? OS_INPUT_KEY_UP : OS_INPUT_KEY_DOWN;
|
||||
|
||||
// What key does this SDL scancode correspond to?
|
||||
auto lookup = s_keyConversion.find(event.key.keysym.scancode);
|
||||
|
|
@ -329,7 +328,7 @@ void GLSDLWindow::DispatchSDLMouseMotionEvent(const SDL_Event& event) {
|
|||
|
||||
void GLSDLWindow::DispatchSDLMouseButtonEvent(const SDL_Event& event) {
|
||||
// Is this an up or down mouse click?
|
||||
OSINPUT inputclass = event.type == SDL_EVENT_MOUSE_BUTTON_UP ? OS_INPUT_MOUSE_UP : OS_INPUT_MOUSE_DOWN;
|
||||
OSINPUT inputclass = event.type == SDL_MOUSEBUTTONUP ? OS_INPUT_MOUSE_UP : OS_INPUT_MOUSE_DOWN;
|
||||
|
||||
// XY click coordinates
|
||||
auto x = static_cast<int32_t>(event.button.x);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define GX_GL_SDL_GL_SDL_WINDOW_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "gx/glsdl/GLTypes.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include "console/CVar.hpp"
|
||||
#include <storm/Memory.hpp>
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
|
||||
FMOD::System* SI2::sm_pGameSystem = nullptr;
|
||||
FMOD::System* SI2::sm_pChatSystem = nullptr;
|
||||
|
||||
|
|
@ -18,6 +20,8 @@ void F_CALL FMOD_Free(void* ptr, FMOD_MEMORY_TYPE type, const char* sourcestr) {
|
|||
SMemFree(ptr, sourcestr, 0, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SI2::RegisterScriptFunctions() {
|
||||
for (int32_t i = 0; i < s_NumScriptFunctions; i++) {
|
||||
auto item = &s_ScriptFunctions[i];
|
||||
|
|
@ -32,6 +36,7 @@ int32_t SI2::Init(int32_t flag) {
|
|||
SI2_LOG("=> Setting up Game Sound:");
|
||||
SI2_LOG(" - SESound Engine Init");
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
SI2_LOG(" - FMOD Memory Init");
|
||||
FMOD::Memory_Initialize(nullptr, 0, &FMOD_Alloc, &FMOD_ReAlloc, &FMOD_Free);
|
||||
// sub_877440(&off_B1D5E4);
|
||||
|
|
@ -59,7 +64,7 @@ int32_t SI2::Init(int32_t flag) {
|
|||
}
|
||||
|
||||
sm_pGameSystem->setOutput(FMOD_OUTPUTTYPE_AUTODETECT);
|
||||
|
||||
#endif
|
||||
LABEL_9:
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,16 @@
|
|||
#include <storm/Log.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstdarg>
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
|
||||
#include <fmod.hpp>
|
||||
#include <fmod_errors.h>
|
||||
|
||||
#endif
|
||||
|
||||
#define SI2_ERR(errcode, format, ...) SI2::Log_Write(__LINE__, __FILE__, errcode, format, ##__VA_ARGS__)
|
||||
#define SI2_LOG(format, ...) SI2::Log_Write(__LINE__, __FILE__, FMOD_OK, format, ##__VA_ARGS__)
|
||||
#define SI2_LOG(format, ...) SI2::Log_Write(__LINE__, __FILE__, 0, format, ##__VA_ARGS__)
|
||||
|
||||
class SI2 {
|
||||
public:
|
||||
|
|
@ -19,14 +23,15 @@ class SI2 {
|
|||
static size_t s_NumScriptFunctions;
|
||||
static uint32_t sm_logFlags;
|
||||
static HSLOG sm_log;
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
static FMOD::System* sm_pGameSystem;
|
||||
static FMOD::System* sm_pChatSystem;
|
||||
|
||||
#endif
|
||||
// Static functions
|
||||
static void RegisterScriptFunctions();
|
||||
static int32_t Log_Init();
|
||||
static void Log_Write(const char* format, ...);
|
||||
static void Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, const char* format, ...);
|
||||
static void Log_Write(uint32_t line, const char* filename, int32_t errcode, const char* format, ...);
|
||||
static void RegisterCVars();
|
||||
static int32_t Init(int32_t flag);
|
||||
static void StartGlueMusic(const char* filename);
|
||||
|
|
|
|||
|
|
@ -25,10 +25,11 @@ void SI2::Log_Write(const char* format, ...) {
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
Log_Write(__LINE__, __FILE__, FMOD_OK, output);
|
||||
// Log_Write(__LINE__, __FILE__, FMOD_OK, output);
|
||||
Log_Write(__LINE__, __FILE__, 0, output);
|
||||
}
|
||||
|
||||
void SI2::Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, const char* format, ...) {
|
||||
void SI2::Log_Write(uint32_t line, const char* filename, int32_t errcode, const char* format, ...) {
|
||||
static uint32_t s_nNumErrors = 0;
|
||||
|
||||
if (s_nNumErrors > 200) {
|
||||
|
|
@ -52,6 +53,7 @@ void SI2::Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, co
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
if (errcode == FMOD_OK) {
|
||||
SLogWrite(sm_log, output);
|
||||
SLogFlush(sm_log);
|
||||
|
|
@ -62,10 +64,13 @@ void SI2::Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, co
|
|||
}
|
||||
|
||||
SLogWrite(sm_log, " -######## FMOD ERROR! (err %d) %s", errcode, FMOD_ErrorString(errcode));
|
||||
#endif
|
||||
|
||||
if (format[0]) {
|
||||
SLogWrite(sm_log, output);
|
||||
}
|
||||
SLogWrite(sm_log, "%s(%d)", filename, line);
|
||||
SLogFlush(sm_log);
|
||||
s_nNumErrors++;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class CSimpleTop : public CLayoutFrame {
|
|||
frame_layout m_layout;
|
||||
CSimpleSortedArray<FRAMEPRIORITY*> m_eventqueue[NUM_FRAME_STRATA][NUM_SIMPLE_EVENTS];
|
||||
int32_t m_checkFocus = 1;
|
||||
EVENT_DATA_MOUSE m_mousePosition;
|
||||
EVENT_DATA_MOUSE m_mousePosition = {};
|
||||
int32_t (*m_mouseButtonCallback)(CMouseEvent*) = nullptr;
|
||||
int32_t (*m_mousePositionCallback)(CMouseEvent*) = nullptr;
|
||||
int32_t (*m_displaySizeCallback)(const CSizeEvent&) = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue