@@ -77,7 +77,7 @@ glDrawBuffer(GL_BACK);
To define the subclass you just subclass the
Fl_Gl_Window class:
-
+\code
class MyWindow : public Fl_Gl_Window {
void draw();
int handle(int);
@@ -86,7 +86,7 @@ public:
MyWindow(int X, int Y, int W, int H, const char *L)
: Fl_Gl_Window(X, Y, W, H, L) {}
};
-
+\endcode
The draw() and handle() methods are
described below. Like any widget, you can include additional
@@ -98,7 +98,7 @@ information, etc.)
The draw() method is where you actually do your
OpenGL drawing:
-
+\code
void MyWindow::draw() {
if (!valid()) {
... set up projection, viewport, etc ...
@@ -107,14 +107,14 @@ void MyWindow::draw() {
}
... draw ...
}
-
+\endcode
The handle() Method
The handle() method handles mouse and keyboard
events for the window:
-
+\code
int MyWindow::handle(int event) {
switch(event) {
case FL_PUSH:
@@ -144,7 +144,7 @@ int MyWindow::handle(int event) {
return Fl_Gl_Window::handle(event);
}
}
-
+\endcode
When handle() is called, the OpenGL context is not
set up! If your display changes, you should call
@@ -154,16 +154,18 @@ call any OpenGL drawing functions from inside handle()!
You can call some OpenGL stuff like hit detection and texture
loading functions by doing:
-
+\code
case FL_PUSH:
- make_current(); // make OpenGL context current
+ make_current(); // make OpenGL context current
if (!valid()) {
+
... set up projection exactly the same as draw ...
- valid(1); // stop it from doing this next time
+
+ valid(1); // stop it from doing this next time
}
... ok to call NON-DRAWING OpenGL code here, such as hit
detection, loading textures, etc...
-
+\endcode
Your main program can now create one of your windows by doing
new MyWindow(...). You can also use FLUID by:
Creating a Fl_Box widget in FLUID.
- In the widget panel fill in the "class"
+ In the widget panel fill in the "class"
field with MyWindow. This will make FLUID
produce constructors for your new class.
- In the "Extra Code" field put #include
- "MyWindow.H", so that the FLUID output
+ In the "Extra Code" field put \#include
+ "MyWindow.H", so that the FLUID output
file will compile.
-You must put glwindow->show() in your main code
+
You must put glwindow->show() in your main code
after calling show() on the window containing the
OpenGL window.
@@ -201,22 +203,21 @@ care.
Most importantly, before you show any windows,
including those that don't have OpenGL drawing, you must
initialize FLTK so that it knows it is going to use OpenGL. You
-may use any of the symbols described for Fl_Gl_Window::mode()
+may use any of the symbols described for Fl_Gl_Window::mode()
to describe how you intend to use OpenGL:
-
+\code
Fl::gl_visual(FL_RGB);
-
+\endcode
You can then put OpenGL drawing code anywhere you can draw
normally by surrounding it with:
-
+\code
gl_start();
... put your OpenGL code here ...
gl_finish();
-
+\endcode
gl_start() and gl_finish() set up an OpenGL
@@ -231,7 +232,7 @@ the projection transformation or anything else you should use
glPushMatrix() and glPopMatrix() functions to
put the state back before calling gl_finish().
-You may want to use Fl_Window::current()->h() to
+
You may want to use Fl_Window::current()->h() to
get the drawable height so that you can flip the Y
coordinates.
@@ -240,26 +241,23 @@ adhere to for maximum portability:
- - You must choose a default visual with Fl::gl_visual().
+ - You must choose a default visual with Fl::gl_visual().
- - You cannot pass FL_DOUBLE to
- Fl::gl_visual().
+ - You cannot pass FL_DOUBLE to Fl::gl_visual().
- - You cannot use Fl_Double_Window or
- Fl_Overlay_Window.
+ - You cannot use Fl_Double_Window or Fl_Overlay_Window.
Do not call gl_start() or
-gl_finish() when drawing into an Fl_Gl_Window!
+gl_finish() when drawing into an Fl_Gl_Window !
OpenGL Drawing Functions
FLTK provides some useful OpenGL drawing functions. They can
be freely mixed with any OpenGL calls, and are defined by
-including <FL/gl.H> which you should include
-instead of the OpenGL header <GL/gl.h>.
+including which you should include
+instead of the OpenGL header .
void gl_color(Fl_Color)
@@ -270,10 +268,9 @@ only right if this window uses the default colormap!
void gl_rect(int x, int y, int w, int h)
void gl_rectf(int x, int y, int w, int h)
-Outlines or fills a rectangle with the current color. If Fl_Gl_Window::ortho()
-has been called, then the rectangle will exactly fill the pixel
-rectangle passed.
+
Outlines or fills a rectangle with the current color. If
+Fl_Gl_Window::ortho() has been called, then the rectangle will exactly
+fill the pixel rectangle passed.
void gl_font(Fl_Font fontid, int size)
@@ -361,7 +358,7 @@ to view large scenes without writing a lot of OpenGL code.
subclass of Fl_Gl_Widget that includes several state
variables:
-
+\code
class OptimizerWindow : public Fl_Gl_Window {
csContext *context_; // Initialized to 0 and set by draw()...
csDrawAction *draw_action_; // Draw action...
@@ -384,13 +381,13 @@ public:
void camera(csCamera *c) {
camera_ = c;
if (context_) {
- draw_action_->setCamera(camera_);
- camera_->draw(draw_action_);
+ draw_action_->setCamera(camera_);
+ camera_->draw(draw_action_);
redraw();
}
}
};
-
+\endcode
The camera() Method
@@ -403,7 +400,7 @@ this call.
The draw() method performs the needed initialization and does
the actual drawing:
-
+\code
void OptimizerWindow::draw() {
if (!context_) {
// This is the first time we've been asked to draw; create the
@@ -411,12 +408,12 @@ void OptimizerWindow::draw() {
#ifdef WIN32
context_ = new csContext((HDC)fl_getHDC());
- context_->ref();
- context_->makeCurrent((HDC)fl_getHDC());
+ context_->ref();
+ context_->makeCurrent((HDC)fl_getHDC());
#else
context_ = new csContext(fl_display, fl_visual);
- context_->ref();
- context_->makeCurrent(fl_display, fl_window);
+ context_->ref();
+ context_->makeCurrent(fl_display, fl_window);
#endif // WIN32
... perform other context setup as desired ...
@@ -425,24 +422,24 @@ void OptimizerWindow::draw() {
draw_action_ = new csDrawAction;
if (camera_) {
- draw_action_->setCamera(camera_);
- camera_->draw(draw_action_);
+ draw_action_->setCamera(camera_);
+ camera_->draw(draw_action_);
}
} else {
#ifdef WIN32
- context_->makeCurrent((HDC)fl_getHDC());
+ context_->makeCurrent((HDC)fl_getHDC());
#else
- context_->makeCurrent(fl_display, fl_window);
+ context_->makeCurrent(fl_display, fl_window);
#endif // WIN32
}
if (!valid()) {
// Update the viewport for this context...
- context_->setViewport(0, 0, w(), h());
+ context_->setViewport(0, 0, w(), h());
}
// Clear the window...
- context_->clear(csContext::COLOR_CLEAR | csContext::DEPTH_CLEAR,
+ context_->clear(csContext::COLOR_CLEAR | csContext::DEPTH_CLEAR,
0.0f, // Red
0.0f, // Green
0.0f, // Blue
@@ -450,9 +447,9 @@ void OptimizerWindow::draw() {
// Then draw the scene (if any)...
if (scene_)
- draw_action_->apply(scene_);
+ draw_action_->apply(scene_);
}
-
+\endcode
The scene() Method
diff --git a/documentation/osissues.dox b/documentation/osissues.dox
index 43c13a38c..e1742e296 100644
--- a/documentation/osissues.dox
+++ b/documentation/osissues.dox
@@ -9,9 +9,9 @@
All programs that need to access the operating system
specific interfaces must include the following header file:
-
-#include <FL/x.H>
-
+\code
+#include
+\endcode
Despite the name, this header file will define the
appropriate interface for your environment. The pages that
@@ -78,7 +78,7 @@ XID, or NULL if not found. This function uses a cache
so it is slightly faster than iterating through the windows
yourself.
-
+
This call allows you to supply the X events to FLTK, which
may allow FLTK to cooperate with another toolkit or library. The
@@ -104,21 +104,21 @@ HREF="subclassing.html#draw">Fl_Widget::draw() is
called, or by Fl_Window::make_current():
-
+\code
extern Display *fl_display;
extern Window fl_window;
extern GC fl_gc;
extern int fl_screen;
extern XVisualInfo *fl_visual;
extern Colormap fl_colormap;
-
+\endcode
You must use them to produce Xlib calls. Don't attempt to change
them. A typical X drawing call is written like this:
-
+\code
XDrawSomething(fl_display, fl_window, fl_gc, ...);
-
+\endcode
Other information such as the position or size of the X
window can be found by looking at
index or RGB color. This is the X pixel that fl_color() would use.
-
+
Convert a name into the red, green, and blue values of a color
by parsing the X11 color names. On other systems, fl_parse_color
-can only convert names in hexadecimal encoding, for example #ff8083.
+can only convert names in hexadecimal encoding, for example \#ff8083.
@@ -170,7 +170,7 @@ visual.
Set which X display to use. This actually does
-putenv("DISPLAY=...") so that child programs
+putenv("DISPLAY=...") so that child programs
will display on the same screen if called with exec().
This must be done before the display is opened. This call is
provided under MacOS and WIN32 but it has no effect.
@@ -206,7 +206,7 @@ probably cannot call any FLTK functions.
fl_open_display() to the default screen. You can change
it by setting this to a different value immediately afterwards.
It can also be set by changing the last number in the
-Fl::display() string to "host:0.#".
+Fl::display() string to "host:0.#".
@@ -217,15 +217,15 @@ visual and colormap. You can change them before calling
show() on the first window. Typical code for changing
the default visual is:
-
+\code
Fl::args(argc, argv); // do this first so $DISPLAY is set
fl_open_display();
fl_visual = find_a_good_visual(fl_display, fl_screen);
-if (!fl_visual) Fl::abort("No good visual");
-fl_colormap = make_a_colormap(fl_display, fl_visual->visual, fl_visual->depth);
+if (!fl_visual) Fl::abort("No good visual");
+fl_colormap = make_a_colormap(fl_display, fl_visual->visual, fl_visual->depth);
// it is now ok to show() windows:
-window->show(argc, argv);
-
+window->show(argc, argv);
+\endcode
Using a Subclass of Fl_Window for Special X Stuff
@@ -252,7 +252,7 @@ implementation must call either Fl_X::set_xid() or
An example:
-
+\code
void MyWindow::show() {
if (shown()) {Fl_Window::show(); return;} // you must do this!
fl_open_display(); // necessary if this is first window
@@ -262,11 +262,11 @@ void MyWindow::show() {
if (!visual) {
visual = figure_out_visual();
colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
- vis->visual, AllocNone);
+ vis->visual, AllocNone);
}
Fl_X::make_xid(this, visual, colormap);
}
-
+\endcode
Fl_X *Fl_X::set_xid(Fl_Window *, Window xid)
@@ -293,7 +293,7 @@ your own windows you might just want to put all the drawing code
in here.
The X region that is a combination of all damage()
-calls done so far is in Fl_X::i(this)->region. If
+calls done so far is in Fl_X::i(this)->region. If
NULL then you should redraw the entire window. The
undocumented function fl_clip_region(XRegion) will
initialize the FLTK clip stack with a region or NULL
@@ -301,20 +301,20 @@ for no clipping. You must set region to NULL afterwards
as fl_clip_region() will own and delete it when
done.
-If damage() & FL_DAMAGE_EXPOSE then only X
+
If damage() & FL_DAMAGE_EXPOSE then only X
expose events have happened. This may be useful if you have an
undamaged image (such as a backing buffer) around.
Here is a sample where an undamaged image is kept somewhere:
-
+\code
void MyWindow::flush() {
- fl_clip_region(Fl_X::i(this)->region);
- Fl_X::i(this)->region = 0;
+ fl_clip_region(Fl_X::i(this)->region);
+ Fl_X::i(this)->region = 0;
if (damage() != 2) {... draw things into backing store ...}
... copy backing store to window ...
}
-
+\endcode
virtual void Fl_Window::hide()
@@ -324,7 +324,7 @@ window, and then call Fl_Window::hide() to get rid of
the main window identified by xid(). If you override
this, you must also override the destructor as shown:
-
+\code
void MyWindow::hide() {
if (mypixmap) {
XFreePixmap(fl_display,mypixmap);
@@ -332,7 +332,7 @@ void MyWindow::hide() {
}
Fl_Window::hide(); // you must call this
}
-
+\endcode
virtual void Fl_Window::~Fl_Window()
@@ -340,11 +340,11 @@ void MyWindow::hide() {
you must override the destructor as well (otherwise only
the base class hide() is called):
-
+\code
MyWindow::~MyWindow() {
hide();
}
-
+\endcode
Setting the Icon of a Window
@@ -358,33 +358,33 @@ need to cast the icon Pixmap to a char * when
calling this method. To set a monochrome icon using a bitmap compiled
with your application use:
-
-#include "icon.xbm"
+\code
+#include "icon.xbm"
fl_open_display(); // needed if display has not been previously opened
Pixmap p = XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display),
icon_bits, icon_width, icon_height);
-window->icon((char *)p);
-
+window->icon((char *)p);
+\endcode
To use a multi-colored icon, the XPM format and library
should be used as follows:
-
-#include <X11/xpm.h>
-#include "icon.xpm"
+\code
+#include
+#include "icon.xpm"
fl_open_display(); // needed if display has not been previously opened
Pixmap p, mask;
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
- icon_xpm, &p, &mask, NULL);
+ icon_xpm, &p, &mask, NULL);
-window->icon((char *)p);
-
+window->icon((char *)p);
+\endcode
When using the Xpm library, be sure to include it in the list
of libraries that are used to link the application (usually
@@ -453,7 +453,7 @@ state information and data structures.
Handling Other WIN32 Messages
-By default a single WNDCLASSEX called "FLTK" is
+
By default a single WNDCLASSEX called "FLTK" is
created. All Fl_Window's are of this class unless you
use Fl_Window::xclass(). The window class is created
the first time Fl_Window::show() is called.
@@ -505,14 +505,14 @@ HREF="subclassing.html#draw">Fl_Widget::draw() is
called, FLTK stores all the silly extra arguments you need to
make a proper GDI call in some global variables:
-
+\code
extern HINSTANCE fl_display;
extern HWND fl_window;
extern HDC fl_gc;
COLORREF fl_RGB();
HPEN fl_pen();
HBRUSH fl_brush();
-
+\endcode
These global variables are set before draw() is
called, or by fl_color() and are created as
needed and cached. A typical GDI drawing call is written like
this:
-
+\code
DrawSomething(fl_gc, ..., fl_brush());
-
+\endcode
It may also be useful to refer to Fl_Window::current()
@@ -543,9 +543,9 @@ need to cast the HICON handle to a char * when
calling this method. To set the icon using an icon resource
compiled with your application use:
-
-window->icon((char *)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON)));
-
+\code
+window->icon((char *)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON)));
+\endcode
You can also use the LoadImage() and related
functions to load specific resolutions or create the icon from
@@ -572,9 +572,9 @@ executables that controls whether or not to make a console
window.
To always get a console window you simply create a console
-application (the "/SUBSYSTEM:CONSOLE" option for the
+application (the "/SUBSYSTEM:CONSOLE" option for the
linker). For a GUI-only application create a WIN32 application
-(the "/SUBSYSTEM:WINDOWS" option for the linker).
+(the "/SUBSYSTEM:WINDOWS" option for the linker).
FLTK includes a WinMain() function that calls the
ANSI standard main() entry point for you. This
@@ -707,7 +707,7 @@ applications
will NOT copy any resource forks! For copying and moving use
CpMac and MvMac respectively. For creating a tar archive, all
executables need to be stripped from their Resource Fork before
-packing, e.g. "DeRez fluid > fluid.r". After unpacking the
+packing, e.g. "DeRez fluid > fluid.r". After unpacking the
Resource Fork needs to be reattached, e.g. "Rez fluid.r -o
fluid".