0

I am doing a simple OpenGL freeglut project where I need to close an OpenGL window and when given a command, reopen it in the initial state (Like a game staring again when the replay button is pressed). I want to do something like this -

while (c == 'y') {
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMainLoop();
    printf ("Want to play again? (y/n)\n");
    scanf ("%c", &c);
}

How can I do this? I saw about glutDestroyWindow() somewhere but couldn't figure out how to use that in my case.

Whittaker
  • 63
  • 1
  • 5
  • 1
    "*I need to close an OpenGL window and reopen it in the initial state*" Why exactly do you need to do this? – Nicol Bolas Jun 30 '19 at 13:30
  • I am doing a simple game. I want it to be like - first the console and game starts (opengl window opens). Then when the gamer fails, the opengl window closes and print the score in console and asks the user if he/she wants to play again. If he presses 'y', then the game starts again (opengl window opens in initial state) – Whittaker Jul 01 '19 at 06:04

0 Answers0