source: rtems-graphics-toolkit/fltk-1.1.10/documentation/glut.html @ 513eea1

Last change on this file since 513eea1 was 513eea1, checked in by Joel Sherrill <joel.sherrill@…>, on 01/09/10 at 22:43:24

2010-01-08 Joel Sherrill <joel.sherrill@…>

fltk 1.1.10. imported

  • ORIGIN: Updated.
  • Property mode set to 100644
File size: 8.4 KB
Line 
1<HTML>
2<HEAD>
3        <TITLE>D - GLUT Compatibility</TITLE>
4</HEAD>
5<BODY>
6<H1 ALIGN=RIGHT><A NAME=glut>D - GLUT Compatibility</A></H1>
7<P>This appendix describes the GLUT compatibility header file supplied with FLTK. FLTK's GLUT compatibility is based on the original GLUT 3.7 and the follow-on FreeGLUT 2.4.0 libraries.</P>
8<H2>Using the GLUT Compatibility Header File</H2>
9<P>You should be able to compile existing GLUT source code by including <TT>&lt;FL/glut.H&gt;</TT> instead of <TT>&lt;GL/glut.h&gt;</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>
10<P><I>All files calling GLUT procedures must be compiled with C++</I>. You may 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.</P>
11<P>You must link with the FLTK library. Most of <TT>FL/glut.H</TT> is inline functions.  You should take a look at it (and maybe at <TT>test/glpuzzle.cxx</TT> in the FLTK source) if you are having trouble porting your GLUT program. </P>
12<P>This has been tested with most of the demo programs that come with the GLUT and FreeGLUT distributions.</P>
13<H2>Known Problems</H2>
14<P>The following functions and/or arguments to functions are missing, and
15you will have to replace them or comment them out for your code to
16compile:
17<UL>
18<LI><TT>glutGet(GLUT_ELAPSED_TIME)</TT></LI>
19<LI><TT>glutGet(GLUT_SCREEN_HEIGHT_MM)</TT></LI>
20<LI><TT>glutGet(GLUT_SCREEN_WIDTH_MM)</TT></LI>
21<LI><TT>glutGet(GLUT_WINDOW_NUM_CHILDREN)</TT></LI>
22<LI><TT>glutInitDisplayMode(GLUT_LUMINANCE)</TT></LI>
23<LI><TT>glutLayerGet(GLUT_HAS_OVERLAY)</TT></LI>
24<LI><TT>glutLayerGet(GLUT_LAYER_IN_USE)</TT></LI>
25<LI><TT>glutPushWindow()</TT></LI>
26<LI><TT>glutSetColor(), glutGetColor(), glutCopyColormap()</TT></LI>
27<LI><TT>glutVideoResize()</TT> missing. </LI>
28<LI><TT>glutWarpPointer()</TT></LI>
29<LI><TT>glutWindowStatusFunc()</TT></LI>
30<LI>Spaceball, buttonbox, dials, and tablet functions</LI>
31</UL>
32 Most of the symbols/enumerations have different values than GLUT uses.
33 This will break code that relies on the actual values. The only
34symbols guaranteed to have the same values are true/false pairs like <TT>
35GLUT_DOWN</TT> and <TT>GLUT_UP</TT>, mouse buttons <TT>
36GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON</TT>, and <TT>
37GLUT_KEY_F1</TT> thru <TT>F12</TT>.
38<P>The strings passed as menu labels are not copied. </P>
39<P><TT>glutPostRedisplay()</TT> does not work if called from inside a
40display function.  You must use <TT>glutIdleFunc()</TT> if you want
41your display to update continuously. </P>
42<P><TT>glutSwapBuffers()</TT> does not work from inside a display
43function.  This is on purpose, because FLTK swaps the buffers for you. </P>
44<P><TT>glutUseLayer()</TT> does not work well, and should only be used
45to initialize transformations inside a resize callback.  You should
46redraw overlays by using <TT>glutOverlayDisplayFunc()</TT>. </P>
47<P>Overlays are cleared before the overlay display function is called. <TT>
48glutLayerGet(GLUT_OVERLAY_DAMAGED)</TT> always returns true for
49compatibility with some GLUT overlay programs.  You must rewrite your
50code so that <TT>gl_color()</TT> is used to choose colors in an
51overlay, or you will get random overlay colors. </P>
52<P><TT>glutSetCursor(GLUT_CURSOR_FULL_CROSSHAIR)</TT> just results in a
53small crosshair. </P>
54<P>The fonts used by <TT>glutBitmapCharacter() and glutBitmapWidth()</TT>
55 may be different. </P>
56<P><TT>glutInit(argc,argv)</TT> will consume different switches than
57GLUT does.  It accepts the switches recognized by <A href="Fl.html#Fl.args">
58<TT>Fl::args()</TT></A>, and will accept any abbreviation of these
59switches (such as &quot;-di&quot; for &quot;-display&quot;). </P>
60<H2>Mixing GLUT and FLTK Code</H2>
61 You can make your GLUT window a child of a <TT>Fl_Window</TT> with the
62following scheme.  The biggest trick is that GLUT insists on <TT>show()</TT>
63'ing the window at the point it is created, which means the <TT>
64Fl_Window</TT> parent window must already be shown.
65<UL>
66<LI>Don't call <TT>glutInit()</TT>. </LI>
67<LI>Create your <TT>Fl_Window</TT>, and any FLTK widgets.  Leave a
68blank area in the window for your GLUT window. </LI>
69<LI><TT>show()</TT> the <TT>Fl_Window</TT>.  Perhaps call <TT>
70show(argc,argv)</TT>. </LI>
71<LI>Call <TT>window-&gt;begin()</TT> so that the GLUT window will  be
72automatically added to it. </LI>
73<LI>Use <TT>glutInitWindowSize()</TT> and <TT>glutInitWindowPosition()</TT>
74 to set the location in the  parent window to put the GLUT window. </LI>
75<LI>Put your GLUT code next.  It probably does not need many changes.
76 Call <TT>window-&gt;end()</TT> immediately after the <TT>
77glutCreateWindow()</TT>! </LI>
78<LI>You can call either <TT>glutMainLoop()</TT>, <TT>Fl::run()</TT>, or
79loop calling <TT>Fl::wait()</TT> to run  the program. </LI>
80</UL>
81<HR break>
82<H2><A name=Fl_Glut_Window>class Fl_Glut_Window</A></H2>
83<HR>
84<H3>Class Hierarchy</H3>
85<UL>
86<PRE>
87<A href=Fl_Gl_Window.html#Fl_Gl_Window>Fl_Gl_Window</A>
88   |
89   +----<B>Fl_Glut_Window</B>
90</PRE>
91</UL>
92<H3>Include Files</H3>
93<UL>
94<PRE>
95#include &lt;FL/glut.H&gt;
96</PRE>
97</UL>
98<H3>Description</H3>
99 Each GLUT window is an instance of this class.  You may find it useful
100to manipulate instances directly rather than use GLUT window id's.
101 These may be created without opening the display, and thus can fit
102better into FLTK's method of creating windows.
103<P>The current GLUT window is available in the global variable <TT>
104glut_window</TT>. </P>
105<P><TT>new Fl_Glut_Window(...)</TT> is the same as <TT>
106glutCreateWindow()</TT> except it does not <TT>show()</TT> the window
107or make the window current. </P>
108<P><TT>window-&gt;make_current()</TT> is the same as <TT>
109glutSetWindow(number)</TT>.  If the window has not had <TT>show()</TT>
110 called on it yet, some functions that assumme an OpenGL context will
111not work.  If you do <TT>show()</TT> the window, call <TT>make_current()</TT>
112 again to set the context. </P>
113<P><TT>~Fl_Glut_Window()</TT> is the same as <TT>glutDestroyWindow()</TT>
114. </P>
115<H3>Members</H3>
116The <TT>Fl_Glut_Window</TT> class contains several public members that can
117be altered directly:
118<CENTER><TABLE WIDTH="80%" BORDER="1" ALT="Fl_Glut_Window public members.">
119<TR>
120        <TH>member</TH>
121        <TH>description</TH>
122</TR>
123<TR>
124        <TD>display</TD>
125        <TD>A pointer to the function to call to draw the normal planes.</TD>
126</TR>
127<TR>
128        <TD>entry</TD>
129        <TD>A pointer to the function to call when the mouse moves into
130        or out of the window.</TD>
131</TR>
132<TR>
133        <TD>keyboard</TD>
134        <TD>A pointer to the function to call when a regular key is pressed.</TD>
135</TR>
136<TR>
137        <TD>menu[3]</TD>
138        <TD>The menu to post when one of the mouse buttons is pressed.</TD>
139</TR>
140<TR>
141        <TD>mouse</TD>
142        <TD>A pointer to the function to call when a button is pressed or
143        released.</TD>
144</TR>
145<TR>
146        <TD>motion</TD>
147        <TD>A pointer to the function to call when the mouse is moved with
148        a button down.</TD>
149</TR>
150<TR>
151        <TD>overlaydisplay</TD>
152        <TD>A pointer to the function to call to draw the overlay planes.</TD>
153</TR>
154<TR>
155        <TD>passivemotion</TD>
156        <TD>A pointer to the function to call when the mouse is moved with
157        no buttons down.</TD>
158</TR>
159<TR>
160        <TD>reshape</TD>
161        <TD>A pointer to the function to call when the window is resized.</TD>
162</TR>
163<TR>
164        <TD>special</TD>
165        <TD>A pointer to the function to call when a special key is pressed.</TD>
166</TR>
167<TR>
168        <TD>visibility</TD>
169        <TD>A pointer to the function to call when the window is iconified
170        or restored (made visible.)</TD>
171</TR>
172</TABLE></CENTER>
173
174<H3>Methods</H3>
175<UL>
176<LI><A href=#Fl_Glut_Window.Fl_Glut_Window>Fl_Glut_Window</A></LI>
177<LI><A href=#Fl_Glut_Window.~Fl_Glut_Window>~Fl_Glut_Window</A></LI>
178<LI><A href=#Fl_Glut_Window.make_current>make_current</A></LI>
179</UL>
180<H4><A name=Fl_Glut_Window.Fl_Glut_Window>
181Fl_Glut_Window::Fl_Glut_Window(int x, int y, int w, int h, const char
182*title = 0)
183<BR> Fl_Glut_Window::Fl_Glut_Window(int w, int h, const char *title = 0)</A>
184</H4>
185 The first constructor takes 4 int arguments to create the window with
186a preset position and size.  The second constructor with 2 arguments
187will create the window with a preset size, but the window manager will
188choose the position according to it's own whims.
189<H4><A name=Fl_Glut_Window.~Fl_Glut_Window>virtual
190Fl_Glut_Window::~Fl_Glut_Window()</A></H4>
191 Destroys the GLUT window.
192<H4><A name="Fl_Glut_Window.make_current">void Fl_Glut_Window::make_current()</A></H4>
193Switches all drawing functions to the GLUT window.
194
195</BODY>
196</HTML>
Note: See TracBrowser for help on using the repository browser.