Commit ef7b7b5f authored by Doug Binks's avatar Doug Binks Committed by Degrande Samuel
Browse files

Improved usercontext.c test

parent d8a1de0e
#include <glad/gl.h> #include <glad/gl.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h>
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
int main(void) int main(void)
{ {
GLFWwindow* window; GLFWwindow* window;
GLFWusercontext* usercontext; GLFWusercontext* usercontext;
glfwSetErrorCallback(error_callback);
/* Initialize the library */ /* Initialize the library */
if (!glfwInit()) if (!glfwInit())
return -1; return -1;
...@@ -26,16 +34,44 @@ int main(void) ...@@ -26,16 +34,44 @@ int main(void)
usercontext = glfwCreateUserContext(window); usercontext = glfwCreateUserContext(window);
if (!usercontext) if (!usercontext)
{ {
fprintf(stderr, "Failed to create user context\n");
glfwTerminate(); glfwTerminate();
return -1; return -1;
} }
/* set the user context current */ /* set the user context current */
glfwMakeUserContextCurrent(usercontext); glfwMakeUserContextCurrent(usercontext);
if (glfwGetCurrentContext()!=NULL)
{
fprintf(stderr, "Current glfw window context not NULL after glfwMakeUserContextCurrent\n");
glfwTerminate();
return -1;
}
if (glfwGetCurrentUserContext()!=usercontext)
{
fprintf(stderr, "Current user context not correct after glfwMakeUserContextCurrent\n");
glfwTerminate();
return -1;
}
/* set the window context current */ /* set the window context current */
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
if ( glfwGetCurrentUserContext() != NULL )
{
fprintf(stderr, "Current user context not NULL after glfwMakeContextCurrent\n");
glfwTerminate();
return -1;
}
if ( glfwGetCurrentContext() != window )
{
fprintf(stderr, "Current glfw window context not correct after glfwMakeContextCurrent\n");
glfwTerminate();
return -1;
}
glClearColor( 0.4f, 0.3f, 0.4f, 0.0f ); glClearColor( 0.4f, 0.3f, 0.4f, 0.0f );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment