diff options
| -rw-r--r-- | README.md | 15 | ||||
| -rw-r--r-- | main.c | 31 |
2 files changed, 45 insertions, 1 deletions
@@ -1,2 +1,15 @@ # opentest -Bloon test + +Sample OpenGL window example using GLFW. + +Compile on macOS: + +``` +clang main.c -o ogl_example -lglfw -framework OpenGL +``` + +Run: + +``` +./ogl_example +``` @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <GLFW/glfw3.h> + +int main(void) +{ + if (!glfwInit()) { + fprintf(stderr, "Failed to initialize GLFW\n"); + return 1; + } + + GLFWwindow *window = glfwCreateWindow(640, 480, "Hello OpenGL", NULL, NULL); + if (!window) { + fprintf(stderr, "Failed to create window\n"); + glfwTerminate(); + return 1; + } + + glfwMakeContextCurrent(window); + + while (!glfwWindowShouldClose(window)) { + glClear(GL_COLOR_BUFFER_BIT); + + glfwSwapBuffers(window); + + glfwPollEvents(); + } + + glfwDestroyWindow(window); + glfwTerminate(); + return 0; +} |
