2013-08-28 96 views
1

在使用VS2012的Windows 8 64bit上,我遇到了设置GLUT(从Nate Robins获得的3.7.6二进制文件)的麻烦。 glut32.dll被复制到SysWOW64目录中,include和lib路径都在我的项目文件中设置,并且这些库在链接器 - >输入设置(“...; glut32.lib; glu32.lib; opengl32。 LIB; ......“)。在Windows 8上使用VisualStudio 2012设置GLUT

我的代码如下所示:

#include <GL/glut.h> 

void display() 
{ 
} 

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

构建过程是成功的,但应用程序崩溃并出现以下错误信息:

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

设置看起来相当简单。任何想法我失踪?

+2

[此](http://stackoverflow.com/questions/6178693/unhandled-exception-at-0x1000bbae-in-octree- exe-0xc0000005-access-violation-wr)可能是同一个问题 –

+0

@TheJoker是的。主函数中的第一行代码完全相同。答案解释了为什么失败。 – Chemistpp

+0

感谢您指出正确的方向!详情请参阅我的答案:) – Christoph

回答

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(); 
} 
+0

我应该编辑我的问题的标题以反映我的问题与操作系统或IDE无关的事实吗? – Christoph