add init draw and frame buffer size callback

This commit is contained in:
Luca Conte 2025-03-05 22:11:10 +01:00
parent 41c7355817
commit bbec4f6a26
1 changed files with 19 additions and 0 deletions

View File

@ -2,6 +2,18 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h> #include <stdio.h>
void init(void) {
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
}
void draw(void) {
glClear(GL_COLOR_BUFFER_BIT);
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
}
int main(int argc, char const *argv[]) int main(int argc, char const *argv[])
{ {
glfwInit(); glfwInit();
@ -15,9 +27,16 @@ int main(int argc, char const *argv[])
glfwTerminate(); glfwTerminate();
return 1; return 1;
} }
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
glewInit();
init();
while (!glfwWindowShouldClose(window)) { while (!glfwWindowShouldClose(window)) {
draw();
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }