Redraw OpenGL window at 60 fps (Vsync On)

25 views
Skip to first unread message

FOSS Dev

unread,
Oct 10, 2020, 4:36:47 AM10/10/20
to fltk.general
Hi i am new to FLTK but i want to know how can i make a render loop that automatically redraw OpenGL window at a constant frame rate.
Thanks

Manolo

unread,
Oct 10, 2020, 6:25:57 AM10/10/20
to fltk.general
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl.H>

Fl_Gl_Window *my_gl_window = ....
my_gl_window->show();
while (1) {
  Fl::wait(1./60); // that would give 60 redraws per second
  my_gl_window->redraw();
  }

imm

unread,
Oct 12, 2020, 8:22:38 AM10/12/20
to general fltk
I think, if I were doing it like this, I might look at using the
Fl::add_timeout() mechanism to trigger the redraw of the GL window
(though I'm certain Manolo knows that!)
Reply all
Reply to author
Forward
0 new messages