mirror of
https://github.com/glfw/glfw.git
synced 2024-11-15 02:34:36 +00:00
Improved usercontext.c test
This commit is contained in:
parent
f2806aa9ab
commit
d01ad1a78d
@ -1,11 +1,19 @@
|
||||
#include <glad/gl.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)
|
||||
{
|
||||
GLFWwindow* window;
|
||||
GLFWusercontext* usercontext;
|
||||
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
/* Initialize the library */
|
||||
if (!glfwInit())
|
||||
return -1;
|
||||
@ -26,16 +34,44 @@ int main(void)
|
||||
usercontext = glfwCreateUserContext(window);
|
||||
if (!usercontext)
|
||||
{
|
||||
fprintf(stderr, "Failed to create user context\n");
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* set the user context current */
|
||||
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 */
|
||||
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 );
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user