1998-12-29 17:21:17 +03:00
|
|
|
<HTML>
|
|
|
|
<BODY>
|
|
|
|
|
|
|
|
<H1 ALIGN=RIGHT><A NAME="glut">D - GLUT Compatibility</A></H1>
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
This appendix describes the GLUT compatibility header file supplied with
|
|
|
|
FLTK.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<H2>Using the GLUT Compatibility Header File</H2>
|
|
|
|
|
|
|
|
You should be able to compile existing GLUT source code by including
|
|
|
|
<tt><FL/glut.H></tt> instead of <tt><GL/glut.h></tt>. This can
|
|
|
|
be done by editing the source, by changing the <tt>-I</tt> switches to
|
|
|
|
the compiler, or by providing a symbolic link from <tt>GL/glut.h</tt>
|
|
|
|
to <tt>FL/glut.H</tt>.
|
|
|
|
|
|
|
|
<p><i>All files calling GLUT procedures must be compiled with C++</i>. You may
|
1998-12-29 17:21:17 +03:00
|
|
|
have to alter them slightly to get them to compile without warnings,
|
|
|
|
and you may have to rename them to get make to use the C++ compiler.
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p>You must link with the FLTK library. If you call any GLUT drawing
|
|
|
|
functions that FLTK does not emulate
|
|
|
|
(<tt>glutExtensionsSupported()</tt>, <tt>glutWire*()</tt>,
|
|
|
|
<tt>glutSolid*()</tt>, and <tt>glutStroke*()</tt>), you will also have
|
|
|
|
to link with the GLUT library (<i>after</i> the FLTK library!)
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p>Most of <tt>FL/glut.H</tt> is inline functions. You should take a
|
|
|
|
look at it (and maybe at <tt>test/glut.cxx</tt> in the FLTK source) if
|
|
|
|
you are having trouble porting your GLUT program.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
|
|
|
<p>This has been tested with most of the demo programs that come with
|
1999-01-07 19:36:11 +03:00
|
|
|
the GLUT 3.3 distribution.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
|
|
|
<h2>Known Problems</h2>
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
The following functions and/or arguments to functions are missing,
|
|
|
|
and you will have to replace them or comment them out for your code to
|
|
|
|
compile:
|
|
|
|
|
1998-12-29 17:21:17 +03:00
|
|
|
<ul>
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<li><tt>glutLayerGet(GLUT_LAYER_IN_USE)</tt>
|
|
|
|
<li><tt>glutLayerGet(GLUT_HAS_OVERLAY)</tt>
|
|
|
|
<li><tt>glutSetColor(), glutGetColor(), glutCopyColormap()</tt>
|
|
|
|
<li><tt>glutInitDisplayMode(GLUT_STEREO)</tt>
|
|
|
|
<li><tt>glutInitDisplayMode(GLUT_LUMINANCE)</tt>
|
|
|
|
<li><tt>glutPushWindow()</tt>
|
|
|
|
<li><tt>glutWarpPointer()</tt>
|
|
|
|
<li>Spaceball, buttonbox, dials, tablet functions,
|
|
|
|
<tt>glutDeviceGet()</tt>
|
|
|
|
<li><tt>glutWindowStatusFunc()</tt>
|
|
|
|
<li><tt>glutGet(GLUT_WINDOW_NUM_CHILDREN)</tt>
|
|
|
|
<li><tt>glutGet(GLUT_SCREEN_WIDTH_MM)</tt>
|
|
|
|
<li><tt>glutGet(GLUT_SCREEN_HEIGHT_MM)</tt>
|
|
|
|
<li><tt>glutGet(GLUT_ELAPSED_TIME)</tt>
|
|
|
|
<li><tt>glutVideoResize()</tt> missing.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
Most of the symbols/enumerations have different values than
|
|
|
|
GLUT uses. This will break code that relies on the actual values.
|
1998-12-29 17:21:17 +03:00
|
|
|
The only symbols guaranteed to have the same values are true/false
|
1999-01-07 19:36:11 +03:00
|
|
|
pairs like <tt>GLUT_DOWN</tt> and <tt>GLUT_UP</tt>, mouse
|
|
|
|
buttons <tt>GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON,
|
|
|
|
GLUT_RIGHT_BUTTON</tt>, and <tt>GLUT_KEY_F1</tt> thru
|
|
|
|
<tt>F12</tt>.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p>The strings passed as menu labels are not copied.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p><tt>glutPostRedisplay()</tt> does not work if called from
|
|
|
|
inside a display function. You must use <tt>glutIdleFunc()</tt>
|
1998-12-29 17:21:17 +03:00
|
|
|
if you want your display to update continuously.
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p><tt>glutSwapBuffers()</tt> does not work from inside a display
|
|
|
|
function. This is on purpose, because FLTK swaps the buffers for you.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p><tt>glutUseLayer()</tt> does not work well, and should only be
|
1998-12-29 17:21:17 +03:00
|
|
|
used to initialize transformations inside a resize callback. You
|
1999-01-07 19:36:11 +03:00
|
|
|
should redraw overlays by using <tt>glutOverlayDisplayFunc()</tt>.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p>Overlays are cleared before the overlay display function is called.
|
|
|
|
<tt>glutLayerGet(GLUT_OVERLAY_DAMAGED)</tt> always returns true for
|
|
|
|
compatibility with some GLUT overlay programs. You must rewrite your
|
|
|
|
code so that <tt>gl_color()</tt> is used to choose colors in an
|
|
|
|
overlay, or you will get random overlay colors.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p><tt>glutSetCursor(GLUT_CURSOR_FULL_CROSSHAIR)</tt> just
|
1998-12-29 17:21:17 +03:00
|
|
|
results in a small crosshair.
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p>The fonts used by <tt>glutBitmapCharacter() and
|
|
|
|
glutBitmapWidth()</tt> may be different.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p><tt>glutInit(argc,argv)</tt> will consume different switches than GLUT
|
1998-12-29 17:21:17 +03:00
|
|
|
does. It accepts the switches recognized by <a
|
1999-01-07 19:36:11 +03:00
|
|
|
href="#args"><tt>Fl::args()</tt></a>, and will accept any
|
|
|
|
abbreviation of these switches (such as "-di" for "-display").
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<h2>Mixing GLUT and FLTK Code</h2>
|
|
|
|
|
|
|
|
You can make your GLUT window a child of a <tt>Fl_Window</tt> with the
|
|
|
|
following scheme. The biggest trick is that GLUT insists on
|
|
|
|
<tt>show()</tt>'ing the window at the point it is created, which means the
|
|
|
|
<tt>Fl_Window</tt> parent window must already be shown.
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li>Don't call <tt>glutInit()</tt>.
|
|
|
|
|
|
|
|
<li>Create your <tt>Fl_Window</tt>, and any FLTK widgets.
|
|
|
|
Leave a blank area in the window for your GLUT window.
|
|
|
|
|
|
|
|
<li><tt>show()</tt> the <tt>Fl_Window</tt>. Perhaps call
|
|
|
|
<tt>show(argc,argv)</tt>.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<li>Call <tt>window->begin()</tt> so that the GLUT window will
|
|
|
|
be automatically added to it.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<li>Use <tt>glutInitWindowSize()</tt> and
|
|
|
|
<tt>glutInitWindowPosition()</tt> to set the location in the
|
|
|
|
parent window to put the GLUT window.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<li>Put your GLUT code next. It probably does not need many changes.
|
|
|
|
Call <tt>window->end()</tt> immediately after the <tt>glutCreateWindow()</tt>!
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<li>You can call either <tt>glutMainLoop()</tt>,
|
|
|
|
<tt>Fl::run()</tt>, or loop calling <tt>Fl::wait()</tt> to run
|
|
|
|
the program.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<hr break>
|
|
|
|
|
|
|
|
<h2><a name="Fl_Glut_Window">class Fl_Glut_Window</a></h2>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<hr>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<h3>Class Hierarchy</h3>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<ul><pre>
|
|
|
|
<a href="#Fl_Gl_Window">Fl_Gl_Window</a>
|
|
|
|
|
|
|
|
|
+----<b>Fl_Glut_Window</b>
|
|
|
|
</pre></ul>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<h3>Include Files</h3>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<ul><pre>
|
|
|
|
#include <FL/glut.H>
|
|
|
|
</pre></ul>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<h3>Description</h3>
|
|
|
|
|
|
|
|
Each GLUT window is an instance of this class. You may find it useful to
|
|
|
|
manipulate instances directly rather than use GLUT window id's. These
|
1998-12-29 17:21:17 +03:00
|
|
|
may be created without opening the display, and thus can fit better
|
1999-01-07 19:36:11 +03:00
|
|
|
into FLTK's method of creating windows.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p>The current GLUT window is available in the global variable
|
|
|
|
<tt>glut_window</tt>.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p><tt>new Fl_Glut_Window(...)</tt> is the same as
|
|
|
|
<tt>glutCreateWindow()</tt> except it does not <tt>show()</tt> the window
|
1998-12-29 17:21:17 +03:00
|
|
|
or make the window current.
|
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
<p><tt>window->make_current()</tt> is the same as
|
|
|
|
<tt>glutSetWindow(number)</tt>. If the window has not had
|
|
|
|
<tt>show()</tt> called on it yet, some functions that assumme an OpenGL
|
|
|
|
context will not work. If you do <tt>show()</tt> the window, call
|
|
|
|
<tt>make_current()</tt> again to set the context.
|
|
|
|
|
|
|
|
<p><tt>~Fl_Glut_Window()</tt> is the same as
|
|
|
|
<tt>glutDestroyWindow()</tt>.
|
|
|
|
|
|
|
|
<h3>Methods</h3>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><a href="#Fl_Glut_Window.Fl_Glut_Window">Fl_Glut_Window</a>
|
|
|
|
<li><a href="#Fl_Glut_Window.~Fl_Glut_Window">~Fl_Glut_Window</a>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h4><a name="Fl_Glut_Window.Fl_Glut_Window">Fl_Glut_Window::Fl_Glut_Window(int x, int y, int w, int h, const char *title = 0)<br>
|
|
|
|
Fl_Glut_Window::Fl_Glut_Window(int w, int h, const char *title = 0)</a></h4>
|
|
|
|
|
|
|
|
The first constructor takes 4 int arguments to create the window with
|
|
|
|
a preset position and size. The second constructor with 2 arguments
|
|
|
|
will create the window with a preset size, but the window manager
|
|
|
|
will choose the position according to it's own whims.
|
|
|
|
|
|
|
|
<h4><a name="Fl_Glut_Window.~Fl_Glut_Window">virtual Fl_Glut_Window::~Fl_Glut_Window()</a></h4>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
1999-01-07 19:36:11 +03:00
|
|
|
Destroys the GLUT window.
|
1998-12-29 17:21:17 +03:00
|
|
|
|
|
|
|
</BODY>
|
|
|
|
</HTML>
|