# HG changeset patch # User John Tsiombikas # Date 1455830509 -7200 # Node ID 7e911c994ef210310c1daa091e0897c6c78b2f8b # Parent b469e6a72636ff005e5de81d4a1d17ec970552e8 should work on mac now diff -r b469e6a72636 -r 7e911c994ef2 Makefile --- a/Makefile Thu Feb 18 23:15:43 2016 +0200 +++ b/Makefile Thu Feb 18 23:21:49 2016 +0200 @@ -4,7 +4,13 @@ CC = gcc CFLAGS = -pedantic -Wall -g -LDFLAGS = -lglut -lGL -lGLU +LDFLAGS = $(libgl) + +ifeq ($(shell uname -s), Darwin) + libgl = -framework OpenGL -framework GLUT -lGLEW +else + libgl = -lGL -lGLU -lglut -lGLEW +endif $(bin): $(obj) $(CC) -o $@ $(obj) $(LDFLAGS) diff -r b469e6a72636 -r 7e911c994ef2 refmod_test.c --- a/refmod_test.c Thu Feb 18 23:15:43 2016 +0200 +++ b/refmod_test.c Thu Feb 18 23:21:49 2016 +0200 @@ -1,7 +1,12 @@ #include #include #include +#include +#ifdef __APPLE__ +#include +#else #include +#endif #include "sdr.h" #ifdef FREEGLUT diff -r b469e6a72636 -r 7e911c994ef2 sdr.c --- a/sdr.c Thu Feb 18 23:15:43 2016 +0200 +++ b/sdr.c Thu Feb 18 23:21:49 2016 +0200 @@ -3,86 +3,19 @@ #include #include #include +#include #if defined(unix) || defined(__unix__) #include #include -#include #endif /* unix */ -#if defined(WIN32) || defined(__WIN32__) -#include - -#define glXGetProcAddress wglGetProcAddress -#endif /* windows */ - -#define GL_GLEXT_LEGACY -#include - #include "sdr.h" -#ifndef GL_VERSION_2_0 - -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_CURRENT_PROGRAM 0x8B8D - -typedef char GLchar; - -GLuint (*glCreateProgram)(void); -GLuint (*glCreateShader)(GLenum); -void (*glDeleteProgram)(GLuint); -void (*glDeleteShader)(GLuint); -void (*glCompileShader)(GLuint); -void (*glAttachShader)(GLuint, GLuint); -void (*glGetShaderiv)(GLuint, GLenum, GLint *); -void (*glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); -void (*glGetProgramiv)(GLuint, GLenum, GLint *); -void (*glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); -void (*glLinkProgram)(GLuint); -void (*glShaderSource)(GLuint, GLsizei, const GLchar* *, const GLint *); -void (*glUseProgram)(GLuint); -GLint (*glGetUniformLocation)(GLuint, const GLchar *); -void (*glUniform1f)(GLint, GLfloat); -void (*glUniform2f)(GLint, GLfloat, GLfloat); -void (*glUniform3f)(GLint, GLfloat, GLfloat, GLfloat); -void (*glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); -void (*glUniform1i)(GLint, GLint); -void (*glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *); -GLint (*glGetAttribLocation)(GLuint, const GLchar *); -void (*glVertexAttrib3f)(GLint, GLfloat, GLfloat, GLfloat); - void init_sdr(void) { - glCreateProgram = glXGetProcAddress("glCreateProgramObjectARB"); - glCreateShader = glXGetProcAddress("glCreateShaderObjectARB"); - glDeleteProgram = glXGetProcAddress("glDeleteObjectARB"); - glDeleteShader = glXGetProcAddress("glDeleteObjectARB"); - glCompileShader = glXGetProcAddress("glCompileShaderARB"); - glAttachShader = glXGetProcAddress("glAttachObjectARB"); - glGetShaderiv = glXGetProcAddress("glGetObjectParameterivARB"); - glGetShaderInfoLog = glXGetProcAddress("glGetInfoLogARB"); - glGetProgramiv = glXGetProcAddress("glGetObjectParameterivARB"); - glGetProgramInfoLog = glXGetProcAddress("glGetInfoLogARB"); - glLinkProgram = glXGetProcAddress("glLinkProgramARB"); - glShaderSource = glXGetProcAddress("glShaderSourceARB"); - glUseProgram = glXGetProcAddress("glUseProgramObjectARB"); - glGetUniformLocation = glXGetProcAddress("glGetUniformLocationARB"); - glUniform1f = glXGetProcAddress("glUniform1fARB"); - glUniform2f = glXGetProcAddress("glUniform2fARB"); - glUniform3f = glXGetProcAddress("glUniform3fARB"); - glUniform4f = glXGetProcAddress("glUniform4fARB"); - glUniform1i = glXGetProcAddress("glUniform1iARB"); - glUniformMatrix4fv = glXGetProcAddress("glUniformMatrix4fvARB"); - glGetAttribLocation = glXGetProcAddress("glGetAttribLocationARB"); - glVertexAttrib3f = glXGetProcAddress("glVertexAttrib3fARB"); + glewInit(); } -#else -void init_sdr(void) {} -#endif unsigned int create_vertex_shader(const char *src) {