#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <bits/stdc++.h>
void HandleInput(GLFWwindow *window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
{
glfwSetWindowShouldClose(window, true);
}
}
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "First Window", NULL, NULL);
if (window == NULL)
{
std::cout << "Somethong wrong happen" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// INIT GLEW
glewExperimental = true;
if (glewInit() != GLEW_OK)
{
std::cout << "INIT GLEW FAIL" << std::endl;
glfwTerminate();
return -1;
}
glViewport(0, 0, 800, 600);
while (!glfwWindowShouldClose(window))
{
HandleInput(window);
glClearColor(0.5, 0.2, 0.3, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
}
发表评论