Skip to content

Commit

Permalink
add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
jojolebarjos committed Dec 29, 2016
1 parent d3048ad commit 5c4c39d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions cpp/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define HEIGHT 768
#define MULTISAMPLING 16
#define FPS 0
#define DEBUG 1

// GLEW (http://glew.sourceforge.net/)
#define GLEW_STATIC
Expand Down Expand Up @@ -45,6 +46,12 @@
// Skinning code
#include "skinning.h"

// Debug log callback
#if DEBUG
static void APIENTRY debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, GLchar const * message, void const * userParam) {
std::cout << message << std::endl;
}
#endif

// Program entry point
int main(int argc, char** argv) {
Expand Down Expand Up @@ -109,6 +116,9 @@ int main(int argc, char** argv) {
// Create OpenGL context
glfwInit();
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
#if DEBUG
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, 1);
#endif
#if MULTISAMPLING
glfwWindowHint(GLFW_SAMPLES, MULTISAMPLING);
#endif
Expand All @@ -119,6 +129,15 @@ int main(int argc, char** argv) {
glewExperimental = GL_TRUE;
glewInit();

// Enable debug callback
#if DEBUG
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(debugCallback, nullptr);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, GL_FALSE);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
#endif

// Create vertex buffer
GLuint vertices;
glGenBuffers(1, &vertices);
Expand Down
2 changes: 1 addition & 1 deletion cpp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LIB += -lOpenMeshTools -lOpenMeshCore
ifeq ($(OS),Windows_NT)
LIB += -Wl,-Bstatic -lglew32 -Wl,-Bdynamic -lglfw3 -lopengl32 -lglu32 -lgdi32
else
LIB += -lGLEW -lglfw3 -lpthread -lGL -lXrandr -lGLU -lX11 -lXxf86vm -lXi
LIB += -lGLEW -lglfw3 -lpthread -lGL -lXrandr -lGLU -lX11 -lXxf86vm -lXi -ldl -lXinerama -lXcursor
endif

%.o : %.cpp $(INC)
Expand Down

0 comments on commit 5c4c39d

Please sign in to comment.