我尝试使用以下代码来旋转图像,但它不起作用。
每当我写下这段代码时它都不起作用,我不确定,但我怀疑问题发生在这一行(虽然它没有显示出指向它的错误):rotatekiller [i ] - > display(rotatingObjects [i] .points [3] .x + rotatingObjects [i] .ceta,rotatingObjects [i] .points [3] .y + rotatingObjects [i] .ceta);
错误发生在单独的窗口,弹出错误窗口。
Image *rotatingkiller[1];
void LoadImages()
{
rotatingkiller[0] = new Image("satoor.bmp");
}
void myDisplay()
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glColor3f(0.9, 0.9, 0.9);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPointSize(4.0);
glColor3f(0.0, 0.0, 0.0);
for (int i = 0; i < rotatingObjects.size(); i++)
{
glPushMatrix();
glTranslatef(775, 475, 0);
glRotatef(rotatingObjects[0].ceta, 0, 0, 1);
glTranslatef(-775, -475, 0);
rotatingkiller[i]->display(rotatingObjects[i].points[3].x + rotatingObjects[i].ceta, rotatingObjects[i].points[3].y + rotatingObjects[i].ceta);
rotatingObjects[i].Draw();
glPopMatrix();
glutSwapBuffers();
}
glFlush();
}
void update(int value)
{
rotatingObjects[0].ceta += 15;
glutPostRedisplay();
glutTimerFunc(80, update, 0);
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(1000, 600);
glutInitWindowPosition(50, 50);
glutCreateWindow("Jumping Rabbit");
myStyleInit();
loadImages();
InsertShapes();
glutDisplayFunc(myDisplay);
glutSpecialFunc(keyboard);
for (int i = 0; i < movingObjects.size(); i++){
printf("%d", movingObjects.size());
glutTimerFunc(movingObjects[i].movmentSpeed, myTimer, i);
printf("%d", i);
}
PlaySound(TEXT("gamestart.wav"), NULL, SND_ASYNC);
glutTimerFunc(25, update, 0);
glutMainLoop();
return 0;
}