From 9017eaee08b0bf401188812d666fe81a5733d66f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 21 Sep 2016 18:12:36 +0200 Subject: [PATCH] Add debug extension support to sharing test --- tests/CMakeLists.txt | 2 +- tests/sharing.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 205ec377..9a703a8c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,7 +31,7 @@ add_executable(cursor cursor.c ${GLAD}) add_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD} ${GLAD}) add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${GLAD}) -add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${GLAD}) +add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${GETOPT} ${GLAD}) add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT} ${GLAD}) add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD}) add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD}) diff --git a/tests/sharing.c b/tests/sharing.c index 1d630183..be1bcd9d 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -34,6 +34,7 @@ #include #include +#include "getopt.h" #include "linmath.h" static const char* vertex_shader_text = @@ -68,6 +69,17 @@ static void error_callback(int error, const char* description) fprintf(stderr, "Error: %s\n", description); } +void APIENTRY debug_callback(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const GLchar* message, + const void* user) +{ + fprintf(stderr, "Error: %s\n", message); +} + static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) @@ -76,6 +88,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, int main(int argc, char** argv) { + int ch; GLFWwindow* windows[2]; GLuint texture, program, vertex_buffer; GLint mvp_location, vpos_location, color_location, texture_location; @@ -87,6 +100,16 @@ int main(int argc, char** argv) if (!glfwInit()) exit(EXIT_FAILURE); + while ((ch = getopt(argc, argv, "d")) != -1) + { + switch (ch) + { + case 'd': + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); + break; + } + } + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); @@ -109,6 +132,12 @@ int main(int argc, char** argv) // pointers should be re-usable between them gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); + if (GLAD_GL_ARB_debug_output) + { + glDebugMessageCallbackARB(debug_callback, NULL); + glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); + } + // Create the OpenGL objects inside the first context, created above // All objects will be shared with the second context, created below {