mercredi 10 juillet 2019

FLTK window not showing in while loop c++

I am trying to implement a game loop in FLTK

void SnakeFLTK::init() {
    _display = new Fl_Window(900, 600);
    if (!_display)
        throw SnakeFLTKException("Couldn't make fltk window!");
    _display->color(FL_BLACK);
    _display->show();
    while (!_doExit) {
        std::cout << "-->" << std::endl;
    }
    Fl::run();
}

the problem I have is the window is not showing. I want to keep showing and redrawing on the window in the while (!_doExit) loop and it's important that I use _doExit. I have tried using

while (Fl::wait > 0)

but this method seems to have its own loop that waits for events. How do I Implement a loop like I did and show the window?

Aucun commentaire:

Enregistrer un commentaire