Browse Source

Merge branch 'fdb-osx-support'

vurtun 9 years ago
parent
commit
6b5a4f16e8

+ 6 - 1
demo/allegro5/Makefile

@@ -15,7 +15,12 @@ ifeq ($(OS),Windows_NT)
 BIN := $(BIN).exe
 LIBS = -lmingw32 -lallegro -lallegro_primitives -lm
 else
-LIBS = -lallegro -lallegro_primitives -lGL -lm -lGLU -lGLEW
+	UNAME_S := $(shell uname -s)
+	ifeq ($(UNAME_S),Darwin)
+		LIBS = -lallegro -lallegro_primitives -lallegro_main -framework OpenGL -lm -lGLEW
+	else
+		LIBS = -lallegro -lallegro_primitives -lallegro_main -lGL -lm -lGLU -lGLEW
+	endif
 endif
 
 # Modes

+ 0 - 7
demo/glfw/main.c

@@ -9,13 +9,6 @@
 #include <math.h>
 
 #include <GL/glew.h>
-#ifdef __APPLE__
-    #include <OpenGL/gl.h>
-    #include <OpenGL/glu.h>
-#else
-    #include <GL/gl.h>
-    #include <GL/glu.h>
-#endif
 #include <GLFW/glfw3.h>
 
 /* these defines are both needed for the header

+ 1 - 1
demo/glfw/nuklear_glfw.c

@@ -31,7 +31,7 @@ static struct nk_glfw {
 } glfw;
 
 #ifdef __APPLE__
-  #define NK_SHADER_VERSION "#version 400\n"
+  #define NK_SHADER_VERSION "#version 150\n"
 #else
   #define NK_SHADER_VERSION "#version 300 es\n"
 #endif

+ 6 - 1
demo/sdl/Makefile

@@ -15,7 +15,12 @@ ifeq ($(OS),Windows_NT)
 BIN := $(BIN).exe
 LIBS = -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lm -lGLU32 -lGLEW32
 else
-LIBS = -lSDL2 -lGL -lm -lGLU -lGLEW
+	UNAME_S := $(shell uname -s)
+	ifeq ($(UNAME_S),Darwin)
+		LIBS = -lSDL2 -framework OpenGL -lm -lGLEW
+	else
+		LIBS = -lSDL2 -lGL -lm -lGLU -lGLEW
+	endif
 endif
 
 # Modes

+ 5 - 2
demo/sdl/main.c

@@ -9,9 +9,8 @@
 #include <math.h>
 
 #include <GL/glew.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
 #include <SDL2/SDL.h>
+#include <SDL2/SDL_opengl.h>
 
 /* these defines are both needed for the header
  * and source file. So if you split them remember
@@ -46,6 +45,10 @@ main(void)
 
     /* SDL setup */
     SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS);
+    SDL_GL_SetAttribute (SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
+    SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
     win = SDL_CreateWindow("Demo",
         SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,

+ 7 - 2
demo/sdl/nuklear_sdl.c

@@ -27,12 +27,17 @@ static struct nk_sdl {
     struct nk_font_atlas atlas;
 } sdl;
 
+#ifdef __APPLE__
+  #define NK_SHADER_VERSION "#version 150\n"
+#else
+  #define NK_SHADER_VERSION "#version 300 es\n"
+#endif
 NK_API void
 nk_sdl_device_create(void)
 {
     GLint status;
     static const GLchar *vertex_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "uniform mat4 ProjMtx;\n"
         "in vec2 Position;\n"
         "in vec2 TexCoord;\n"
@@ -45,7 +50,7 @@ nk_sdl_device_create(void)
         "   gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
         "}\n";
     static const GLchar *fragment_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "precision mediump float;\n"
         "uniform sampler2D Texture;\n"
         "in vec2 Frag_UV;\n"

+ 6 - 1
example/Makefile

@@ -8,7 +8,12 @@ ifeq ($(OS),Windows_NT)
 BIN := $(BIN).exe
 LIBS = -lglfw3 -lopengl32 -lm -lGLU32 -lGLEW32
 else
-LIBS = -lglfw -lGL -lm -lGLU -lGLEW
+	UNAME_S := $(shell uname -s)
+	ifeq ($(UNAME_S),Darwin)
+		LIBS = -lglfw3 -framework OpenGL -lm -lGLEW
+	else
+		LIBS = -lglfw -lGL -lm -lGLU -lGLEW
+	endif
 endif
 
 all: node_editor file_browser overview extended

+ 9 - 4
example/calculator.c

@@ -11,8 +11,6 @@
 #include <limits.h>
 
 #include <GL/glew.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
 #include <GLFW/glfw3.h>
 
 #define NK_INCLUDE_FIXED_TYPES
@@ -32,6 +30,12 @@
 #define MAX_ELEMENT_MEMORY 128 * 1024
 #define UNUSED(a) (void)a
 
+#ifdef __APPLE__
+  #define NK_SHADER_VERSION "#version 150\n"
+#else
+  #define NK_SHADER_VERSION "#version 300 es\n"
+#endif
+
 /* ===============================================================
  *
  *                          DEVICE
@@ -52,12 +56,13 @@ struct device {
     GLuint font_tex;
 };
 
+
 static void
 device_init(struct device *dev)
 {
     GLint status;
     static const GLchar *vertex_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "uniform mat4 ProjMtx;\n"
         "in vec2 Position;\n"
         "in vec2 TexCoord;\n"
@@ -70,7 +75,7 @@ device_init(struct device *dev)
         "   gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
         "}\n";
     static const GLchar *fragment_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "precision mediump float;\n"
         "uniform sampler2D Texture;\n"
         "in vec2 Frag_UV;\n"

+ 8 - 4
example/extended.c

@@ -11,8 +11,6 @@
 #include <limits.h>
 
 #include <GL/glew.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
 #include <GLFW/glfw3.h>
 
 #define NK_INCLUDE_FIXED_TYPES
@@ -39,6 +37,12 @@
 #define MAX(a,b) ((a) < (b) ? (b) : (a))
 #define LEN(a) (sizeof(a)/sizeof(a)[0])
 
+#ifdef __APPLE__
+  #define NK_SHADER_VERSION "#version 150\n"
+#else
+  #define NK_SHADER_VERSION "#version 300 es\n"
+#endif
+
 struct icons {
     struct nk_image unchecked;
     struct nk_image checked;
@@ -521,7 +525,7 @@ device_init(struct device *dev)
 {
     GLint status;
     static const GLchar *vertex_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "uniform mat4 ProjMtx;\n"
         "in vec2 Position;\n"
         "in vec2 TexCoord;\n"
@@ -534,7 +538,7 @@ device_init(struct device *dev)
         "   gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
         "}\n";
     static const GLchar *fragment_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "precision mediump float;\n"
         "uniform sampler2D Texture;\n"
         "in vec2 Frag_UV;\n"

+ 10 - 4
example/file_browser.c

@@ -9,10 +9,10 @@
 #include <math.h>
 #include <time.h>
 #include <limits.h>
+#include <unistd.h>
+#include <dirent.h>
 
 #include <GL/glew.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
 #include <GLFW/glfw3.h>
 
 #define NK_INCLUDE_FIXED_TYPES
@@ -39,6 +39,12 @@
 #define MAX(a,b) ((a) < (b) ? (b) : (a))
 #define LEN(a) (sizeof(a)/sizeof(a)[0])
 
+#ifdef __APPLE__
+  #define NK_SHADER_VERSION "#version 150\n"
+#else
+  #define NK_SHADER_VERSION "#version 300 es\n"
+#endif
+
 /* ===============================================================
  *
  *                          GUI
@@ -548,7 +554,7 @@ device_init(struct device *dev)
 {
     GLint status;
     static const GLchar *vertex_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "uniform mat4 ProjMtx;\n"
         "in vec2 Position;\n"
         "in vec2 TexCoord;\n"
@@ -561,7 +567,7 @@ device_init(struct device *dev)
         "   gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
         "}\n";
     static const GLchar *fragment_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "precision mediump float;\n"
         "uniform sampler2D Texture;\n"
         "in vec2 Frag_UV;\n"

+ 8 - 4
example/node_editor.c

@@ -22,8 +22,6 @@
 #include <limits.h>
 
 #include <GL/glew.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
 #include <GLFW/glfw3.h>
 
 #define NK_INCLUDE_FIXED_TYPES
@@ -47,6 +45,12 @@
 #define MAX(a,b) ((a) < (b) ? (b) : (a))
 #define LEN(a) (sizeof(a)/sizeof(a)[0])
 
+#ifdef __APPLE__
+  #define NK_SHADER_VERSION "#version 150\n"
+#else
+  #define NK_SHADER_VERSION "#version 300 es\n"
+#endif
+
 /* ===============================================================
  *
  *                          NODE EDITOR
@@ -402,7 +406,7 @@ device_init(struct device *dev)
 {
     GLint status;
     static const GLchar *vertex_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "uniform mat4 ProjMtx;\n"
         "in vec2 Position;\n"
         "in vec2 TexCoord;\n"
@@ -415,7 +419,7 @@ device_init(struct device *dev)
         "   gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
         "}\n";
     static const GLchar *fragment_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "precision mediump float;\n"
         "uniform sampler2D Texture;\n"
         "in vec2 Frag_UV;\n"

+ 8 - 4
example/overview.c

@@ -11,8 +11,6 @@
 #include <limits.h>
 
 #include <GL/glew.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
 #include <GLFW/glfw3.h>
 
 #define NK_INCLUDE_FIXED_TYPES
@@ -36,6 +34,12 @@
 #define MAX(a,b) ((a) < (b) ? (b) : (a))
 #define LEN(a) (sizeof(a)/sizeof(a)[0])
 
+#ifdef __APPLE__
+  #define NK_SHADER_VERSION "#version 150\n"
+#else
+  #define NK_SHADER_VERSION "#version 300 es\n"
+#endif
+
 /* ===============================================================
  *
  *                          GUI
@@ -1154,7 +1158,7 @@ device_init(struct device *dev)
 {
     GLint status;
     static const GLchar *vertex_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "uniform mat4 ProjMtx;\n"
         "in vec2 Position;\n"
         "in vec2 TexCoord;\n"
@@ -1167,7 +1171,7 @@ device_init(struct device *dev)
         "   gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
         "}\n";
     static const GLchar *fragment_shader =
-        "#version 300 es\n"
+        NK_SHADER_VERSION
         "precision mediump float;\n"
         "uniform sampler2D Texture;\n"
         "in vec2 Frag_UV;\n"