Monday, May 28, 2012

FLTK and GLUT issues


There's an example here of using glut to create a sphere,
but FLTK for everything else:
http://seriss.com/people/erco/fltk/#OpenGLSphereWithLight


That's the typical use of GLUT in FLTK apps; to access
the opengl shortcuts that you would normally have to do
in raw opengl code (eg. glutSolidSphere())


GLUT's edict is to serve two purposes:


1) Provide simple cross platform window and event management
so that one can build simple standalone opengl apps
that don't depend on other libraries besides opengl.


2) Supply some neat opengl shortcut functions
(such as creating spheres) to make opengl examples
easier to write.


FLTK has #1 covered, so if you're using FLTK, you wouldn't
use GLUT to do the #1 stuff. But the features GLUT provides
in #2 can be useful inside FLTK apps.


FLTK can provide an opengl window via Fl_Gl_Window, in which
you can do normal opengl programming.


GLUT has some cool opengl convenience functions that
makes sense to use inside the Fl_Gl_Window; usually things
you just don't want to code in raw opengl, because
GLUT already provides an easy to use interface for them.


But you should /avoid/ using GLUT calls that try to do
anything with the event queue or window management. eg.
glutCreateWindow(), glutIdleFunc(), etc.. in an FLTK app,
those would compete for window manager and device event
management (mouse/keyboard) causing havoc.


> showing how to embed a GLUT window into a FLTK window?


I'd avoid going there; this is asking for trouble
because both FLTK and GLUT will compete for the
window manager and event queue resources.


Better to use an FLTK GL window, and use opengl
oriented GLUT calls that don't involve event or window
management.