#include<stdio.h>
#include<glad/glad.h>
#include<GLFW/glfw3.h>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
int main()
{
if (GL_FALSE == glfwInit())
{
printf("Iniitialize glfw failer\n");
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "OPENGL_WINDOW", NULL, NULL);
if (NULL == window)
{
printf("Failed to create GLFW window\n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
printf("Falied to initialize GLAD\n");
}
glViewport(0, 0, 800, 600);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
while (!glfwWindowShouldClose(window))
{
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
版权声明:本文为weixin_43213429原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。