Fix building on Windows

- Drop linking opengl32/glew32.libs using `#pragma`s in favour of
  specifing the libraries at build time.
- Use check for the `WIN32` macro when including Windows specific
  headers in `src/render_gl.c`.
- Undefine the `min`, `max`, `near`, and `far` macros when building on
  Windows.
This commit is contained in:
Stephen Gregoratto 2023-08-13 17:50:39 +10:00
parent ecf1e63508
commit 9207839c80
2 changed files with 11 additions and 9 deletions

View file

@ -11,18 +11,14 @@
// Linux // Linux
#elif defined(__unix__) #elif defined(__unix__)
#include <GL/glew.h> #include <GL/glew.h>
#elif defined(__MSYS__)
#include <GL/glew.h> // Windows
// WINDOWS #elif defined(WIN32)
#else
#include <windows.h> #include <windows.h>
#define GL3_PROTOTYPES 1 #define GL3_PROTOTYPES 1
#include <glew.h> #include <GL/glew.h>
#pragma comment(lib, "glew32.lib") #include <GL/gl.h>
#include <gl/GL.h>
#pragma comment(lib, "opengl32.lib")
#endif #endif

View file

@ -4,6 +4,12 @@
#include <string.h> #include <string.h>
#include "types.h" #include "types.h"
#ifdef WIN32
#undef min
#undef max
#undef near
#undef far
#endif
#if !defined(offsetof) #if !defined(offsetof)
#define offsetof(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT)) #define offsetof(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))