【发布时间】:2015-05-18 02:32:54
【问题描述】:
我一直在尝试一些现代 OpenGL 教程,但我发现了一些似乎很奇怪的行为。这是代码,简化为(几乎)基本要素。
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
using std::cout;
using std::endl;
int main(){
std::cout << "Begin program" << std::endl;
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL", 0, 0); // Windowed
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE;
glewInit();
while(!glfwWindowShouldClose(window))
{
glfwSwapBuffers(window);
glfwPollEvents();
}
cout << "before glfwTerminate()" << endl;
glfwTerminate();
cout << "after glfwTerminate()" << endl; cout.flush();
std::cout << "End program" << std::endl;
return 0;
}
查看GLFW docs,对glfwTerminate()的调用应该不会退出程序,但在“before glfwTerminate()”之后没有任何内容输出到控制台,程序结束。
我使用的是 ArchLinux(刚刚更新),我尝试使用 xfce4 和 KDE(后者的最小安装,只是为了确保它不是 xfce4 问题)。
有人会提示发生了什么吗?
【问题讨论】:
标签: c++ eclipse opengl glfw glew