OpenGL教程1:打开一个窗口 Posted on 2016-11-06 | Edited on 2018-10-17 | In uncategorized 12345678910111213141516171819202122232425262728293031323334353637383940414243// GLFW#include <iostream>#include <GLFW/glfw3.h>int main(int argc, const char * argv[]) { //初始glfw glfwInit(); //glfw 设置 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // only in mac glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // 建立一个窗口 GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", nullptr, nullptr); if (window == nullptr) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } // 上下文 glfwMakeContextCurrent(window); while(!glfwWindowShouldClose(window)) { glfwPollEvents(); glfwSwapBuffers(window); } glfwTerminate(); return 0;}