2002-09-16 05:35:34 +04:00
|
|
|
<HTML>
|
|
|
|
<BODY>
|
|
|
|
|
2001-11-28 21:00:17 +03:00
|
|
|
<!-- NEW PAGE -->
|
2002-09-16 05:35:34 +04:00
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<H2><A name=Fl_Gl_Window>class Fl_Gl_Window</A></H2>
|
2002-09-16 05:35:34 +04:00
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<HR>
|
2002-09-16 05:35:34 +04:00
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<H3>Class Hierarchy</H3>
|
2002-09-16 05:35:34 +04:00
|
|
|
|
|
|
|
<UL><PRE>
|
2001-10-01 00:25:36 +04:00
|
|
|
<A href=Fl_Window.html#Fl_Window>Fl_Window</A>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
+----<B>Fl_Gl_Window</B>
|
2002-09-16 05:35:34 +04:00
|
|
|
</PRE></UL>
|
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<H3>Include Files</H3>
|
2002-09-16 05:35:34 +04:00
|
|
|
|
|
|
|
<UL><PRE>
|
1999-01-13 22:28:54 +03:00
|
|
|
#include <FL/Fl_Gl_Window.H>
|
2002-09-16 05:35:34 +04:00
|
|
|
</PRE></UL>
|
|
|
|
|
|
|
|
<H3>Additional Libraries</H3>
|
|
|
|
|
|
|
|
<UL><PRE>
|
|
|
|
-lfltk_gl / fltkgl.lib
|
|
|
|
</PRE></UL>
|
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<H3>Description</H3>
|
2001-11-29 22:24:00 +03:00
|
|
|
The <TT>Fl_Gl_Window</TT> widget sets things up so OpenGL works, and
|
|
|
|
also keeps an OpenGL "context" for that window, so that changes to the
|
1999-01-13 22:28:54 +03:00
|
|
|
lighting and projection may be reused between redraws. Fl_Gl_Window
|
|
|
|
also flushes the OpenGL streams and swaps buffers after <TT>draw()</TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
returns.
|
|
|
|
<P>OpenGL hardware typically provides some overlay bit planes, which
|
|
|
|
are very useful for drawing UI controls atop your 3D graphics. If the
|
|
|
|
overlay hardware is not provided, FLTK tries to simulate the overlay,
|
|
|
|
This works pretty well if your graphics are double buffered, but not
|
1999-01-13 22:28:54 +03:00
|
|
|
very well for single-buffered. </P>
|
2006-06-23 14:56:15 +04:00
|
|
|
<P>Please note that the FLTK drawing and clipping functions
|
|
|
|
will not work inside an <tt>Fl_Gl_Window</tt>. All drawing
|
|
|
|
should be done using OpenGL calls exclusively.
|
2006-06-23 14:58:37 +04:00
|
|
|
Even though <tt>Fl_Gl_Window</tt> is derived from <tt>Fl_Group</tt>,
|
2006-06-23 14:56:15 +04:00
|
|
|
it is not useful to add other FLTK Widgets as children,
|
|
|
|
unless those Widgets are modified to draw using OpenGL calls.</P>
|
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<H3>Methods</H3>
|
|
|
|
<CENTER>
|
2001-05-06 20:25:05 +04:00
|
|
|
<TABLE width=90% summary="Fl_Gl_Window methods.">
|
1999-01-13 22:28:54 +03:00
|
|
|
<TR><TD align=left valign=top>
|
|
|
|
<UL>
|
|
|
|
<LI><A href=#Fl_Gl_Window.Fl_Gl_Window>Fl_Gl_Window</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.~Fl_Gl_Window>~Fl_Gl_Window</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.can_do>can_do</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.can_do_overlay>can_do_overlay</A></LI>
|
|
|
|
</UL>
|
|
|
|
</TD><TD align=left valign=top>
|
|
|
|
<UL>
|
2001-03-14 20:20:02 +03:00
|
|
|
<LI><A href=#Fl_Gl_Window.context>context</A></LI>
|
2006-08-17 13:49:43 +04:00
|
|
|
<LI><A href=#Fl_Gl_Window.context_valid>context_valid</A></LI>
|
1999-01-13 22:28:54 +03:00
|
|
|
<LI><A href=#Fl_Gl_Window.draw>draw</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.draw_overlay>draw_overlay</A></LI>
|
|
|
|
</UL>
|
|
|
|
</TD><TD align=left valign=top>
|
|
|
|
<UL>
|
|
|
|
<LI><A href=#Fl_Gl_Window.hide>hide</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.invalidate>invalidate</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.make_current>make_current</A></LI>
|
|
|
|
</UL>
|
|
|
|
</TD><TD align=left valign=top>
|
|
|
|
<UL>
|
|
|
|
<LI><A href=#Fl_Gl_Window.make_overlay_current>make_overlay_current</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.mode>mode</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.ortho>ortho</A></LI>
|
|
|
|
</UL>
|
|
|
|
</TD><TD align=left valign=top>
|
|
|
|
<UL>
|
|
|
|
<LI><A href=#Fl_Gl_Window.redraw_overlay>redraw_overlay</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.swap_buffers>swap_buffers</A></LI>
|
|
|
|
<LI><A href=#Fl_Gl_Window.valid>valid</A></LI>
|
|
|
|
</UL>
|
|
|
|
</TD></TR>
|
|
|
|
</TABLE>
|
|
|
|
</CENTER>
|
2001-11-29 22:24:00 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.Fl_Gl_Window>Fl_Gl_Window::Fl_Gl_Window(int x,
|
1999-01-13 22:28:54 +03:00
|
|
|
int y, int w, int h, const char *label = 0)</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
Creates a new <TT>Fl_Gl_Window</TT> widget using the given position,
|
|
|
|
size, and label string. The default boxtype is <TT>FL_NO_BOX</TT>. The
|
|
|
|
default mode is <TT>FL_RGB|FL_DOUBLE|FL_DEPTH</TT>.
|
|
|
|
<H4><A name=Fl_Gl_Window.~Fl_Gl_Window>virtual
|
1999-01-13 22:28:54 +03:00
|
|
|
Fl_Gl_Window::~Fl_Gl_Window()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
The destructor removes the widget and destroys the OpenGL context
|
|
|
|
associated with it.
|
1999-01-13 22:28:54 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.draw>virtual void Fl_Gl_Window::draw(void)</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
<TT>Fl_Gl_Window::draw()</TT> is a pure virtual method. You must
|
1999-01-13 22:28:54 +03:00
|
|
|
subclass <TT>Fl_Gl_Window</TT> and provide an implementation for <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
draw()</TT>. You may also provide an implementation of draw_overlay()
|
|
|
|
if you want to draw into the overlay planes. You can avoid
|
1999-01-13 22:28:54 +03:00
|
|
|
reinitializing the viewport and lights and other things by checking <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
valid()</TT> at the start of <TT>draw()</TT> and only doing the
|
|
|
|
initialization if it is false.
|
|
|
|
<P>The <TT>draw()</TT> method can <I>only</I> use OpenGL calls. Do not
|
1999-01-13 22:28:54 +03:00
|
|
|
attempt to call X, any of the functions in <FL/fl_draw.H>, or <TT>glX</TT>
|
|
|
|
directly. Do not call <TT>gl_start()</TT> or <TT>gl_finish()</TT>. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P>If double-buffering is enabled in the window, the back and front
|
1999-01-13 22:28:54 +03:00
|
|
|
buffers are swapped after this function is completed. </P>
|
|
|
|
<H4><A name=Fl_Gl_Window.mode>const int Fl_Gl_Window::mode() const
|
|
|
|
<BR> int Fl_Gl_Window::mode(int m)</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
Set or change the OpenGL capabilites of the window. The value can be
|
|
|
|
any of the following OR'd together:
|
1999-01-13 22:28:54 +03:00
|
|
|
<UL>
|
|
|
|
<LI><TT>FL_RGB</TT> - RGB color (not indexed) </LI>
|
|
|
|
<LI><TT>FL_RGB8</TT> - RGB color with at least 8 bits of each color </LI>
|
|
|
|
<LI><TT>FL_INDEX</TT> - Indexed mode </LI>
|
|
|
|
<LI><TT>FL_SINGLE</TT> - not double buffered </LI>
|
|
|
|
<LI><TT>FL_DOUBLE</TT> - double buffered </LI>
|
|
|
|
<LI><TT>FL_ACCUM</TT> - accumulation buffer </LI>
|
|
|
|
<LI><TT>FL_ALPHA</TT> - alpha channel in color </LI>
|
|
|
|
<LI><TT>FL_DEPTH</TT> - depth buffer </LI>
|
|
|
|
<LI><TT>FL_STENCIL</TT> - stencil buffer </LI>
|
|
|
|
<LI><TT>FL_MULTISAMPLE</TT> - multisample antialiasing </LI>
|
|
|
|
</UL>
|
2001-11-29 22:24:00 +03:00
|
|
|
<TT>FL_RGB</TT> and <TT>FL_SINGLE</TT> have a value of zero, so they
|
|
|
|
are "on" unless you give <TT>FL_INDEX</TT> or <TT>FL_DOUBLE</TT>.
|
1999-01-13 22:28:54 +03:00
|
|
|
<P>If the desired combination cannot be done, FLTK will try turning off <TT>
|
|
|
|
FL_MULTISAMPLE</TT>. If this also fails the <TT>show()</TT> will call <TT>
|
|
|
|
Fl::error()</TT> and not show the window. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P>You can change the mode while the window is displayed. This is most
|
|
|
|
useful for turning double-buffering on and off. Under X this will
|
|
|
|
cause the old X window to be destroyed and a new one to be created. If
|
|
|
|
this is a top-level window this will unfortunately also cause the
|
1999-01-13 22:28:54 +03:00
|
|
|
window to blink, raise to the top, and be de-iconized, and the <TT>xid()</TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
will change, possibly breaking other code. It is best to make the GL
|
1999-01-13 22:28:54 +03:00
|
|
|
window a child of another window if you wish to do this! </P>
|
|
|
|
<H4><A name=Fl_Gl_Window.can_do>static int Fl_Gl_Window::can_do(int)
|
|
|
|
<BR> int Fl_Gl_Window::can_do() const</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
Returns non-zero if the hardware supports the given or current OpenGL
|
|
|
|
mode.
|
2001-03-14 20:20:02 +03:00
|
|
|
|
|
|
|
<h4><a name=Fl_Gl_Window.context>void* Fl_Gl_Window::context() const;
|
|
|
|
<br>void Fl_Gl_Window::context(void*, int destroy_flag = false);</a></h4>
|
|
|
|
|
|
|
|
Return or set a pointer to the GLContext that this window is
|
|
|
|
using. This is a system-dependent structure, but it is portable to copy
|
|
|
|
the context from one window to another. You can also set it to NULL,
|
|
|
|
which will force FLTK to recreate the context the next time <a
|
2001-10-01 00:25:36 +04:00
|
|
|
href=#Fl_Gl_Window.make_current><tt>make_current()</tt></a> is called, this is
|
2001-03-14 20:20:02 +03:00
|
|
|
useful for getting around bugs in OpenGL implementations.
|
|
|
|
|
|
|
|
<p>If <i>destroy_flag</i> is true the context will be destroyed by
|
|
|
|
fltk when the window is destroyed, or when the <a
|
2001-10-01 00:25:36 +04:00
|
|
|
href=#Fl_Gl_Window.mode><tt>mode()</tt></a> is changed, or the next time
|
2001-03-14 20:20:02 +03:00
|
|
|
<tt>context(x)</tt> is called.
|
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.valid>char Fl_Gl_Window::valid() const
|
|
|
|
<BR> void Fl_Gl_Window::valid(char i)</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
<TT>Fl_Gl_Window::valid()</TT> is turned off when FLTK creates a new
|
1999-01-13 22:28:54 +03:00
|
|
|
context for this window or when the window resizes, and is turned on <I>
|
1999-01-27 11:45:11 +03:00
|
|
|
after</I> <TT>draw()</TT> is called. You can use this inside your <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
draw()</TT> method to avoid unneccessarily initializing the OpenGL
|
|
|
|
context. Just do this:
|
1999-01-15 01:14:01 +03:00
|
|
|
<UL><PRE>
|
1998-12-29 17:21:17 +03:00
|
|
|
void mywindow::draw() {
|
|
|
|
if (!valid()) {
|
|
|
|
glViewport(0,0,w(),h());
|
|
|
|
glFrustum(...);
|
|
|
|
...other initialization...
|
|
|
|
}
|
2006-08-17 13:49:43 +04:00
|
|
|
if (!context_valid()) {
|
|
|
|
...load textures, etc. ...
|
|
|
|
}
|
1998-12-29 17:21:17 +03:00
|
|
|
... draw your geometry here ...
|
|
|
|
}
|
1999-01-15 01:14:01 +03:00
|
|
|
</PRE></UL>
|
1998-12-29 17:21:17 +03:00
|
|
|
|
2001-11-29 22:24:00 +03:00
|
|
|
You can turn <TT>valid()</TT> on by calling <TT>valid(1)</TT>. You
|
1999-01-13 22:28:54 +03:00
|
|
|
should only do this after fixing the transformation inside a <TT>draw()</TT>
|
1999-01-15 01:14:01 +03:00
|
|
|
or after <TT>make_current()</TT>. This is done automatically after <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
draw()</TT> returns.
|
1999-01-13 22:28:54 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.invalidate>void Fl_Gl_Window::invalidate()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
The <TT>invalidate()</TT> method turns off <TT>valid()</TT> and is
|
|
|
|
equivalent to calling <TT>value(0)</TT>.
|
2006-08-17 13:49:43 +04:00
|
|
|
|
|
|
|
<H4><A name=Fl_Gl_Window.context_valid>char Fl_Gl_Window::context_valid() const
|
|
|
|
<BR> void Fl_Gl_Window::context_valid(char i)</A></H4>
|
|
|
|
<TT>Fl_Gl_Window::context_valid()</TT> will only be set if the
|
|
|
|
OpenGL context is created or recreated. It differs from
|
|
|
|
<TT>Fl_Gl_Window::valid()</TT> which is also set whenever the context
|
|
|
|
changes size.
|
|
|
|
|
1999-01-13 22:28:54 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.ortho>void Fl_Gl_Window::ortho()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
Set the projection so 0,0 is in the lower left of the window and each
|
1999-01-13 22:28:54 +03:00
|
|
|
pixel is 1 unit wide/tall. If you are drawing 2D images, your <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
draw()</TT> method may want to call this if <TT>valid()</TT> is false.
|
1999-01-13 22:28:54 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.make_current>void Fl_Gl_Window::make_current()</A>
|
|
|
|
</H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
The <TT>make_current()</TT> method selects the OpenGL context for the
|
|
|
|
widget. It is called automatically prior to the <TT>draw()</TT> method
|
|
|
|
being called and can also be used to implement feedback and/or
|
|
|
|
selection within the <TT>handle()</TT> method.
|
|
|
|
<H4><A name=Fl_Gl_Window.make_overlay_current>void
|
1999-01-13 22:28:54 +03:00
|
|
|
Fl_Gl_Window::make_overlay_current()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
The <TT>make_overlay_current()</TT> method selects the OpenGL context
|
1999-01-13 22:28:54 +03:00
|
|
|
for the widget's overlay. It is called automatically prior to the <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
draw_overlay()</TT> method being called and can also be used to
|
1999-01-13 22:28:54 +03:00
|
|
|
implement feedback and/or selection within the <TT>handle()</TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
method.
|
1999-01-13 22:28:54 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.swap_buffers>void Fl_Gl_Window::swap_buffers()</A>
|
|
|
|
</H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
The <TT>swap_buffers()</TT> method swaps the back and front buffers.
|
|
|
|
It is called automatically after the <TT>draw()</TT> method is called.
|
1999-01-13 22:28:54 +03:00
|
|
|
<H4><A name=Fl_Gl_Window.hide>void Fl_Gl_Window::hide()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
Hides the window and destroys the OpenGL context.
|
|
|
|
<H4><A name=Fl_Gl_Window.can_do_overlay>int
|
1999-01-13 22:28:54 +03:00
|
|
|
Fl_Gl_Window::can_do_overlay()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
Returns true if the hardware overlay is possible. If this is false,
|
|
|
|
FLTK will try to simulate the overlay, with significant loss of update
|
|
|
|
speed. Calling this will cause FLTK to open the display.
|
|
|
|
<H4><A name=Fl_Gl_Window.redraw_overlay>void
|
1999-01-13 22:28:54 +03:00
|
|
|
Fl_Gl_Window::redraw_overlay()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
This method causes <TT>draw_overlay</TT> to be called at a later time.
|
|
|
|
Initially the overlay is clear, if you want the window to display
|
|
|
|
something in the overlay when it first appears, you must call this
|
|
|
|
immediately after you <TT>show()</TT> your window.
|
|
|
|
<H4><A name=Fl_Gl_Window.draw_overlay>virtual void
|
1999-01-13 22:28:54 +03:00
|
|
|
Fl_Gl_Window::draw_overlay()</A></H4>
|
2001-11-29 22:24:00 +03:00
|
|
|
You must implement this virtual function if you want to draw into the
|
|
|
|
overlay. The overlay is cleared before this is called. You should
|
1999-01-13 22:28:54 +03:00
|
|
|
draw anything that is not clear using OpenGL. You must use <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
gl_color(i)</TT> to choose colors (it allocates them from the colormap
|
|
|
|
using system-specific calls), and remember that you are in an indexed
|
|
|
|
OpenGL mode and drawing anything other than flat-shaded will probably
|
|
|
|
not work.
|
1999-01-13 22:28:54 +03:00
|
|
|
<P>Both this function and <TT>Fl_Gl_Window::draw()</TT> should check <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
Fl_Gl_Window::valid()</TT> and set the same transformation. If you
|
|
|
|
don't your code may not work on other systems. Depending on the OS,
|
|
|
|
and on whether overlays are real or simulated, the OpenGL context may
|
1999-01-13 22:28:54 +03:00
|
|
|
be the same or different between the overlay and main window. </P>
|
2002-09-16 05:35:34 +04:00
|
|
|
</BODY>
|
|
|
|
</HTML>
|