Update SDL example for OS X

Just like GLFW example, use different settings in Makefile and
different shader versions.
This commit is contained in:
Frederik De Bleser 2016-04-19 13:47:17 +02:00
parent a8d124adf1
commit 8ca1c35608
2 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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"