Initial commit - some engine bugs stopping compiling
This commit is contained in:
99
third-party/glad/test/c/run/gl/debug/001/test.c
vendored
Normal file
99
third-party/glad/test/c/run/gl/debug/001/test.c
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Core 3.3 debug profile using glfw to load
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" --extensions="" c --debug
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
static int pre = 0;
|
||||
static int post = 0;
|
||||
|
||||
static void pre_call_gl_callback(const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
ASSERT(strcmp(name, "glClear") == 0, "got %s expected glClear", name);
|
||||
ASSERT(apiproc != NULL, "glClear proc is null");
|
||||
ASSERT((void*) apiproc == (void*) glad_glClear, "passed in proc is not actual implementation");
|
||||
ASSERT((void*) apiproc != (void*) glad_debug_glClear, "passed in proc is debug implementation");
|
||||
ASSERT(len_args == 1, "expected only one argument, got %d", len_args);
|
||||
|
||||
++pre;
|
||||
|
||||
va_list args;
|
||||
va_start(args, len_args);
|
||||
int value = va_arg(args, int);
|
||||
va_end(args);
|
||||
|
||||
ASSERT(value == GL_COLOR_BUFFER_BIT || value == GL_DEPTH_BUFFER_BIT, "invalid argument in debug callback");
|
||||
}
|
||||
|
||||
static void post_call_gl_callback(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
ASSERT(strcmp(name, "glClear") == 0, "got %s expected glClear", name);
|
||||
ASSERT(apiproc != NULL, "glClear proc is null");
|
||||
ASSERT((void*) apiproc == (void*) glad_glClear, "passed in proc is not actual implementation");
|
||||
ASSERT((void*) apiproc != (void*) glad_debug_glClear, "passed in proc is debug implementation");
|
||||
ASSERT(len_args == 1, "expected only one argument, got %d", len_args);
|
||||
ASSERT(ret == NULL, "return value not null");
|
||||
|
||||
++post;
|
||||
|
||||
va_list args;
|
||||
va_start(args, len_args);
|
||||
int value = va_arg(args, int);
|
||||
va_end(args);
|
||||
|
||||
ASSERT(value == GL_COLOR_BUFFER_BIT || value == GL_DEPTH_BUFFER_BIT, "invalid argument in debug callback");
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoadGL(glfwGetProcAddress);
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(GLAD_GL_VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
|
||||
gladSetGLPreCallback(pre_call_gl_callback);
|
||||
gladSetGLPostCallback(post_call_gl_callback);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* make sure install/uninstall is working as expected */
|
||||
gladUninstallGLDebug();
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
gladInstallGLDebug();
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
ASSERT(pre == 2, "pre callback called %d times, expected twice", pre);
|
||||
ASSERT(post == 2, "post callback called %d times, expected twice", post);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
45
third-party/glad/test/c/run/gl/default/001/test.c
vendored
Normal file
45
third-party/glad/test/c/run/gl/default/001/test.c
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Core 3.3 profile using glfw to load
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoadGL(glfwGetProcAddress);
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(GLAD_GL_VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(GLAD_GL_KHR_debug == 1, "KHR_debug not available");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
45
third-party/glad/test/c/run/gl/default/002/test.c
vendored
Normal file
45
third-party/glad/test/c/run/gl/default/002/test.c
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Core 3.3 profile using internal loader to load
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --loader
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoaderLoadGL();
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(GLAD_GL_VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(GLAD_GL_KHR_debug == 1, "KHR_debug not available");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
third-party/glad/test/c/run/gl/default/003/test.c
vendored
Normal file
44
third-party/glad/test/c/run/gl/default/003/test.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 2.1 using internal loader to load
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core=2.1" c --loader
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoaderLoadGL();
|
||||
ASSERT(version >= 2001, "glad version %d < 2001", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 2, "glad major version %d < 2", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 2 || GLAD_VERSION_MINOR(version) >= 1, "glad minor version %d < 1", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(GLAD_GL_VERSION_2_1, "GL_VERSION_2_1 not set");
|
||||
ASSERT(GLAD_GL_KHR_debug == 1, "KHR_debug not available");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
59
third-party/glad/test/c/run/gl/mx/001/test.c
vendored
Normal file
59
third-party/glad/test/c/run/gl/mx/001/test.c
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* MX Core 3.3 profile using glfw to load
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --mx
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
GLFWwindow* create_window(void) {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
return window;
|
||||
}
|
||||
|
||||
void run(GLFWwindow *window) {
|
||||
GladGLContext context = {0};
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoadGLContext(&context, glfwGetProcAddress);
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(context.VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(context.KHR_debug, "KHR_debug not available");
|
||||
|
||||
context.Viewport(0, 0, WIDTH, HEIGHT);
|
||||
context.ClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
context.Clear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
GLFWwindow *window1 = create_window();
|
||||
GLFWwindow *window2 = create_window();
|
||||
|
||||
run(window1);
|
||||
run(window2);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
59
third-party/glad/test/c/run/gl/mx/002/test.c
vendored
Normal file
59
third-party/glad/test/c/run/gl/mx/002/test.c
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* MX Core 3.3 profile using internal loader
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --mx --loader
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
GLFWwindow* create_window(void) {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
return window;
|
||||
}
|
||||
|
||||
void run(GLFWwindow *window) {
|
||||
GladGLContext context = {0};
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoaderLoadGLContext(&context);
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(context.VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(context.KHR_debug, "KHR_debug not available");
|
||||
|
||||
context.Viewport(0, 0, WIDTH, HEIGHT);
|
||||
context.ClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
context.Clear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
GLFWwindow *window1 = create_window();
|
||||
GLFWwindow *window2 = create_window();
|
||||
|
||||
run(window1);
|
||||
run(window2);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
63
third-party/glad/test/c/run/gl/mx/003/test_disabled.c
vendored
Normal file
63
third-party/glad/test/c/run/gl/mx/003/test_disabled.c
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* MX Core 3.3 profile using glfw to load.
|
||||
* Using MX Global for GL calls.
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --mx --mx-global
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
GLFWwindow* create_window(void) {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
return window;
|
||||
}
|
||||
|
||||
void run(GLFWwindow *window) {
|
||||
GladGLContext context = {0};
|
||||
context.userptr = (void*) &context;
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoadGLContext(&context, glfwGetProcAddress);
|
||||
ASSERT(memcmp(&context, gladGetGLContext(), sizeof(GladGLContext)) == 0, "invalid global context");
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(context.VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(context.KHR_debug, "KHR_debug not available");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
GLFWwindow *window1 = create_window();
|
||||
GLFWwindow *window2 = create_window();
|
||||
|
||||
run(window1);
|
||||
run(window2);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
63
third-party/glad/test/c/run/gl/mx/004/test_disabled.c
vendored
Normal file
63
third-party/glad/test/c/run/gl/mx/004/test_disabled.c
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* MX Core 3.3 profile using internal loader.
|
||||
* Using MX Global for GL calls.
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --mx --mx-global --loader
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
GLFWwindow* create_window(void) {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
return window;
|
||||
}
|
||||
|
||||
void run(GLFWwindow *window) {
|
||||
GladGLContext context = {0};
|
||||
context.userptr = (void*) &context;
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoaderLoadGLContext(&context);
|
||||
ASSERT(memcmp(&context, gladGetGLContext(), sizeof(GladGLContext)) == 0, "invalid global context");
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(context.VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(context.KHR_debug, "KHR_debug not available");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
GLFWwindow *window1 = create_window();
|
||||
GLFWwindow *window2 = create_window();
|
||||
|
||||
run(window1);
|
||||
run(window2);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
61
third-party/glad/test/c/run/gl/mx/005/test_disabled.c
vendored
Normal file
61
third-party/glad/test/c/run/gl/mx/005/test_disabled.c
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* MX Core 3.3 profile using glfw to load.
|
||||
* Using MX Global for GL calls and the global context.
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --mx --mx-global
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
GLFWwindow* create_window(void) {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
return window;
|
||||
}
|
||||
|
||||
void run(GLFWwindow *window) {
|
||||
GladGLContext *context = gladGetGLContext();
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoadGL(glfwGetProcAddress);
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(context->VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(context->KHR_debug, "KHR_debug not available");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
GLFWwindow *window1 = create_window();
|
||||
GLFWwindow *window2 = create_window();
|
||||
|
||||
run(window1);
|
||||
run(window2);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
61
third-party/glad/test/c/run/gl/mx/006/test_disabled.c
vendored
Normal file
61
third-party/glad/test/c/run/gl/mx/006/test_disabled.c
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* MX Core 3.3 profile using internal loader.
|
||||
* Using MX Global for GL calls and the global context.
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --mx --mx-global --loader
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
GLFWwindow* create_window(void) {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
return window;
|
||||
}
|
||||
|
||||
void run(GLFWwindow *window) {
|
||||
GladGLContext *context = gladGetGLContext();
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoaderLoadGL();
|
||||
ASSERT(version >= 3003, "glad version %d < 3003", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "glad major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 3, "glad minor version %d < 3", GLAD_VERSION_MINOR(version));
|
||||
ASSERT(context->VERSION_3_3, "GL_VERSION_3_3 not set");
|
||||
ASSERT(context->KHR_debug, "KHR_debug not available");
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
GLFWwindow *window1 = create_window();
|
||||
GLFWwindow *window2 = create_window();
|
||||
|
||||
run(window1);
|
||||
run(window2);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
65
third-party/glad/test/c/run/gl/on-demand+debug/001/test.c
vendored
Normal file
65
third-party/glad/test/c/run/gl/on-demand+debug/001/test.c
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Core 3.3 on demand debug profile using glad to load
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" --extensions="" c --debug --on-demand --loader
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
static int pre = 0;
|
||||
static int post = 0;
|
||||
|
||||
static void pre_call_gl_callback(const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
(void) name;
|
||||
(void) apiproc;
|
||||
(void) len_args;
|
||||
++pre;
|
||||
}
|
||||
|
||||
static void post_call_gl_callback(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
(void) ret;
|
||||
(void) name;
|
||||
(void) apiproc;
|
||||
(void) len_args;
|
||||
++post;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
|
||||
gladSetGLPreCallback(pre_call_gl_callback);
|
||||
gladSetGLPostCallback(post_call_gl_callback);
|
||||
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
ASSERT(pre == 2, "pre callback called %d times, expected twice", pre);
|
||||
ASSERT(post == 2, "post callback called %d times, expected twice", post);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
67
third-party/glad/test/c/run/gl/on-demand+debug/002/test.c
vendored
Normal file
67
third-party/glad/test/c/run/gl/on-demand+debug/002/test.c
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Core 3.3 on demand debug profile using glfw to load
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" --extensions="" c --debug --on-demand
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
static int pre = 0;
|
||||
static int post = 0;
|
||||
|
||||
static void pre_call_gl_callback(const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
(void) name;
|
||||
(void) apiproc;
|
||||
(void) len_args;
|
||||
++pre;
|
||||
}
|
||||
|
||||
static void post_call_gl_callback(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
(void) ret;
|
||||
(void) name;
|
||||
(void) apiproc;
|
||||
(void) len_args;
|
||||
++post;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
gladSetGLOnDemandLoader(glfwGetProcAddress);
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
|
||||
gladSetGLPreCallback(pre_call_gl_callback);
|
||||
gladSetGLPostCallback(post_call_gl_callback);
|
||||
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
ASSERT(pre == 2, "pre callback called %d times, expected twice", pre);
|
||||
ASSERT(post == 2, "post callback called %d times, expected twice", post);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
40
third-party/glad/test/c/run/gl/on-demand/001/test.c
vendored
Normal file
40
third-party/glad/test/c/run/gl/on-demand/001/test.c
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Core 3.3 profile using glfw to load on-demand
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --on-demand
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
gladSetGLOnDemandLoader(glfwGetProcAddress);
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
38
third-party/glad/test/c/run/gl/on-demand/002/test.c
vendored
Normal file
38
third-party/glad/test/c/run/gl/on-demand/002/test.c
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Core 3.3 profile builtin on-demand loader
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="gl:core" c --on-demand --loader
|
||||
* COMPILE: $GCC -Wno-pedantic $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl -lglfw
|
||||
* RUN: $tmp/test
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
#define WIDTH 50
|
||||
#define HEIGHT 50
|
||||
|
||||
int main(void) {
|
||||
ASSERT(glfwInit(), "glfw init failed");
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "<test>", NULL, NULL);
|
||||
ASSERT(window != NULL, "glfw window creation failed");
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
102
third-party/glad/test/c/run/wgl/default/001/test.c
vendored
Normal file
102
third-party/glad/test/c/run/wgl/default/001/test.c
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Full WGL, see examples/c/wgl.c for more information
|
||||
*
|
||||
* GLAD: $GLAD --out-path=$tmp --api="wgl,gl:core" c --loader --alias
|
||||
* COMPILE: $MINGW_GCC -Wno-pedantic $test -o $tmp/test.exe -I$tmp/include $tmp/src/wgl.c $tmp/src/gl.c -lgdi32 -lopengl32
|
||||
* RUN: $WINE $tmp/test.exe
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <glad/wgl.h>
|
||||
#include <glad/gl.h>
|
||||
|
||||
|
||||
#define ASSERT(expression, message, args...) if(!(expression)) { fprintf(stderr, "%s(%d): " message "\n", __FILE__, __LINE__, ##args); exit(1); }
|
||||
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
WNDCLASSEX wcex = { };
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = DefWindowProc;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
|
||||
wcex.lpszClassName = _T("<test>");
|
||||
|
||||
ATOM wndclass = RegisterClassEx(&wcex);
|
||||
|
||||
HWND hWnd = CreateWindow(MAKEINTATOM(wndclass), _T("<test>"),
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0, 0,
|
||||
50, 50,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
ASSERT(hWnd != NULL, "window creation failed");
|
||||
|
||||
HDC hdc = GetDC(hWnd);
|
||||
ASSERT(hdc != NULL, "failed to get window's device context");
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd = { };
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 32;
|
||||
pfd.cDepthBits = 32;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
int format = ChoosePixelFormat(hdc, &pfd);
|
||||
ASSERT(format != 0 && SetPixelFormat(hdc, format, &pfd) != FALSE, "failed to set pixel format");
|
||||
|
||||
HGLRC temp_context = wglCreateContext(hdc);
|
||||
ASSERT(temp_context != NULL, "failed to create initial rendering context");
|
||||
|
||||
wglMakeCurrent(hdc, temp_context);
|
||||
|
||||
int wgl_version = gladLoaderLoadWGL(hdc);
|
||||
ASSERT(wgl_version >= 1000, "failed to load WGL");
|
||||
ASSERT(GLAD_VERSION_MAJOR(wgl_version) >= 1, "wgl major version %d < 1", GLAD_VERSION_MAJOR(wgl_version));
|
||||
ASSERT(GLAD_VERSION_MINOR(wgl_version) >= 0, "wgl minor version %d < 0", GLAD_VERSION_MINOR(wgl_version));
|
||||
|
||||
int attributes[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
|
||||
WGL_CONTEXT_FLAGS_ARB,
|
||||
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
HGLRC opengl_context = wglCreateContextAttribsARB(hdc, NULL, attributes);
|
||||
ASSERT(opengl_context != NULL, "failed to create final rendering context");
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(temp_context);
|
||||
wglMakeCurrent(hdc, opengl_context);
|
||||
|
||||
int version = gladLoaderLoadGL();
|
||||
ASSERT(version >= 3002, "glad version %d < 32", version);
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) >= 3, "gl major version %d < 3", GLAD_VERSION_MAJOR(version));
|
||||
ASSERT(GLAD_VERSION_MAJOR(version) > 3 || GLAD_VERSION_MINOR(version) >= 2, "gl minor version too small %d < 2", GLAD_VERSION_MINOR(version));
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
SwapBuffers(hdc);
|
||||
|
||||
wglDeleteContext(opengl_context);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user