So I'm making quiz in opengl with c++. The problem is that I don't know how to declare function inside other function, so I have an error.
void main_menu_display()
{
glClear(GL_COLOR_BUFFER_BIT);
// code to draw main menu
glutSwapBuffers();
}
void main_menu_key(unsigned char key, int x, int y)
{
I also tried this, to solve errors: //void first_screen_display(); //void first_screen_key();
switch(key)
{
case 27: //< escape -> quit
exit(0);
case 13: //< enter -> goto first display
glutDisplayFunc(first_screen_display);
glutKeyboardFunc(first_screen_key);
break;
and there's error: 'first_screen_display' was not declared in this scope and same happens with first screen key.
}
glutPostRedisplay();
}
void first_screen_display()
{
glClear(GL_COLOR_BUFFER_BIT);
// code to draw first screen of game
glutSwapBuffers();
}
void first_screen_key(unsigned char key, int x, int y)
{
switch(key)
{
case 27: //< escape -> return to main menu
glutDisplayFunc(first_screen_display);
glutKeyboardFunc(first_screen_key);
break;
/* other stuff */
default:
break;
}
glutPostRedisplay();
}
int main(int argc, char* argv[]) //argument count, argument variables
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowSize(600,600);
glutInitWindowPosition(100,100);
glutCreateWindow("Quiz");
glutDisplayFunc(main_menu_display);
glutKeyboardFunc(main_menu_key);
//glutDisplayFunc(first_screen_display);
//glutKeyboardFunc(first_screen_key);
Init();
glutMainLoop();
return 0;
}