1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
class Game {
public:
Game(int argc, char* argv[]);
static void update(int value); // This Works with OGL
static void reshape(int width,int height); // This does not seem to work
void execute(void);
/* other stuff */
};
Game::Game(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH|GLUT_RGBA);
glutInitWindowSize(getScreenSize().x,getScreenSize().y);
glutReshapeFunc(reshape); // set reshape function
/* other stuff non-ogl */
glutTimerFunc(m_timercallback,update,m_timercallback); // set update function
}
void Game::update(int value) // This works!
{
glutPostRedisplay();
glutTimerFunc(timercallback,update,timercallback);
}
void Game::reshape(int width,int height) // Doesn't work
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,
(double)width / (double)height,
1,
100.0);
glMatrixMode(GL_MODELVIEW);
}
void Game::execute(void)
{
glutCreateWindow("Window title");
glutMainLoop();
}
|