Merge branch 'master' of goat:git/laserbrain_demo
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Mon, 22 Jan 2018 12:45:15 +0000 (04:45 -0800)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Mon, 22 Jan 2018 12:45:15 +0000 (04:45 -0800)
1  2 
Makefile
src/opengl.c

diff --combined Makefile
+++ b/Makefile
@@@ -18,11 -18,11 +18,11 @@@ incpath = -Isrc -Isrc/machine -I/usr/lo
  
  warn = -pedantic -Wall
  
- CFLAGS = $(warn) $(opt) $(dbg) $(incpath)
- CXXFLAGS = -std=c++11 $(warn) $(opt) $(dbg) $(incpath)
+ CFLAGS = $(warn) $(opt) $(dbg) $(incpath) -fopenmp
+ CXXFLAGS = -std=c++11 $(warn) $(opt) $(dbg) $(incpath) -fopenmp
  LDFLAGS = $(libpath) -ldrawtext $(libgl_$(sys)) $(libal_$(sys)) -lm -lgmath -lvmath \
                  -limago -lresman -lpthread -lassimp -ltreestore -lgoatvr \
-                 `pkg-config --libs sdl2 freetype2` -lpng -ljpeg -lz -lvorbisfile
+                 `pkg-config --libs sdl2 freetype2` -lpng -ljpeg -lz -lvorbisfile -lgomp
  
  sys = $(shell uname -s | sed 's/MINGW.*/mingw/')
  libgl_Linux = -lGL -lGLU -lGLEW
@@@ -32,7 -32,7 +32,7 @@@ libgl_mingw = -lopengl32 -lglu32 -lglew
  
  libal_Linux = -lopenal
  libal_Darwin = -framework OpenAL
 -libal_mingw = -lOpenAL32
 +libal_mingw = -lopenal
  
  ifeq ($(sys), mingw)
        bin = demo.exe
diff --combined src/opengl.c
index 0000000,9fe7ea3..796144c
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,104 +1,106 @@@
+ #include "opengl.h"
+ #include "logger.h"
 -static void gldebug_logger(unsigned int src, unsigned int type, unsigned int id,
 -              unsigned int severity, int len, const char *msg, const void *cls);
++
++static void GLAPIENTRY gldebug_logger(GLenum src, GLenum type, GLuint id, GLenum severity,
++              GLsizei len, const char *msg, const void *cls);
++
+ static const char *gldebug_srcstr(unsigned int src);
+ static const char *gldebug_typestr(unsigned int type);
+ static const char *gldebug_sevstr(unsigned int sev);
+ struct GLCaps glcaps;
+ int init_opengl(void)
+ {
+       glewInit();
+       glcaps.debug = GLEW_ARB_debug_output;
+ #ifndef NDEBUG
+       if(glcaps.debug) {
+               info_log("Installing OpenGL debug callback\n");
+               glDebugMessageCallback(gldebug_logger, 0);
+       }
+ #endif
+       return 0;
+ }
 -static void gldebug_logger(unsigned int src, unsigned int type, unsigned int id,
 -              unsigned int severity, int len, const char *msg, const void *cls)
++static void GLAPIENTRY gldebug_logger(GLenum src, GLenum type, GLuint id, GLenum severity,
++              GLsizei len, const char *msg, const void *cls)
+ {
+       static const char *fmt = "[GLDEBUG] (%s) %s: %s\n";
+       switch(type) {
+       case GL_DEBUG_TYPE_ERROR:
+               error_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg);
+               break;
+       case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
+       case GL_DEBUG_TYPE_PORTABILITY:
+       case GL_DEBUG_TYPE_PERFORMANCE:
+               warning_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg);
+               break;
+       default:
+               debug_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg);
+       }
+ }
+ static const char *gldebug_srcstr(unsigned int src)
+ {
+       switch(src) {
+       case GL_DEBUG_SOURCE_API:
+               return "api";
+       case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
+               return "wsys";
+       case GL_DEBUG_SOURCE_SHADER_COMPILER:
+               return "sdrc";
+       case GL_DEBUG_SOURCE_THIRD_PARTY:
+               return "3rdparty";
+       case GL_DEBUG_SOURCE_APPLICATION:
+               return "app";
+       case GL_DEBUG_SOURCE_OTHER:
+               return "other";
+       default:
+               break;
+       }
+       return "unknown";
+ }
+ static const char *gldebug_typestr(unsigned int type)
+ {
+       switch(type) {
+       case GL_DEBUG_TYPE_ERROR:
+               return "error";
+       case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
+               return "deprecated";
+       case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
+               return "undefined behavior";
+       case GL_DEBUG_TYPE_PORTABILITY:
+               return "portability warning";
+       case GL_DEBUG_TYPE_PERFORMANCE:
+               return "performance warning";
+       case GL_DEBUG_TYPE_OTHER:
+               return "other";
+       default:
+               break;
+       }
+       return "unknown";
+ }
+ static const char *gldebug_sevstr(unsigned int sev)
+ {
+       switch(sev) {
+       case GL_DEBUG_SEVERITY_HIGH:
+               return "high";
+       case GL_DEBUG_SEVERITY_MEDIUM:
+               return "medium";
+       case GL_DEBUG_SEVERITY_LOW:
+               return "low";
+       default:
+               break;
+       }
+       return "unknown";
+ }