setup: switched from glut to glfw as windowing backend

This commit is contained in:
2025-08-21 22:21:21 +02:00
parent bc1940fb66
commit 255c7da8e5
2 changed files with 46 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <GLFW/glfw3.h>
#include <cstdio>
void display() {
@@ -20,20 +20,54 @@ void display() {
glViewport(0, 0, width, height);
}*/
void processInput(GLFWwindow *window)
{
if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800, 600);
glutCreateWindow("OpenGL Example");
GLFWwindow* window;
if (!glfwInit())
return -1;
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
GLenum err = glewInit();
if (GLEW_OK != err) {
fprintf(stderr, "GLEW error: %s\n", glewGetErrorString(err));
return 1;
}
glViewport(0, 0, 800, 600);
//glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glutDisplayFunc(display);
glutMainLoop();
return 0;
while (!glfwWindowShouldClose(window))
{
processInput(window);
/* Render here */
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
/* Poll for and process events */
glfwPollEvents();
glfwSwapBuffers(window);
}
glfwTerminate();
}