2013-08-28 97 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