Created
March 17, 2020 04:48
-
-
Save sardap/0821af8a59c3729642b812f0ec019e6e to your computer and use it in GitHub Desktop.
Open window openGL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <glad/glad.h> | |
#include <GLFW/glfw3.h> | |
void framebuffer_size_callback(GLFWwindow* window, int width, int height) | |
{ | |
glViewport(0, 0, width, height); | |
} | |
int main() | |
{ | |
glfwInit(); | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); | |
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | |
// NEEDED FOPR MACS | |
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); | |
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL); | |
if (window == NULL) | |
{ | |
std::cout << "Failed to create GLFW window" << std::endl; | |
glfwTerminate(); | |
return -1; | |
} | |
glfwMakeContextCurrent(window); | |
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) | |
{ | |
std::cout << "Failed to initialize GLAD" << std::endl; | |
return -1; | |
} | |
glViewport(0, 0, 800, 600); | |
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); | |
while (!glfwWindowShouldClose(window)) | |
{ | |
glfwSwapBuffers(window); | |
glfwPollEvents(); | |
} | |
glfwTerminate(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment