فهرست منبع

Fixing issues preventing Mac OS X compiling and some cleaneup
Also adds initiale code for iOS in Base.h

Brandon Slack 14 سال پیش
والد
کامیت
4be714e1f4
3فایلهای تغییر یافته به همراه35 افزوده شده و 8 حذف شده
  1. 32 6
      gameplay/src/Base.h
  2. 1 0
      gameplay/src/FileSystem.cpp
  3. 2 2
      gameplay/src/PlatformMacOS.mm

+ 32 - 6
gameplay/src/Base.h

@@ -160,14 +160,40 @@ extern void printError(const char* format, ...);
     #define WIN32_LEAN_AND_MEAN
     #include <GL/glew.h>
 #elif __APPLE__
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#define glBindVertexArray glBindVertexArrayAPPLE
-#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
-#define glGenVertexArrays glGenVertexArraysAPPLE
-#define glIsVertexArray glIsVertexArrayAPPLE
+    #include "TargetConditionals.h"
+    // NOTE: Alternative
+    // #ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
+    // ...
+    // #elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
+    // ...
+    // #endif
+    // NOTE: TARGET_OS_MAC is defined in iOS libs, therefore the 
+    // below order matters, the above does not not
+    // see: http://developer.apple.com/library/mac/#documentation/developertools/conceptual/cross_development/Using/using.html
+
+    #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
+        #include <OpenGLES/ES2/gl.h>
+        #include <OpenGLES/ES2/glext.h>
+        #define glBindVertexArray glBindVertexArrayOES
+        #define glDeleteVertexArrays glDeleteVertexArraysOES
+        #define glGenVertexArrays glGenVertexArraysOES
+        #define glIsVertexArray glIsVertexArrayOES
+        #define glClearDepth glClearDepthf
+        #define OPENGL_ES 1
+    #elif TARGET_OS_MAC
+        #include <OpenGL/gl.h>
+        #include <OpenGL/glext.h>
+        #define glBindVertexArray glBindVertexArrayAPPLE
+        #define glDeleteVertexArrays glDeleteVertexArraysAPPLE
+        #define glGenVertexArrays glGenVertexArraysAPPLE
+        #define glIsVertexArray glIsVertexArrayAPPLE
+    #else
+        #error "Unsupported Apple Device"
+    #endif
 #endif
 
+
+
 // Graphics (GLSL)
 #define VERTEX_ATTRIBUTE_POSITION_NAME              "a_position"
 #define VERTEX_ATTRIBUTE_NORMAL_NAME                "a_normal"

+ 1 - 0
gameplay/src/FileSystem.cpp

@@ -7,6 +7,7 @@
     #include <stdio.h>
 #else
     #include <dirent.h>
+    #include <sys/stat.h>
 #endif
 
 namespace gameplay

+ 2 - 2
gameplay/src/PlatformMacOS.mm

@@ -529,7 +529,7 @@ Platform* Platform::create(Game* game)
 int Platform::enterMessagePump()
 {
     NSAutoreleasePool* pool = [NSAutoreleasePool new];
-    NSApplication* NSApp = [NSApplication sharedApplication];
+    NSApplication* app = [NSApplication sharedApplication];
     NSRect screenBounds = [[NSScreen mainScreen] frame];
     NSRect viewBounds = NSMakeRect(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
     
@@ -550,7 +550,7 @@ int Platform::enterMessagePump()
     [window setDelegate:__view];
     [__view release];
     
-    [NSApp run];
+    [app run];
     
     [pool release];
     return EXIT_SUCCESS;