Add debug extension support to sharing test

This commit is contained in:
Camilla Berglund 2016-09-21 18:12:36 +02:00
parent 38aae024cd
commit 9017eaee08
2 changed files with 30 additions and 1 deletions

View File

@ -31,7 +31,7 @@ add_executable(cursor cursor.c ${GLAD})
add_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD} ${GLAD}) add_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD} ${GLAD})
add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${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(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT} ${GLAD})
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD}) add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD})
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD}) add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD})

View File

@ -34,6 +34,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "getopt.h"
#include "linmath.h" #include "linmath.h"
static const char* vertex_shader_text = 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); 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) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{ {
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) 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 main(int argc, char** argv)
{ {
int ch;
GLFWwindow* windows[2]; GLFWwindow* windows[2];
GLuint texture, program, vertex_buffer; GLuint texture, program, vertex_buffer;
GLint mvp_location, vpos_location, color_location, texture_location; GLint mvp_location, vpos_location, color_location, texture_location;
@ -87,6 +100,16 @@ int main(int argc, char** argv)
if (!glfwInit()) if (!glfwInit())
exit(EXIT_FAILURE); 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_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
@ -109,6 +132,12 @@ int main(int argc, char** argv)
// pointers should be re-usable between them // pointers should be re-usable between them
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 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 // Create the OpenGL objects inside the first context, created above
// All objects will be shared with the second context, created below // All objects will be shared with the second context, created below
{ {