fix: make it build on windows

This commit is contained in:
Tropical 2026-04-10 19:12:57 -07:00
parent c58c1bd9d2
commit c432e83d18
20 changed files with 85 additions and 77 deletions

View file

@ -10,7 +10,7 @@ project(
'warning_level=0',
'unity=on', # merge source files per target
'unity_size=8', # TODO: mess around with this
'buildtype=debugoptimized', # needed for _FORTIFY_SOURCE
# 'buildtype=debugoptimized', # needed for _FORTIFY_SOURCE
'b_pch=true', # precompiled headers
# 'b_lto=true', # link-time optimisation (ThinLTO under clang+lld)
# 'b_ndebug=if-release', # drop assert() in --buildtype=release

View file

@ -32,6 +32,7 @@
#include "platform/profile/profile.h"
#include "platform/storage/storage.h"
#include "util/StringHelpers.h"
#include "strings.h"
void Game::HandleXuiActions(void) {
eXuiAction eAction;

View file

@ -1,8 +1,12 @@
#define GDRAW_ASSERTS
#include "gdraw.h"
#include <GL/gl.h>
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#endif
#include <GL/glew.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
@ -128,33 +132,33 @@ typedef gdraw_gl_resourcetype gdraw_resourcetype;
GDRAW_GL_EXTENSION_LIST
#undef GLE
typedef const GLubyte*(APIENTRYP PFNGLGETSTRINGIPROC_)(GLenum name,
typedef const GLubyte*(APIENTRY* PFNGLGETSTRINGIPROC_)(GLenum name,
GLuint index);
static PFNGLGETSTRINGIPROC_ gdraw_glGetStringi = NULL;
typedef void(APIENTRYP PFNGLGENVERTEXARRAYSPROC_)(GLsizei n, GLuint* arrays);
typedef void(APIENTRYP PFNGLBINDVERTEXARRAYPROC_)(GLuint array);
typedef void(APIENTRY* PFNGLGENVERTEXARRAYSPROC_)(GLsizei n, GLuint* arrays);
typedef void(APIENTRY* PFNGLBINDVERTEXARRAYPROC_)(GLuint array);
static PFNGLGENVERTEXARRAYSPROC_ gdraw_glGenVertexArrays = NULL;
static PFNGLBINDVERTEXARRAYPROC_ gdraw_glBindVertexArray = NULL;
static GLuint gdraw_vao = 0;
typedef void(APIENTRYP gdraw_vtxattrib_fn)(GLuint, GLint, GLenum, GLboolean,
typedef void(APIENTRY* gdraw_vtxattrib_fn)(GLuint, GLint, GLenum, GLboolean,
GLsizei, const void*);
static gdraw_vtxattrib_fn gdraw_real_vtxattrib = NULL;
static GLuint gdraw_screenvbo = 0;
static const void* gdraw_screenvbo_base = NULL;
static size_t gdraw_expected_vbo_size = 0;
typedef void(APIENTRYP gdraw_drawelements_fn)(GLenum mode, GLsizei count,
typedef void(APIENTRY* gdraw_drawelements_fn)(GLenum mode, GLsizei count,
GLenum type, const void* indices);
static gdraw_drawelements_fn gdraw_real_drawelements = NULL;
static GLuint gdraw_screenibo = 0;
typedef GLuint(APIENTRYP gdraw_createshader_fn)(GLenum);
typedef void(APIENTRYP gdraw_shadersource_fn)(GLuint, GLsizei, const GLchar**,
typedef GLuint(APIENTRY* gdraw_createshader_fn)(GLenum);
typedef void(APIENTRY* gdraw_shadersource_fn)(GLuint, GLsizei, const GLchar**,
const GLint*);
typedef void(APIENTRYP gdraw_compileshader_fn)(GLuint);
typedef void(APIENTRYP gdraw_linkprogram_fn)(GLuint);
typedef void(APIENTRY* gdraw_compileshader_fn)(GLuint);
typedef void(APIENTRY* gdraw_linkprogram_fn)(GLuint);
static gdraw_createshader_fn gdraw_real_createshader = NULL;
static gdraw_shadersource_fn gdraw_real_shadersource = NULL;
static gdraw_compileshader_fn gdraw_real_compileshader = NULL;
@ -162,24 +166,24 @@ static gdraw_linkprogram_fn gdraw_real_linkprogram = NULL;
// some core reject p0
typedef void(APIENTRYP gdraw_useprogram_fn)(GLuint);
typedef void(APIENTRY* gdraw_useprogram_fn)(GLuint);
static gdraw_useprogram_fn gdraw_real_useprogram = NULL;
static GLuint gdraw_null_program = 0;
typedef void(APIENTRYP gdraw_teximage2d_fn)(GLenum, GLint, GLint, GLsizei,
typedef void(APIENTRY* gdraw_teximage2d_fn)(GLenum, GLint, GLint, GLsizei,
GLsizei, GLint, GLenum, GLenum,
const void*);
typedef void(APIENTRYP gdraw_texsubimage2d_fn)(GLenum, GLint, GLint, GLint,
typedef void(APIENTRY* gdraw_texsubimage2d_fn)(GLenum, GLint, GLint, GLint,
GLsizei, GLsizei, GLenum, GLenum,
const void*);
static gdraw_teximage2d_fn gdraw_real_teximage2d = NULL;
static gdraw_texsubimage2d_fn gdraw_real_texsubimage2d = NULL;
#define TRY(ptr, arb, core) \
do { \
#define TRY(ptr, arb, core) \
do { \
void* _p = SDL_GL_GetProcAddress(core); \
if (!_p) _p = SDL_GL_GetProcAddress(arb); \
*(void**)&(ptr) = _p; \
*(void**)&(ptr) = _p; \
} while (0)
static void load_extensions(void) {
@ -254,15 +258,19 @@ static void load_extensions(void) {
(gdraw_shadersource_fn)SDL_GL_GetProcAddress("glShaderSource");
gdraw_real_compileshader =
(gdraw_compileshader_fn)SDL_GL_GetProcAddress("glCompileShader");
gdraw_real_linkprogram = (gdraw_linkprogram_fn)SDL_GL_GetProcAddress("glLinkProgram");
gdraw_real_teximage2d = (gdraw_teximage2d_fn)SDL_GL_GetProcAddress("glTexImage2D");
gdraw_real_linkprogram =
(gdraw_linkprogram_fn)SDL_GL_GetProcAddress("glLinkProgram");
gdraw_real_teximage2d =
(gdraw_teximage2d_fn)SDL_GL_GetProcAddress("glTexImage2D");
gdraw_real_texsubimage2d =
(gdraw_texsubimage2d_fn)SDL_GL_GetProcAddress("glTexSubImage2D");
gdraw_real_useprogram = (gdraw_useprogram_fn)SDL_GL_GetProcAddress("glUseProgram");
gdraw_real_useprogram =
(gdraw_useprogram_fn)SDL_GL_GetProcAddress("glUseProgram");
gdraw_real_drawelements =
(gdraw_drawelements_fn)SDL_GL_GetProcAddress("glDrawElements");
gdraw_glGetStringi = (PFNGLGETSTRINGIPROC_)SDL_GL_GetProcAddress("glGetStringi");
gdraw_glGetStringi =
(PFNGLGETSTRINGIPROC_)SDL_GL_GetProcAddress("glGetStringi");
gdraw_glGenVertexArrays =
(PFNGLGENVERTEXARRAYSPROC_)SDL_GL_GetProcAddress("glGenVertexArrays");
gdraw_glBindVertexArray =

View file

@ -10,6 +10,15 @@
#include "rrCore.h" // base data types, macros
// on windows, these will cause MSVC to shit itself due to thinking
// the stubbed iggy symbols are DLL-exported.
#ifndef _ENABLEIGGY
#undef RADEXPFUNC
#undef RADEXPLINK
#define RADEXPFUNC
#define RADEXPLINK
#endif
RADDEFSTART
#ifndef IGGY_GDRAW_SHARED_TYPEDEF
@ -123,8 +132,8 @@ typedef enum IggyDatatype {
/* Describes an AS3 datatype visible through iggy interface. */
#ifdef __RADWIN__
#include <stddef.h>
IDOCN typedef char IggyUTF16;
#include <uchar.h>
IDOCN typedef char16_t IggyUTF16;
#else
#include <uchar.h>
typedef const char16_t IggyUTF16;

View file

@ -21,6 +21,7 @@
#include "platform/renderer/renderer.h"
#include "strings.h"
#include "util/StringHelpers.h"
#include "app/common/ui/ConsoleUIController.h"
int LocalizationManager::s_iHTMLFontSizesA[eHTMLSize_COUNT] = {20, 13, 20, 26};

View file

@ -24,6 +24,7 @@
#include "minecraft/world/level/tile/entity/HopperTileEntity.h"
#include "platform/profile/profile.h"
#include "platform/storage/storage.h"
#include "strings.h"
unsigned char MenuController::m_szPNG[8] = {137, 80, 78, 71, 13, 10, 26, 10};

View file

@ -21,6 +21,7 @@
#include "platform/input/input.h"
#include "platform/profile/profile.h"
#include "platform/storage/storage.h"
#include "strings.h"
unsigned int NetworkController::m_uiLastSignInData = 0;

View file

@ -176,21 +176,22 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) {
random->nextInt((int)m_splashes.size() - (eSplashRandomStart + 1));
// Override splash text on certain dates
const std::time_t now =
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm localTime;
localtime_r(&now, &localTime);
const int month = localTime.tm_mon + 1; // tm_mon is 0-based
const int day = localTime.tm_mday;
if (month == 11 && day == 9) {
auto now = std::chrono::system_clock::now();
auto dp = std::chrono::floor<std::chrono::days>(now);
std::chrono::year_month_day ymd{dp};
const auto month = ymd.month();
const uint32_t day = static_cast<uint32_t>(ymd.day());
if (month == std::chrono::November && day == 9) {
splashIndex = eSplashHappyBirthdayEx;
} else if (month == 6 && day == 1) {
} else if (month == std::chrono::June && day == 1) {
splashIndex = eSplashHappyBirthdayNotch;
} else if (month == 12 && day == 24) // the Java game shows this on
// Christmas Eve, so we will too
} else if (month == std::chrono::December &&
day == 24) // the Java game shows this on
// Christmas Eve, so we will too
{
splashIndex = eSplashMerryXmas;
} else if (month == 1 && day == 1) {
} else if (month == std::chrono::January && day == 1) {
splashIndex = eSplashHappyNewYear;
}
// splashIndex = 47; // Very short string

View file

@ -36,7 +36,7 @@ class UIScene;
// 4jcraft, used to be D3D11_RECT.
// This was the only class that used it, so it's here now.
struct 4J_RECT {
struct RECT_4J {
long left;
long top;
long right;
@ -190,7 +190,7 @@ private:
int m_accumulatedTicks;
uint64_t m_lastUiSfx; // Tracks time (ms) of last UI sound effect
4J_RECT m_customRenderingClearRect;
RECT_4J m_customRenderingClearRect;
std::unordered_map<size_t, UIScene*>
m_registeredCallbackScenes; // A collection of scenes and unique id's

View file

@ -40,7 +40,6 @@ static void sigsegv_handler(int sig) {
_exit(139);
}
#endif
#include <features.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

View file

@ -27,6 +27,7 @@ app_dependencies += [
dependency('miniaudio'), # todo: remove once PlatformSound is used
dependency('stb'),
dependency('simdutf'),
dependency('glew'), # TODO remove
java_dep,
nbt_dep,
util_dep,

View file

@ -279,8 +279,6 @@ void SelectWorldScreen::WorldSelectionList::renderItem(int i, int x, int y,
(unsigned)ymd.month(), (int)ymd.year(),
(int)hms.hours().count(), (int)hms.minutes().count());
id = id + " (" + buffer;
int64_t size = levelSummary->getSizeOnDisk();
id = id + ", " + toWString<float>(size / 1024 * 100 / 1024 / 100.0f) +
" MB)";

View file

@ -65,6 +65,7 @@
#include "minecraft/world/entity/player/Abilities.h"
#include "minecraft/world/entity/player/Inventory.h"
#include "minecraft/world/entity/player/Player.h"
#include "minecraft/world/entity/item/MinecartHopper.h"
#include "minecraft/world/food/FoodConstants.h"
#include "minecraft/world/food/FoodData.h"
#include "minecraft/world/item/BowItem.h"

View file

@ -7,6 +7,7 @@
#include <cmath>
#include <ctime>
#include <vector>
#include <numbers>
#include "java/InputOutputStream/BufferedReader.h"
#include "java/InputOutputStream/ByteArrayInputStream.h"
@ -68,20 +69,20 @@ TitleScreen::TitleScreen() {
random->nextInt((int)splashes.size() - (eSplashRandomStart + 1));
// Override splash text on certain dates
const auto now = std::chrono::system_clock::now();
const auto t = std::chrono::system_clock::to_time_t(now);
std::tm localTime;
localtime_r(&t, &localTime);
const int month = localTime.tm_mon + 1; // tm_mon is 0-based
const int day = localTime.tm_mday;
if (month == 11 && day == 9) {
auto now = std::chrono::system_clock::now();
auto dp = std::chrono::floor<std::chrono::days>(now);
std::chrono::year_month_day ymd{dp};
const auto month = ymd.month();
const uint32_t day = static_cast<uint32_t>(ymd.day());
if (month == std::chrono::November && day == 9) {
splashIndex = eSplashHappyBirthdayEx;
} else if (month == 6 && day == 1) {
} else if (month == std::chrono::June && day == 1) {
splashIndex = eSplashHappyBirthdayNotch;
} else if (month == 12 && day == 24) {
} else if (month == std::chrono::December && day == 24) {
// the Java game shows this on Christmas Eve, so we will too
splashIndex = eSplashMerryXmas;
} else if (month == 1 && day == 1) {
} else if (month == std::chrono::January && day == 1) {
splashIndex = eSplashHappyNewYear;
}

View file

@ -12,6 +12,7 @@ lib_minecraft = static_library('minecraft',
# dependency('libcrypto'), # for MD5 in Hasher.cpp on Linux
dependency('zlib'),
dependency('glm'),
dependency('glew'), # TODO remove
nbt_dep,
java_dep,
util_dep,

View file

@ -2,6 +2,7 @@
#include <memory>
#include <vector>
#include <string>
class ItemInstance;
class Player;

View file

@ -24,8 +24,6 @@
#undef glNormalPointer
#undef glColorPointer
#undef glVertexPointer
#undef glGenQueriesARB
#undef glGetQueryObjectuARB
#undef glEnable
#undef glDisable
#undef glBlendFunc

View file

@ -2,7 +2,6 @@
#include "gl3_loader.h"
// NOTE: gl3_loader.h must be included before these two
#include <GL/gl.h>
#include <cstdint>

View file

@ -16,7 +16,7 @@
// #include "gl3_loader.h"
// NOTE: gl3_loader.h must be included before these two
#include <GL/gl.h>
#include <GL/glew.h>
#include <cstdint>
#include <cstdlib>
@ -261,6 +261,16 @@
#define GL_RESCALE_NORMAL 0x803A
#endif
#ifndef GL_BGRA
#define GL_BGRA 0x80E1
#endif
#ifndef GL_RGBA
#define GL_RGBA 0x1908
#endif
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
// glCallList / display list macros
#undef glNewList
@ -460,7 +470,6 @@
#define glActiveTexture(tex) \
do { \
PlatformRenderer.StateSetActiveTexture(tex); \
::glActiveTexture(tex); \
} while (0)
#undef glClientActiveTexture
@ -478,11 +487,6 @@ void glTexImage2D_4J(int target, int level, int internalformat, int width,
int height, int border, int format, int type,
void* pixels);
// helprs
void glGenQueries_4J_Helper(unsigned int* id);
void glGetQueryObjectu_4J_Helper(unsigned int id, unsigned int pname,
unsigned int* val);
template <typename T>
inline void glGenTextures_4J(T* buf) {
unsigned int id = 0;
@ -523,20 +527,6 @@ inline void glCallLists_4J(T* lists) {
}
}
template <typename T>
inline void glGenQueries_4J(T* buf) {
unsigned int id = 0;
glGenQueries_4J_Helper(&id);
buf->put((int)id);
buf->flip();
}
template <typename T>
inline void glGetQueryObjectu_4J(int id, int pname, T* params) {
unsigned int val = 0;
glGetQueryObjectu_4J_Helper((unsigned int)id, (unsigned int)pname, &val);
params->put((int)val);
params->flip();
}
template <typename T>
inline void glFog_4J(int pname, T* params) {
float* p = params->_getDataPointer();
if (pname == 0x0B66 /* GL_FOG_COLOR */)
@ -589,8 +579,6 @@ inline void glReadPixels_4J(int x, int y, int width, int height, int format,
#define glTexImage2D(a, b, c, d, e, f, g, h, i) \
glTexImage2D_4J(a, b, c, d, e, f, g, h, i)
#define glCallLists(x) glCallLists_4J(x)
#define glGenQueriesARB(x) glGenQueries_4J(x)
#define glGetQueryObjectuARB(a, b, c) glGetQueryObjectu_4J(a, b, c)
#define glReadPixels(a, b, c, d, e, f, g) glReadPixels_4J(a, b, c, d, e, f, g)
#define glFog(a, b) glFog_4J(a, b)
#define glLight(a, b, c) glLight_4J(a, b, c)

View file

@ -8,7 +8,6 @@
#include <windows.h>
#endif
#include <GL/gl.h>
#include <string.h>
#include "java/File.h"