diff --git a/example/Makefile b/example/Makefile index e1b0419..fc32735 100644 --- a/example/Makefile +++ b/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 diff --git a/example/calculator.c b/example/calculator.c index 551252e..52cdc52 100644 --- a/example/calculator.c +++ b/example/calculator.c @@ -11,8 +11,6 @@ #include #include -#include -#include #include #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" diff --git a/example/extended.c b/example/extended.c index 3304464..1fbc616 100644 --- a/example/extended.c +++ b/example/extended.c @@ -11,8 +11,6 @@ #include #include -#include -#include #include #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" diff --git a/example/file_browser.c b/example/file_browser.c index e6e1e89..591de8a 100644 --- a/example/file_browser.c +++ b/example/file_browser.c @@ -9,10 +9,10 @@ #include #include #include +#include +#include #include -#include -#include #include #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" diff --git a/example/node_editor.c b/example/node_editor.c index 5b70e67..0c6325f 100644 --- a/example/node_editor.c +++ b/example/node_editor.c @@ -22,8 +22,6 @@ #include #include -#include -#include #include #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" diff --git a/example/overview.c b/example/overview.c index 827347f..1e3f5de 100644 --- a/example/overview.c +++ b/example/overview.c @@ -11,8 +11,6 @@ #include #include -#include -#include #include #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"