c++ - glfw3 窗口在随机时间后冻结
问题描述
我有一些基本的 glfw 和 opengl 代码没有按预期运行的问题。窗口仅在至少几秒钟后才完全冻结,有时甚至更多。
我已经评论了几乎所有的代码,只剩下很少的几行。
初始化函数是:
int Renderer::init(std::string scene_file_ , RenderOptions options_)
{
if(!glfwInit()){
std::cout<<"Problem with GLFW"<< std::endl;
glfwTerminate();
return -1;
}
window = glfwCreateWindow(640,480, "raytracer", NULL, NULL);
if(!window){
std::cout << "Problem with window " << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSwapInterval(2);
glewInit();
}
绘图循环是:
void Renderer::displayScene()
{
GLCall(glEnable(GL_DEPTH_TEST));
int width, height;
glfwGetFramebufferSize(window, &width, &height);
GLCall(glViewport(0,0,width, height));
GLCall(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
GLCall(glClearColor(0.2,0.5,0.2,1.0));
printf("drawing %d\n", temp_inc_test++);
glfwPollEvents();
glfwSwapBuffers(renderer.window);
}
窗口开始正常,背景颜色正确,然后在〜3秒到〜5分钟之间,程序停止,窗口变得无响应。我很确定我已经运行了一些完全一样的代码,并且运行了几个小时。我不明白。
有什么明显的吗?我忘了提:我在 linux Jessie 上使用 rasberry PI
解决方案
推荐阅读
- php - 如何上传带类的图像
- grails - 如何合并独立测试运行的覆盖率报告
- sql - How to get the nested child IDs from table using sql query
- python - Python SAML 身份验证
- telegram - 如何为电报建立自定义客户端?
- sap-fiori - 如何在 fiori 启动板中集成两个云应用程序
- angular - Angular Service Worker 不缓存发布请求
- angular - 您如何可靠地等待 cypress.io 测试中的页面空闲
- phonegap-plugins - PhoneGap 插件中的 ^ 对 spec 属性意味着什么?
- c++ - C ++如何读取java .class文件