2012-08-05 67 views
0

上週,我在閱讀GLUT教程時發現了一些例子,並且一切都很好。GLUT顯示桌面的一部分,而不是我的代碼

現在,當我重試這些相同的例子時,我得到一個奇怪的行爲:我的GLUT窗口顯示窗口位置的桌面部分(所以如果GLUT窗口從(100,100)開始並且大小500px乘500px,它顯示桌面的起始部分(100,100)和結束部分(600,600))。

我上週測試的以下示例應該在黑色背景上顯示一個茶壺。我想知道我的代碼是否有問題(因爲我不記得更改其中的任何內容),或者如果問題來自庫沒有正確鏈接,或者它是我不知道的其他內容。

#include <GL/glut.h> 

void displayFunc(void); 

int glutWindow; 

int main(int argc, char** argv){ 
    glutInit(&argc, argv); 

    glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE); 

    // define the size 
    glutInitWindowSize(500,500); 

    // the position where the window will appear 
    glutInitWindowPosition(100,100); 

    glutWindow = glutCreateWindow("UITest"); 
    glClearColor(0.0, 0.0, 0.0, 0.0); 

    glutDisplayFunc(displayFunc); 

    glutMainLoop(); 

    return EXIT_SUCCESS; 
} 

void displayFunc(void){ 
    glClear(GL_COLOR_BUFFER_BIT); 

    glutWireTeapot(0.5); 
} 

回答

2

你需要一個呼叫的displayFunc()末尾添加到glFlush()

+0

謝謝,它的工作!不過,我不明白爲什麼以前沒有它。 – 2012-08-06 06:01:29

相關問題