Skip to content

Instantly share code, notes, and snippets.

@grrussel
Created May 7, 2013 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grrussel/5536060 to your computer and use it in GitHub Desktop.
Save grrussel/5536060 to your computer and use it in GitHub Desktop.
OpenXCOM 0.9 Build fixes for OSX 10.7
diff --git a/src/Engine/OpenGL.cpp b/src/Engine/OpenGL.cpp
index 50a694e..bc4e8bf 100644
--- a/src/Engine/OpenGL.cpp
+++ b/src/Engine/OpenGL.cpp
@@ -60,7 +60,7 @@ std::string strGLError(GLenum glErr)
#define glGetProcAddress(name) SDL_GL_GetProcAddress(name)
-
+#ifndef __APPLE__
PFNGLCREATEPROGRAMPROC glCreateProgram = 0;
PFNGLUSEPROGRAMPROC glUseProgram = 0;
PFNGLCREATESHADERPROC glCreateShader = 0;
@@ -74,7 +74,7 @@ PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = 0;
PFNGLUNIFORM1IPROC glUniform1i = 0;
PFNGLUNIFORM2FVPROC glUniform2fv = 0;
PFNGLUNIFORM4FVPROC glUniform4fv = 0;
-
+#endif
void * (APIENTRYP glXGetCurrentDisplay)() = 0;
Uint32 (APIENTRYP glXGetCurrentDrawable)() = 0;
void (APIENTRYP glXSwapIntervalEXT)(void *display, Uint32 GLXDrawable, int interval);
@@ -259,6 +259,7 @@ Uint32 (APIENTRYP wglSwapIntervalEXT)(int interval);
glEnable(GL_TEXTURE_2D);
//bind shader functions
+#ifndef __APPLE__
glCreateProgram = (PFNGLCREATEPROGRAMPROC)glGetProcAddress("glCreateProgram");
glUseProgram = (PFNGLUSEPROGRAMPROC)glGetProcAddress("glUseProgram");
glCreateShader = (PFNGLCREATESHADERPROC)glGetProcAddress("glCreateShader");
@@ -272,7 +273,7 @@ Uint32 (APIENTRYP wglSwapIntervalEXT)(int interval);
glUniform1i = (PFNGLUNIFORM1IPROC)glGetProcAddress("glUniform1i");
glUniform2fv = (PFNGLUNIFORM2FVPROC)glGetProcAddress("glUniform2fv");
glUniform4fv = (PFNGLUNIFORM4FVPROC)glGetProcAddress("glUniform4fv");
-
+#endif
glXGetCurrentDisplay = (void* (APIENTRYP)())glGetProcAddress("glXGetCurrentDisplay");
glXGetCurrentDrawable = (Uint32 (APIENTRYP)())glGetProcAddress("glXGetCurrentDrawable");
glXSwapIntervalEXT = (void (APIENTRYP)(void*, Uint32, int))glGetProcAddress("glXSwapIntervalEXT");
diff --git a/src/Engine/OpenGL.h b/src/Engine/OpenGL.h
index b75fcd3..d099657 100644
--- a/src/Engine/OpenGL.h
+++ b/src/Engine/OpenGL.h
@@ -20,7 +20,7 @@ namespace OpenXcom
{
#define glGetProcAddress(name) SDL_GL_GetProcAddress(name)
-
+#ifndef __APPLE__
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
extern PFNGLUSEPROGRAMPROC glUseProgram;
extern PFNGLCREATESHADERPROC glCreateShader;
@@ -34,7 +34,7 @@ extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
extern PFNGLUNIFORM1IPROC glUniform1i;
extern PFNGLUNIFORM2FVPROC glUniform2fv;
extern PFNGLUNIFORM4FVPROC glUniform4fv;
-
+#endif
std::string strGLError(GLenum glErr);
#define glErrorCheck() {\
diff --git a/src/Makefile.simple b/src/Makefile.simple
index 4d41fa8..00f0eec 100644
--- a/src/Makefile.simple
+++ b/src/Makefile.simple
@@ -1,7 +1,8 @@
# Target system.
# Leave blank for standard Linux builds.
# Put DINGOO for Dingoo A320 builds.
-TARGET =
+# Put OSX for MacOSX 10.7 unix-style builds.
+TARGET = OSX
# Directories and files
OBJDIR = ../obj/
@@ -20,11 +21,19 @@ BIN = openxcom
endif
# Compiler settings
+ifeq ($(TARGET),OSX)
+CXXFLAGS ?= -Wall -Wextra -O2
+else
CXXFLAGS ?= -Wall -Wextra -O2 -rdynamic
+endif
+
CXXFLAGS += $(addprefix -D,$(TARGET))
CXXFLAGS += $(shell $(PKG-CONFIG) --cflags sdl yaml-cpp)
-
+ifeq ($(TARGET),OSX)
+LIBS = $(shell $(PKG-CONFIG) --libs sdl yaml-cpp) -lSDL_gfx -lSDL_mixer -lSDL_image -framework OpenGL
+else
LIBS = $(shell $(PKG-CONFIG) --libs sdl yaml-cpp) -lSDL_gfx -lSDL_mixer -lSDL_image -lGL
+endif
# Rules
all: $(BINDIR)$(BIN)
diff --git a/src/pch.h b/src/pch.h
index 9960477..6f6c804 100644
--- a/src/pch.h
+++ b/src/pch.h
@@ -5,7 +5,13 @@
//#define _CRTDBG_MAP_ALLOC
//#include <stdlib.h>
//#include <crtdbg.h>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#include <OpenGL/glext.h>
+#include <GLUT/glut.h>
+#endif
#include <algorithm>
#include <cassert>
#include <cctype>
@@ -26,7 +32,9 @@
#include <limits>
#include <list>
#include <locale>
+#ifndef __APPLE__
#include <malloc.h>
+#endif
#include <map>
#include <queue>
#include <SDL_endian.h>
@@ -38,6 +46,7 @@
#include <SDL.h>
#include <SDL_syswm.h>
#include <SDL_types.h>
+
#include <set>
#include <sstream>
#include <string>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment