From 2904160889d79255227c2c2f4ed3b6592a78a27d Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Thu, 18 Dec 2025 18:44:36 -0600 Subject: [PATCH] fix Windows XP build --- .gitignore | 1 + Makefile | 8 ++++---- include/math/transform.hpp | 14 +++++++------- src/main.c | 12 ++++++++++-- src/shader/scene.fs.glsl | 2 ++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 6550cc0..8be5d1d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.blend1 *.zip main +*.exe \ No newline at end of file diff --git a/Makefile b/Makefile index af59ee5..be0bcab 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,8 @@ MAKEFILE_PATH := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))) DEBUG = -g -CSTD += -std=gnu23 -CXXSTD += -std=gnu++23 +CSTD += -std=gnu11 +CXXSTD += -std=gnu++14 CFLAGS += -Wall -Werror -Wfatal-errors CFLAGS += -Wno-error=unused-function @@ -20,9 +20,9 @@ CFLAGS += -Wno-error=unused-variable CFLAGS += -I$(MAKEFILE_PATH)/include CFLAGS += -I$(dir $(GLFW))../include CXXFLAGS += -fno-exceptions -LDFLAGS += -nostdlib++ -lm -Wl,-z noexecstack +LDFLAGS += -lm -static-libgcc ifeq ($(shell uname),Linux) -LDFLAGS += -static-libgcc +LDFLAGS += -nostdlib++ endif ifeq ($(OS),Windows_NT) LDFLAGS += -Wl,--subsystem,windows -mwindows diff --git a/include/math/transform.hpp b/include/math/transform.hpp index 34c7ed4..80b4625 100644 --- a/include/math/transform.hpp +++ b/include/math/transform.hpp @@ -41,8 +41,8 @@ inline constexpr mat<4, 4, T> rotate_x(T t) { return { 1, 0, 0, 0, - 0, cos(t), -sin(t), 0, - 0, sin(t), cos(t), 0, + 0, cosf(t), -sinf(t), 0, + 0, sinf(t), cosf(t), 0, 0, 0, 0, 1 }; } @@ -51,9 +51,9 @@ template inline constexpr mat<4, 4, T> rotate_y(T t) { return { - cos(t), 0, sin(t), 0, + cosf(t), 0, sinf(t), 0, 0, 1, 0, 0, - -sin(t), 0, cos(t), 0, + -sinf(t), 0, cosf(t), 0, 0, 0, 0, 1 }; } @@ -62,8 +62,8 @@ template inline constexpr mat<4, 4, T> rotate_z(T t) { return { - cos(t), -sin(t), 0, 0, - sin(t), cos(t), 0, 0, + cosf(t), -sinf(t), 0, 0, + sinf(t), cosf(t), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; @@ -149,7 +149,7 @@ template inline constexpr T inverse_length(vec<3, T> v) { float f = dot(v, v); - return 1.0f / sqrt(f); + return 1.0f / sqrtf(f); } template diff --git a/src/main.c b/src/main.c index 912dd32..d729d52 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "glad/gl.h" @@ -81,8 +82,8 @@ int main() #endif glfwInit(); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); GLFWwindow* window = glfwCreateWindow(vp_width, vp_height, "new", NULL, NULL); @@ -106,6 +107,11 @@ int main() GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version)); return -1; } + printf("%d %d %d\n", + GLAD_GL_ARB_framebuffer_object, + GLAD_GL_ARB_texture_float, + GLAD_GL_ARB_vertex_array_object); + fflush(stdout); ////////////////////////////////////////////////////////////////////// // meshes @@ -173,6 +179,8 @@ int main() const double first_frame = glfwGetTime(); double last_frame = first_frame; + fflush(stderr); + while (!glfwWindowShouldClose(window)) { if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); diff --git a/src/shader/scene.fs.glsl b/src/shader/scene.fs.glsl index edd04ab..fbeb19a 100644 --- a/src/shader/scene.fs.glsl +++ b/src/shader/scene.fs.glsl @@ -1,5 +1,7 @@ #version 130 +precision highp float; + uniform sampler2D texture0; in vec2 f_texture;