DragonYTPastesWork

Simple OpenGL Window

May 10th, 2022
9,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <glad/glad.h>
  2. #include <GLFW/glfw3.h>
  3.  
  4. #include <iostream>
  5.  
  6. int main() {
  7.     glfwInit();
  8.     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  9.     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  10.     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  11.  
  12.     GLFWwindow* window = glfwCreateWindow(800, 600, "this is NOT a window!", NULL, NULL);
  13.     if (window == NULL) {
  14.         std::cout << "Failed to create GLFW window" << std::endl;
  15.         glfwTerminate();
  16.         return -1;
  17.     }
  18.  
  19.     glfwMakeContextCurrent(window);
  20.  
  21.     if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
  22.         std::cout << "Failed to initialize GLAD" << std::endl;
  23.         return -1;
  24.     }
  25.  
  26.     while (!glfwWindowShouldClose(window)) {
  27.        
  28.         glfwPollEvents();
  29.  
  30.         glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
  31.         glClear(GL_COLOR_BUFFER_BIT);
  32.  
  33.         glfwSwapBuffers(window);
  34.     }
  35.  
  36.     glfwTerminate();
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment