Hi, I have a problem with my game.
After playing for several minutes framerate goes to low.
I’ve tried playing in a simple scene: 3d model draw with VBO, no collisions, simple level e no other objects and I have the same problem.
Some suggests?
Maybe something wrong with my “main” file?
main.cpp:
void display();
void animate();
void reshape(int width, int height);
void mouseFunc(int,int,int,int);
void keyboardFunc(unsigned char, int, int);
void specialKeyboardFunc(int, int, int);
void changeScene();
GameScene *game;
StartMenu *start;
SelectionScene *selection;
extern State CURRENTSTATE;
int main (int argc, char ** argv)
{
myWindow window1;
window1.init(argc, argv);StartMenu s; SelectionScene sl; GameScene g; Debug d; start = &s; selection = &sl; game = &g;
glutReshapeFunc(reshape);
window1.render(&display);
window1.mouse(&mouseFunc);
window1.keyboard(&keyboardFunc);
window1.specialKeyboard(&specialKeyboardFunc);
game->setTime(glutGet(GLUT_ELAPSED_TIME));
glutIdleFunc(&animate);glutMainLoop();
return 0;
}
void display()
{glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE);
glLoadIdentity();
switch (CURRENTSTATE) { case STARTMENU: if(start->initialize()) { start->render(); } break; case SELECTION: if(selection->initialize()) { selection->render(); } break; case GAME: if(game->initialize()) { game->render(); } break; default: exit(1); }
glutSwapBuffers();
}
void reshape(int width, int height)
{
switch (CURRENTSTATE) {
case STARTMENU:
start->reshape(width, height);
break;case SELECTION: { SelectionScene selection; selection.reshape(width, height); break; } case GAME: game->reshape(width, height); break; case DEB: // debug->reshape(width, height); break; default: exit(1); }
}
void animate()
{
switch (CURRENTSTATE) {
case SELECTION:
{
selection->animate();
break;
}
case GAME:
game->animate();
break;
case DEB:
// debug->animate();
break;
default:
break;
}
}
void mouseFunc(int btn, int state, int x, int y)
{
switch (CURRENTSTATE) {
case STARTMENU:
start->mouse(btn, state, x, y);
break;case SELECTION: selection->mouse(btn, state, x, y); break; case GAME: game->mouse(btn, state, x, y); break; default: break; }
}
void keyboardFunc(unsigned char key, int x, int y)
{
switch (CURRENTSTATE) {case GAME: game->keyboard(key, x, y); break; default: break; }
}