1

我在使用 VS2012 的 Windows 8 64 位上设置 GLUT(从Nate Robins获得的 3.7.6 二进制文件)时遇到了麻烦。glut32.dll 被复制到 SysWOW64 目录,在我的项目文件中设置了 include 和 lib 路径,并在 Linker->Input settings ("...;glut32.lib;glu32.lib;opengl32.库;...”)。

我的代码如下所示:

#include <GL/glut.h>

void display()
{
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutDisplayFunc(display);
    glutMainLoop();
}

构建过程成功,但应用程序崩溃并显示以下错误消息:

HelloOpenGL.exe 中 0x1000BBAE (glut32.dll) 处的未处理异常:0xC0000005:访问冲突写入位置 0x000000A8。

设置似乎相当简单。有什么我想念的想法吗?

4

1 回答 1

2

glutDisplayFunc()在不打开窗口的情况下调用导致崩溃。这是在传递显示函数之前打开一个新窗口的更新代码:

#include <GL/glut.h>

void display()
{
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    //Set Display Mode
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    //Set the window size
    glutInitWindowSize(250,250);
    //Set the window position
    glutInitWindowPosition(100,100);
    //Create the window
    glutCreateWindow("Hello OpenGL");
    //Set the display function
    glutDisplayFunc(display);
    //Enter the main loop
    glutMainLoop();
}
于 2013-08-28T07:52:22.173 回答