From 8d28b81b89e2010ca1034a12d825ae7b46176a04 Mon Sep 17 00:00:00 2001 From: k Date: Fri, 6 Dec 2024 12:46:38 -0500 Subject: [PATCH] Basic Window --- src/main.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bc237c7..3f26e48 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,40 @@ -#include +#include #include +#include -int main(void){ +#define UNUSED(x) (void)(x) + +void framebuffer_size_callback(GLFWwindow* window, int width, int height); + +int main(void) { + int tmp = 0; + + glfwInit(); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + + GLFWwindow *window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL); + assert(window != NULL && "Window Failed"); + glfwMakeContextCurrent(window); + + tmp = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); + assert(tmp && "Failed to init glad"); + + glViewport(0, 0, 800, 600); + glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); + + while(!glfwWindowShouldClose(window)) + { + glfwSwapBuffers(window); + glfwPollEvents(); + } + + glfwTerminate(); return 0; } + +void framebuffer_size_callback(GLFWwindow* window, int width, int height) { + UNUSED(window); + glViewport(0, 0, width, height); +}