私はfreeglut、windows 8、vs2012および最新のnvidiaドライバーを使用しています。しかし、過剰なアイドル機能には奇妙な振る舞いがあります。ウィンドウのサイズを変更するか、ウィンドウをクリックするまで、何も実行されません。
または、いくつかの変数が変更されたとしても、どういうわけかglutは画面を再レンダリングしたくありません。
#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;
}
何がうまくいかなかったのか?