2013-02-02 11 views
1

我使用的是freeglut,windows 8,vs2012和最新的nvidia驅動程序。但大量空閒函數有一個奇怪的行爲。它在調整窗口大小或點擊窗口之前什麼也不做。Windows 8中的空閒空間 - 重新渲染

或者某種程度上的貪婪並不想重新渲染屏幕,即使一些變量已經改變。

#include <iostream> 
#include <stdlib.h> 
#include <GL/glut.h> 

using namespace std; 


GLfloat rotateQuad = 0; 



void initRendering() { 


    glEnable(GL_DEPTH_TEST); 

} 

//Called when the window is resized 

void handleResize(int w, int h) { 

    //Tell OpenGL how to convert from coordinates to pixel values 

    glViewport(0, 0, w, h); 



} 

//Draws the 3D scene 

void drawScene() { 

    //Clear information from last draw 

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

    glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective 

    glLoadIdentity(); //Reset the drawing perspective 

    glRotatef(rotateQuad,0,0,1); 

    glBegin(GL_QUADS); //Begin quadrilateral coordinates 



    glVertex3f(-0.5f, -0.5f, 0.0f); 

    glVertex3f(0.5f, -0.5f, 0.0f); 

    glVertex3f(0.5f, 0.5f, 0.0f); 

    glVertex3f(-0.5f, 0.5f, 0.0f); 

    glEnd(); //End quadrilateral coordinates 


    glutSwapBuffers(); //Send the 3D scene to the screen 

} 
void idle(){ 
    rotateQuad+=1; 
    if(rotateQuad > 360) rotateQuad=0; 
} 
int main(int argc, char** argv) { 

    //Initialize GLUT 

    glutInit(&argc, argv); 

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 

    glutInitWindowSize(400, 400); //Set the window size 

    //Create the window 

    glutCreateWindow("Quad Rotate"); 

    initRendering(); //Initialize rendering 

    glutIdleFunc(idle); 

    glutDisplayFunc(drawScene); 

    glutReshapeFunc(handleResize); 

    glutMainLoop(); //Start the main loop 

    return 0; 

} 

任何想法出了什麼問題?

回答