refmod_test
changeset 1:7e911c994ef2 tip
should work on mac now
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 18 Feb 2016 23:21:49 +0200 |
parents | b469e6a72636 |
children | |
files | Makefile refmod_test.c sdr.c |
diffstat | 3 files changed, 14 insertions(+), 70 deletions(-) [+] |
line diff
1.1 --- a/Makefile Thu Feb 18 23:15:43 2016 +0200 1.2 +++ b/Makefile Thu Feb 18 23:21:49 2016 +0200 1.3 @@ -4,7 +4,13 @@ 1.4 1.5 CC = gcc 1.6 CFLAGS = -pedantic -Wall -g 1.7 -LDFLAGS = -lglut -lGL -lGLU 1.8 +LDFLAGS = $(libgl) 1.9 + 1.10 +ifeq ($(shell uname -s), Darwin) 1.11 + libgl = -framework OpenGL -framework GLUT -lGLEW 1.12 +else 1.13 + libgl = -lGL -lGLU -lglut -lGLEW 1.14 +endif 1.15 1.16 $(bin): $(obj) 1.17 $(CC) -o $@ $(obj) $(LDFLAGS)
2.1 --- a/refmod_test.c Thu Feb 18 23:15:43 2016 +0200 2.2 +++ b/refmod_test.c Thu Feb 18 23:21:49 2016 +0200 2.3 @@ -1,7 +1,12 @@ 2.4 #include <stdio.h> 2.5 #include <stdlib.h> 2.6 #include <string.h> 2.7 +#include <GL/glew.h> 2.8 +#ifdef __APPLE__ 2.9 +#include <GLUT/glut.h> 2.10 +#else 2.11 #include <GL/glut.h> 2.12 +#endif 2.13 #include "sdr.h" 2.14 2.15 #ifdef FREEGLUT
3.1 --- a/sdr.c Thu Feb 18 23:15:43 2016 +0200 3.2 +++ b/sdr.c Thu Feb 18 23:21:49 2016 +0200 3.3 @@ -3,86 +3,19 @@ 3.4 #include <string.h> 3.5 #include <errno.h> 3.6 #include <assert.h> 3.7 +#include <GL/glew.h> 3.8 3.9 #if defined(unix) || defined(__unix__) 3.10 #include <unistd.h> 3.11 #include <sys/stat.h> 3.12 -#include <GL/glx.h> 3.13 #endif /* unix */ 3.14 3.15 -#if defined(WIN32) || defined(__WIN32__) 3.16 -#include <windows.h> 3.17 - 3.18 -#define glXGetProcAddress wglGetProcAddress 3.19 -#endif /* windows */ 3.20 - 3.21 -#define GL_GLEXT_LEGACY 3.22 -#include <GL/gl.h> 3.23 - 3.24 #include "sdr.h" 3.25 3.26 -#ifndef GL_VERSION_2_0 3.27 - 3.28 -#define GL_FRAGMENT_SHADER 0x8B30 3.29 -#define GL_VERTEX_SHADER 0x8B31 3.30 -#define GL_COMPILE_STATUS 0x8B81 3.31 -#define GL_LINK_STATUS 0x8B82 3.32 -#define GL_INFO_LOG_LENGTH 0x8B84 3.33 -#define GL_CURRENT_PROGRAM 0x8B8D 3.34 - 3.35 -typedef char GLchar; 3.36 - 3.37 -GLuint (*glCreateProgram)(void); 3.38 -GLuint (*glCreateShader)(GLenum); 3.39 -void (*glDeleteProgram)(GLuint); 3.40 -void (*glDeleteShader)(GLuint); 3.41 -void (*glCompileShader)(GLuint); 3.42 -void (*glAttachShader)(GLuint, GLuint); 3.43 -void (*glGetShaderiv)(GLuint, GLenum, GLint *); 3.44 -void (*glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); 3.45 -void (*glGetProgramiv)(GLuint, GLenum, GLint *); 3.46 -void (*glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); 3.47 -void (*glLinkProgram)(GLuint); 3.48 -void (*glShaderSource)(GLuint, GLsizei, const GLchar* *, const GLint *); 3.49 -void (*glUseProgram)(GLuint); 3.50 -GLint (*glGetUniformLocation)(GLuint, const GLchar *); 3.51 -void (*glUniform1f)(GLint, GLfloat); 3.52 -void (*glUniform2f)(GLint, GLfloat, GLfloat); 3.53 -void (*glUniform3f)(GLint, GLfloat, GLfloat, GLfloat); 3.54 -void (*glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); 3.55 -void (*glUniform1i)(GLint, GLint); 3.56 -void (*glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *); 3.57 -GLint (*glGetAttribLocation)(GLuint, const GLchar *); 3.58 -void (*glVertexAttrib3f)(GLint, GLfloat, GLfloat, GLfloat); 3.59 - 3.60 void init_sdr(void) 3.61 { 3.62 - glCreateProgram = glXGetProcAddress("glCreateProgramObjectARB"); 3.63 - glCreateShader = glXGetProcAddress("glCreateShaderObjectARB"); 3.64 - glDeleteProgram = glXGetProcAddress("glDeleteObjectARB"); 3.65 - glDeleteShader = glXGetProcAddress("glDeleteObjectARB"); 3.66 - glCompileShader = glXGetProcAddress("glCompileShaderARB"); 3.67 - glAttachShader = glXGetProcAddress("glAttachObjectARB"); 3.68 - glGetShaderiv = glXGetProcAddress("glGetObjectParameterivARB"); 3.69 - glGetShaderInfoLog = glXGetProcAddress("glGetInfoLogARB"); 3.70 - glGetProgramiv = glXGetProcAddress("glGetObjectParameterivARB"); 3.71 - glGetProgramInfoLog = glXGetProcAddress("glGetInfoLogARB"); 3.72 - glLinkProgram = glXGetProcAddress("glLinkProgramARB"); 3.73 - glShaderSource = glXGetProcAddress("glShaderSourceARB"); 3.74 - glUseProgram = glXGetProcAddress("glUseProgramObjectARB"); 3.75 - glGetUniformLocation = glXGetProcAddress("glGetUniformLocationARB"); 3.76 - glUniform1f = glXGetProcAddress("glUniform1fARB"); 3.77 - glUniform2f = glXGetProcAddress("glUniform2fARB"); 3.78 - glUniform3f = glXGetProcAddress("glUniform3fARB"); 3.79 - glUniform4f = glXGetProcAddress("glUniform4fARB"); 3.80 - glUniform1i = glXGetProcAddress("glUniform1iARB"); 3.81 - glUniformMatrix4fv = glXGetProcAddress("glUniformMatrix4fvARB"); 3.82 - glGetAttribLocation = glXGetProcAddress("glGetAttribLocationARB"); 3.83 - glVertexAttrib3f = glXGetProcAddress("glVertexAttrib3fARB"); 3.84 + glewInit(); 3.85 } 3.86 -#else 3.87 -void init_sdr(void) {} 3.88 -#endif 3.89 3.90 unsigned int create_vertex_shader(const char *src) 3.91 {