【问题标题】:Freeglut error: fgInitGL2: fghGenBuffers is NULLFreeglut 错误:fgInitGL2:fghGenBuffers 为 NULL
【发布时间】:2015-02-26 15:36:18
【问题描述】:

我正在将一个程序从 OSX 转移到 Windows,但一个错误仍然困扰着我。该错误发生在 gdb 的运行时。编译和链接一切正常。

freeglut (C:\path\to\file.exe): fgInitGL2: fghGenBuffers 为 NULL

在 GDB 环境之外,它会给出 APPCRASH (windows-shell) 或分段错误 (mingw64-shell)。

我的链接器标志是:

-std=c++11 -lstdc++ -lz -lm -lmysqlcleint -lpthread -lboost_thread-mgw49-mt-d-1_57 -lboost_system-mgw49-mt-d-1_57 -lboost_regex-mgw49-mt-d-1_57 -lcurl -lfreeglut -lglu32 -lopengl32 -lws2_32 -lwsock32 -U__CYGWIN__

我在 msys2 mingw-w64 工作。在运行时,程序尝试打开一个新窗口(至少在windows任务栏中有一个象形图米),但是窗口的构建不会成功。该程序在 OSX 上运行良好,我使用 glut 而不是 freeglut。

标题(以及其他):

#include <direct.h>
#include <GL/glut.h>
#include <GL/freeglut.h>

CPP(除其他外):

void interface::startInterface(int &argc, char **argv){

    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize  (width, height);
    glutInitWindowPosition (1920, 0);
    glutInit            (&argc, argv);
    glutCreateWindow    ("TIFAR 2.0");


    LoadGLTextures();                           // Load The Texture(s) ( NEW )
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);       // This Will Clear The Background Color To Black
    glClearDepth(1.0);                          // Enables Clearing Of The Depth Buffer
    glDepthFunc(GL_LESS);                       // The Type Of Depth Test To Do
    glEnable(GL_DEPTH_TEST);                    // Enables Depth Testing
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glShadeModel(GL_SMOOTH);                    // Enables Smooth Color Shading
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();                           // Reset The Projection Matrix

    gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f);
    // Calculate The Aspect Ratio Of The Window

    glMatrixMode(GL_MODELVIEW);

    glutDisplayFunc     (interface::display);
    glutReshapeFunc     (interface::reshape);
    glutIdleFunc        (interface::idle);
    glutKeyboardFunc    (interface::processNormalKeys);

    glutMainLoop();
}

程序中还有一些其他部分,例如加载图像的位置,但我认为当我在这里提及所有内容时会提供很多信息。

【问题讨论】:

  • 你用的是什么 FreeGLUT 版本?
  • @genpfault:来自 freeglut_std.h 的定义:FREEGLUT 1,GLUT_API_VERSION 4,GLUT_XLIB_IMPLEMENTATION 13,FREEGLUT_VERSION_2_0 1。

标签: opengl c++11 freeglut mingw-w64


【解决方案1】:

我花了一些时间,但问题的原因在于硬件。我在虚拟机 (VMware) 上运行,虽然规范说它支持最高 2.1 的 OpenGL,但我发现它根本不支持 OpenGL。

我的解决方案是使用一台旧机器,在其上安装 Windows,然后复制所有文件。它编译并运行得非常流畅。

如果其他人遇到同样的问题,我可以建议在虚拟化之前让它在本机安装上运行。它可以为您节省很多时间。

【讨论】:

  • 在 Windows 8.1 上使用远程桌面远程执行我的程序时,我在运行时收到 fgInitGL2: fghFrameBuffers is NULL。从本地机器运行时工作正常。如果不使用 VNC,似乎无法找到解决方法
  • 亲爱的 ObjectiveTruth,这与 Microsoft 虚拟化图形卡的方式有关。请尝试使用 RealVNC。另见opengl.org/discussion_boards/showthread.php/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-08
  • 2021-06-05
  • 1970-01-01
  • 1970-01-01
  • 2017-01-22
  • 1970-01-01
相关资源
最近更新 更多