Skip to content

Instantly share code, notes, and snippets.

@oknauta
Created July 3, 2024 21:30
Show Gist options
  • Save oknauta/86428b5ef825c8ae63c4e889521a1711 to your computer and use it in GitHub Desktop.
Save oknauta/86428b5ef825c8ae63c4e889521a1711 to your computer and use it in GitHub Desktop.
Window in C++ GLFW
// File: `glfw_window.cpp`
// Date: `2024-07-03`
#include <GLFW/glfw3.h>
#include <GL/glut.h>
int main()
{
// Initializing glfw
glfwInit();
// Creating window
GLFWwindow *window = glfwCreateWindow(800, 600, "Simple Window", NULL, NULL);
// If fails, do something
if(!window)
{
glfwTerminate();
return EXIT_FAILURE;
}
// Window loop
while(!glfwWindowShouldClose(window))
{
// Treating the events
// Like the `quit button`
glfwPollEvents();
}
// Destroying window
glfwDestroyWindow(window);
// Terminating glfw
glfwTerminate();
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment