我的程序加载gif并使用devIL将其框架存储在数组中,然后使用该数组在纹理上显示图像。我想使用60fps动画(我已经制作过),但是出于某种原因,draw方法要比所需的16ms更长的时间才能达到此速率,请有人查看我的代码以查看是否花费了适当的时间或有什么事情
我已经尽我所能从显示功能中删除并尝试减少开销,并且计时器回调只是增加了帧
void display() {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glClearColor(55/360.0f, 171/360.0f, 200/306.0f, 1.0f);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
acWidth, acHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE,
data[frame]);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glColor4f(55/360.0f, 171/360.0f, 200/306.0f, 0.0f);
glTexCoord2f(1.0,1.0);
glVertex2f(width,1);
glTexCoord2f(1.0,0.0);
glVertex2f(width,1-2*height);
glTexCoord2f(0.0,0.0);
glVertex2f(-width,1-2*height);
glTexCoord2f(0.0,1.0);
glVertex2f(-width,1);
glEnd();
glutSwapBuffers();
}
void nextFrame(int val){
frame = (frame + 1)% 28;
glutPostRedisplay();
glutTimerFunc(1000.0/60.0,nextFrame, 1);
}