Make examples work on OS X
All examples use GLFW, so we update the Makefile, remove OpenGL include headers (GLFW will include them automatically) and conditionally set a different shader version.
This commit is contained in:
parent
8ca1c35608
commit
da9899c618
@ -7,9 +7,14 @@ CFLAGS = -std=c99 -pedantic -O2
|
|||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
BIN := $(BIN).exe
|
BIN := $(BIN).exe
|
||||||
LIBS = -lglfw3 -lopengl32 -lm -lGLU32 -lGLEW32
|
LIBS = -lglfw3 -lopengl32 -lm -lGLU32 -lGLEW32
|
||||||
|
else
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
LIBS = -lglfw3 -framework OpenGL -lm -lGLEW
|
||||||
else
|
else
|
||||||
LIBS = -lglfw -lGL -lm -lGLU -lGLEW
|
LIBS = -lglfw -lGL -lm -lGLU -lGLEW
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
all: node_editor file_browser overview extended
|
all: node_editor file_browser overview extended
|
||||||
node_editor:
|
node_editor:
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_INCLUDE_FIXED_TYPES
|
#define NK_INCLUDE_FIXED_TYPES
|
||||||
@ -32,6 +30,12 @@
|
|||||||
#define MAX_ELEMENT_MEMORY 128 * 1024
|
#define MAX_ELEMENT_MEMORY 128 * 1024
|
||||||
#define UNUSED(a) (void)a
|
#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
|
* DEVICE
|
||||||
@ -52,12 +56,13 @@ struct device {
|
|||||||
GLuint font_tex;
|
GLuint font_tex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
device_init(struct device *dev)
|
device_init(struct device *dev)
|
||||||
{
|
{
|
||||||
GLint status;
|
GLint status;
|
||||||
static const GLchar *vertex_shader =
|
static const GLchar *vertex_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"uniform mat4 ProjMtx;\n"
|
"uniform mat4 ProjMtx;\n"
|
||||||
"in vec2 Position;\n"
|
"in vec2 Position;\n"
|
||||||
"in vec2 TexCoord;\n"
|
"in vec2 TexCoord;\n"
|
||||||
@ -70,7 +75,7 @@ device_init(struct device *dev)
|
|||||||
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
static const GLchar *fragment_shader =
|
static const GLchar *fragment_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
"uniform sampler2D Texture;\n"
|
"uniform sampler2D Texture;\n"
|
||||||
"in vec2 Frag_UV;\n"
|
"in vec2 Frag_UV;\n"
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_INCLUDE_FIXED_TYPES
|
#define NK_INCLUDE_FIXED_TYPES
|
||||||
@ -39,6 +37,12 @@
|
|||||||
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||||
#define LEN(a) (sizeof(a)/sizeof(a)[0])
|
#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 icons {
|
||||||
struct nk_image unchecked;
|
struct nk_image unchecked;
|
||||||
struct nk_image checked;
|
struct nk_image checked;
|
||||||
@ -521,7 +525,7 @@ device_init(struct device *dev)
|
|||||||
{
|
{
|
||||||
GLint status;
|
GLint status;
|
||||||
static const GLchar *vertex_shader =
|
static const GLchar *vertex_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"uniform mat4 ProjMtx;\n"
|
"uniform mat4 ProjMtx;\n"
|
||||||
"in vec2 Position;\n"
|
"in vec2 Position;\n"
|
||||||
"in vec2 TexCoord;\n"
|
"in vec2 TexCoord;\n"
|
||||||
@ -534,7 +538,7 @@ device_init(struct device *dev)
|
|||||||
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
static const GLchar *fragment_shader =
|
static const GLchar *fragment_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
"uniform sampler2D Texture;\n"
|
"uniform sampler2D Texture;\n"
|
||||||
"in vec2 Frag_UV;\n"
|
"in vec2 Frag_UV;\n"
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_INCLUDE_FIXED_TYPES
|
#define NK_INCLUDE_FIXED_TYPES
|
||||||
@ -39,6 +39,12 @@
|
|||||||
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||||
#define LEN(a) (sizeof(a)/sizeof(a)[0])
|
#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
|
* GUI
|
||||||
@ -548,7 +554,7 @@ device_init(struct device *dev)
|
|||||||
{
|
{
|
||||||
GLint status;
|
GLint status;
|
||||||
static const GLchar *vertex_shader =
|
static const GLchar *vertex_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"uniform mat4 ProjMtx;\n"
|
"uniform mat4 ProjMtx;\n"
|
||||||
"in vec2 Position;\n"
|
"in vec2 Position;\n"
|
||||||
"in vec2 TexCoord;\n"
|
"in vec2 TexCoord;\n"
|
||||||
@ -561,7 +567,7 @@ device_init(struct device *dev)
|
|||||||
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
static const GLchar *fragment_shader =
|
static const GLchar *fragment_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
"uniform sampler2D Texture;\n"
|
"uniform sampler2D Texture;\n"
|
||||||
"in vec2 Frag_UV;\n"
|
"in vec2 Frag_UV;\n"
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_INCLUDE_FIXED_TYPES
|
#define NK_INCLUDE_FIXED_TYPES
|
||||||
@ -47,6 +45,12 @@
|
|||||||
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||||
#define LEN(a) (sizeof(a)/sizeof(a)[0])
|
#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
|
* NODE EDITOR
|
||||||
@ -402,7 +406,7 @@ device_init(struct device *dev)
|
|||||||
{
|
{
|
||||||
GLint status;
|
GLint status;
|
||||||
static const GLchar *vertex_shader =
|
static const GLchar *vertex_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"uniform mat4 ProjMtx;\n"
|
"uniform mat4 ProjMtx;\n"
|
||||||
"in vec2 Position;\n"
|
"in vec2 Position;\n"
|
||||||
"in vec2 TexCoord;\n"
|
"in vec2 TexCoord;\n"
|
||||||
@ -415,7 +419,7 @@ device_init(struct device *dev)
|
|||||||
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
static const GLchar *fragment_shader =
|
static const GLchar *fragment_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
"uniform sampler2D Texture;\n"
|
"uniform sampler2D Texture;\n"
|
||||||
"in vec2 Frag_UV;\n"
|
"in vec2 Frag_UV;\n"
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_INCLUDE_FIXED_TYPES
|
#define NK_INCLUDE_FIXED_TYPES
|
||||||
@ -36,6 +34,12 @@
|
|||||||
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||||
#define LEN(a) (sizeof(a)/sizeof(a)[0])
|
#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
|
* GUI
|
||||||
@ -1154,7 +1158,7 @@ device_init(struct device *dev)
|
|||||||
{
|
{
|
||||||
GLint status;
|
GLint status;
|
||||||
static const GLchar *vertex_shader =
|
static const GLchar *vertex_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"uniform mat4 ProjMtx;\n"
|
"uniform mat4 ProjMtx;\n"
|
||||||
"in vec2 Position;\n"
|
"in vec2 Position;\n"
|
||||||
"in vec2 TexCoord;\n"
|
"in vec2 TexCoord;\n"
|
||||||
@ -1167,7 +1171,7 @@ device_init(struct device *dev)
|
|||||||
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
static const GLchar *fragment_shader =
|
static const GLchar *fragment_shader =
|
||||||
"#version 300 es\n"
|
NK_SHADER_VERSION
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
"uniform sampler2D Texture;\n"
|
"uniform sampler2D Texture;\n"
|
||||||
"in vec2 Frag_UV;\n"
|
"in vec2 Frag_UV;\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user