From e808f24e718ba3eae01b20dc3dc9e1526fd20871 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 27 Dec 2021 00:51:24 +0200 Subject: [PATCH] fixed windows build --- .gitignore | 1 + Makefile | 3 ++- src/opengl.h | 6 ------ src/pc/main_glut.c | 1 + src/pc/miniglut.c | 4 +++- src/sanegl.c | 24 ++++++++++++------------ src/sanegl.h | 6 +++--- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 24d4e0e..fdf3b67 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ keystore.jks *.a data apkbuild +*.exe diff --git a/Makefile b/Makefile index fd57f47..718b7dd 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ incdir = -Isrc -Ilibs/imago/src -Ilibs/glew libdir = -Llibs/unix CFLAGS = $(warn) $(dbg) $(opt) $(def) $(incdir) -fcommon -MMD -LDFLAGS = $(libsys) $(libgl) -lm -limago +LDFLAGS = $(libdir) $(libsys) $(libgl) -lm -limago sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') ifeq ($(sys), mingw) @@ -19,6 +19,7 @@ ifeq ($(sys), mingw) bin = demo.exe libgl = -lopengl32 libsys = -lmingw32 -lgdi32 -lwinmm -mconsole + libdir = -Llibs/w32 else libgl = -lGL -lX11 -lXext endif diff --git a/src/opengl.h b/src/opengl.h index e352e3d..e0ce977 100644 --- a/src/opengl.h +++ b/src/opengl.h @@ -18,12 +18,6 @@ #include -#ifdef __APPLE__ -#include -#else -#include -#endif /* __APPLE__ */ - #endif /* IPHONE */ int init_opengl(void); diff --git a/src/pc/main_glut.c b/src/pc/main_glut.c index ce0a68d..cdff0e5 100644 --- a/src/pc/main_glut.c +++ b/src/pc/main_glut.c @@ -1,6 +1,7 @@ #include #include #include +#include "opengl.h" #include "miniglut.h" #include "demo.h" diff --git a/src/pc/miniglut.c b/src/pc/miniglut.c index 6ea9b4e..4f77408 100644 --- a/src/pc/miniglut.c +++ b/src/pc/miniglut.c @@ -1764,7 +1764,9 @@ static void panic(const char *msg) #ifdef MINIGLUT_USE_LIBC #include -#ifdef __unix__ +#ifdef _WIN32 +#include +#else #include #endif diff --git a/src/sanegl.c b/src/sanegl.c index b22dadd..48c8f05 100644 --- a/src/sanegl.c +++ b/src/sanegl.c @@ -152,17 +152,17 @@ void gl_scalef(float x, float y, float z) gl_mult_matrixf(mat); } -void gl_ortho(float left, float right, float bottom, float top, float near, float far) +void gl_ortho(float left, float right, float bottom, float top, float znear, float zfar) { float mat[] = MAT_IDENT; float dx = right - left; float dy = top - bottom; - float dz = far - near; + float dz = zfar - znear; float tx = -(right + left) / dx; float ty = -(top + bottom) / dy; - float tz = -(far + near) / dz; + float tz = -(zfar + znear) / dz; float sx = 2.0 / dx; float sy = 2.0 / dy; @@ -178,21 +178,21 @@ void gl_ortho(float left, float right, float bottom, float top, float near, floa gl_mult_matrixf(mat); } -void gl_frustum(float left, float right, float bottom, float top, float near, float far) +void gl_frustum(float left, float right, float bottom, float top, float znear, float zfar) { float mat[] = MAT_IDENT; float dx = right - left; float dy = top - bottom; - float dz = far - near; + float dz = zfar - znear; float a = (right + left) / dx; float b = (top + bottom) / dy; - float c = -(far + near) / dz; - float d = -2.0 * far * near / dz; + float c = -(zfar + znear) / dz; + float d = -2.0 * zfar * znear / dz; - mat[0] = 2.0 * near / dx; - mat[5] = 2.0 * near / dy; + mat[0] = 2.0 * znear / dx; + mat[5] = 2.0 * znear / dy; mat[8] = a; mat[9] = b; mat[10] = c; @@ -202,11 +202,11 @@ void gl_frustum(float left, float right, float bottom, float top, float near, fl gl_mult_matrixf(mat); } -void glu_perspective(float vfov, float aspect, float near, float far) +void glu_perspective(float vfov, float aspect, float znear, float zfar) { float vfov_rad = M_PI * vfov / 180.0; - float x = near * tan(vfov_rad / 2.0); - gl_frustum(-aspect * x, aspect * x, -x, x, near, far); + float x = znear * tan(vfov_rad / 2.0); + gl_frustum(-aspect * x, aspect * x, -x, x, znear, zfar); } void gl_apply_xform(unsigned int prog) diff --git a/src/sanegl.h b/src/sanegl.h index 33ec395..0f3ec40 100644 --- a/src/sanegl.h +++ b/src/sanegl.h @@ -70,9 +70,9 @@ void gl_mult_matrixf(const float *mat); void gl_translatef(float x, float y, float z); void gl_rotatef(float angle, float x, float y, float z); void gl_scalef(float x, float y, float z); -void gl_ortho(float left, float right, float bottom, float top, float near, float far); -void gl_frustum(float left, float right, float bottom, float top, float near, float far); -void glu_perspective(float vfov, float aspect, float near, float far); +void gl_ortho(float left, float right, float bottom, float top, float znear, float zfar); +void gl_frustum(float left, float right, float bottom, float top, float znear, float zfar); +void glu_perspective(float vfov, float aspect, float znear, float zfar); void gl_apply_xform(unsigned int prog); -- 1.7.10.4