Skip to content

Commit

Permalink
Support OS X for the GLFW demo.
Browse files Browse the repository at this point in the history
Use conditionals to support the appropriate includes and shader
versions needed for OS X.
  • Loading branch information
fdb committed Apr 19, 2016
1 parent 9b2822c commit 5b0b4c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 6 additions & 1 deletion demo/glfw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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

# Modes
Expand Down
9 changes: 7 additions & 2 deletions demo/glfw/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
#include <math.h>

#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.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
Expand Down
10 changes: 8 additions & 2 deletions demo/glfw/nuklear_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ static struct nk_glfw {
float scroll;
} glfw;

#ifdef __APPLE__
#define NK_SHADER_VERSION "#version 400\n"
#else
#define NK_SHADER_VERSION "#version 300 es\n"
#endif

NK_API void
nk_glfw3_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"
Expand All @@ -48,7 +54,7 @@ nk_glfw3_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"
Expand Down

0 comments on commit 5b0b4c9

Please sign in to comment.