mirror of
https://github.com/fltk/fltk.git
synced 2026-05-24 00:06:20 +08:00
converted html tags to doxygen commands in opengl.dox
also corrected function signatures in opengl.dox added doxygen comments to FL/gl.h, src/gl_start.cxx, src/gl_draw.cxx git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6749 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -32,6 +32,22 @@
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/** \file gl.h
|
||||
* This file defines wrapper functions for OpenGL in FLTK
|
||||
*
|
||||
* To use OpenGL from within an FLTK application you MUST use gl_visual()
|
||||
* to select the default visual before doing show() on any windows. Mesa
|
||||
* will crash if yoy try to use a visual not returned by glxChooseVidual.
|
||||
*
|
||||
* This does not work with Fl_Double_Window's! It will try to draw
|
||||
* into the front buffer. Depending on the system this will either
|
||||
* crash or do nothing (when pixmaps are being used as back buffer
|
||||
* and GL is being done by hardware), work correctly (when GL is done
|
||||
* with software, such as Mesa), or draw into the front buffer and
|
||||
* be erased when the buffers are swapped (when double buffer hardware
|
||||
* is being used)
|
||||
*/
|
||||
|
||||
#ifndef FL_gl_H
|
||||
# define FL_gl_H
|
||||
|
||||
@@ -56,10 +72,15 @@
|
||||
FL_EXPORT void gl_start();
|
||||
FL_EXPORT void gl_finish();
|
||||
|
||||
FL_EXPORT void gl_color(Fl_Color);
|
||||
inline void gl_color(int c) {gl_color((Fl_Color)c);} // back compatability
|
||||
FL_EXPORT void gl_color(Fl_Color i);
|
||||
/** back compatability */
|
||||
inline void gl_color(int c) {gl_color((Fl_Color)c);}
|
||||
|
||||
FL_EXPORT void gl_rect(int x,int y,int w,int h);
|
||||
/**
|
||||
Fills the given rectangle with the current color.
|
||||
\see gl_rect(int x, int y, int w, int h)
|
||||
*/
|
||||
inline void gl_rectf(int x,int y,int w,int h) {glRecti(x,y,x+w,y+h);}
|
||||
|
||||
FL_EXPORT void gl_font(int fontid, int size);
|
||||
|
||||
@@ -20,11 +20,6 @@ drawing your widgets. To do this you use the
|
||||
\ref opengl_gl_finish "gl_finish()"
|
||||
functions around your OpenGL code.
|
||||
|
||||
<A href="#gl_start"><tt>gl_start()</tt></A>
|
||||
and
|
||||
<A href=#gl_finish><tt>gl_finish()</tt></A>
|
||||
functions around your OpenGL code.
|
||||
|
||||
You must include FLTK's \p <FL/gl.h> header
|
||||
file. It will include the file \p <GL/gl.h>, define
|
||||
some extra drawing functions provided by FLTK, and include the
|
||||
@@ -167,6 +162,7 @@ Your main program can now create one of your windows by doing
|
||||
<tt>new MyWindow(...)</tt>.
|
||||
|
||||
You can also use your new window class in
|
||||
\ref fluid "FLUID"
|
||||
<A href="fluid.html#FLUID">FLUID</A>
|
||||
by:
|
||||
|
||||
@@ -189,11 +185,6 @@ in the previous chapter, or into the code for a
|
||||
\ref common_boxtypes "boxtype"
|
||||
or other places with some care.
|
||||
|
||||
<A href="subclassing.html#draw"><tt>Fl_Widget::draw()</tt></A>
|
||||
method or into the code for a
|
||||
<A href="common.html#boxtypes">boxtype</A>
|
||||
or other places with some care.
|
||||
|
||||
Most importantly, before you show \e any windows,
|
||||
including those that don't have OpenGL drawing, you <B>must</B>
|
||||
initialize FLTK so that it knows it is going to use OpenGL. You
|
||||
@@ -204,8 +195,16 @@ to describe how you intend to use OpenGL:
|
||||
Fl::gl_visual(FL_RGB);
|
||||
\endcode
|
||||
|
||||
\anchor opengl_gl_start
|
||||
\anchor opengl_gl_finish
|
||||
You can then put OpenGL drawing code anywhere you can draw
|
||||
normally by surrounding it with:
|
||||
normally by surrounding it with
|
||||
gl_start() and gl_finish() to set up, and later release, an OpenGL
|
||||
context with an orthographic projection so that 0,0 is the
|
||||
lower-left corner of the window and each pixel is one unit. The
|
||||
current clipping is reproduced with OpenGL \p glScissor()
|
||||
commands. These functions also synchronize the OpenGL graphics stream
|
||||
with the drawing done by other X, WIN32, or FLTK functions.
|
||||
|
||||
\code
|
||||
gl_start();
|
||||
@@ -213,21 +212,12 @@ gl_start();
|
||||
gl_finish();
|
||||
\endcode
|
||||
|
||||
\anchor opengl_gl_start
|
||||
\anchor opengl_gl_finish
|
||||
\p gl_start() and \p gl_finish() set up an OpenGL
|
||||
context with an orthographic projection so that 0,0 is the
|
||||
lower-left corner of the window and each pixel is one unit. The
|
||||
current clipping is reproduced with OpenGL \p glScissor()
|
||||
commands. These functions also synchronize the OpenGL graphics stream
|
||||
with the drawing done by other X, WIN32, or FLTK functions.
|
||||
|
||||
The same context is reused each time. If your code changes
|
||||
the projection transformation or anything else you should use
|
||||
\p glPushMatrix() and \p glPopMatrix() functions to
|
||||
put the state back before calling \p gl_finish().
|
||||
|
||||
You may want to use <tt>Fl_Window::current()->h()</tt> to
|
||||
You may want to use <tt>Fl_Window::current()-\>h()</tt> to
|
||||
get the drawable height so that you can flip the Y
|
||||
coordinates.
|
||||
|
||||
@@ -273,31 +263,31 @@ Sets the current OpenGL font to the same font you get by calling
|
||||
|
||||
int gl_height() <br>
|
||||
int gl_descent() <br>
|
||||
float gl_width(const char *) <br>
|
||||
float gl_width(const char *, int n) <br>
|
||||
float gl_width(uchar)
|
||||
float gl_width(const char *s) <br>
|
||||
float gl_width(const char *s, int n) <br>
|
||||
float gl_width(uchar c)
|
||||
|
||||
\par
|
||||
Returns information about the current OpenGL font.
|
||||
|
||||
void gl_draw(const char *) <br>
|
||||
void gl_draw(const char *, int n)
|
||||
void gl_draw(const char *s) <br>
|
||||
void gl_draw(const char *s, int n)
|
||||
|
||||
\par
|
||||
Draws a nul-terminated string or an array of \p n<
|
||||
Draws a nul-terminated string or an array of \p n
|
||||
characters in the current OpenGL font at the current raster
|
||||
position.
|
||||
|
||||
void gl_draw(const char *, int x, int y) <br>
|
||||
void gl_draw(const char *, int n, int x, int y) <br>
|
||||
void gl_draw(const char *, float x, float y) <br>
|
||||
void gl_draw(const char *, int n, float x, float y)
|
||||
void gl_draw(const char *s, int x, int y) <br>
|
||||
void gl_draw(const char *s, int n, int x, int y) <br>
|
||||
void gl_draw(const char *s, float x, float y) <br>
|
||||
void gl_draw(const char *s, int n, float x, float y)
|
||||
|
||||
\par
|
||||
Draws a nul-terminated string or an array of \p n
|
||||
characters in the current OpenGL font at the given position.
|
||||
|
||||
void gl_draw(const char *, int x, int y, int w, int h, Fl_Align)
|
||||
void gl_draw(const char *s, int x, int y, int w, int h, Fl_Align)
|
||||
|
||||
\par
|
||||
Draws a string formatted into a box, with newlines and tabs
|
||||
@@ -316,7 +306,7 @@ you do a swapbuffers.
|
||||
\li <tt>setenv GL_SWAP_TYPE COPY</tt> <br>
|
||||
<br>
|
||||
This indicates that the back buffer is copied to the
|
||||
front buffer, and still contains it's old data. This is
|
||||
front buffer, and still contains its old data. This is
|
||||
true of many hardware implementations. Setting this
|
||||
will speed up emulation of overlays, and widgets that
|
||||
can do partial update can take advantage of this as
|
||||
@@ -333,7 +323,7 @@ you do a swapbuffers.
|
||||
setting the variable, cause FLTK to assume that the
|
||||
back buffer must be completely redrawn after a swap.
|
||||
|
||||
This is easily tested by running the \p gl_overlay demo
|
||||
This is easily tested by running the \ref examples_gl_overlay demo
|
||||
program and seeing if the display is correct when you drag
|
||||
another window over it or if you drag the window off the screen
|
||||
and back on. You have to exit and run the program again for it
|
||||
@@ -453,7 +443,7 @@ void OptimizerWindow::draw() {
|
||||
\par The scene() Method
|
||||
|
||||
\par
|
||||
The \p >scene() method sets the scene to be drawn. The scene is
|
||||
The \p scene() method sets the scene to be drawn. The scene is
|
||||
a collection of 3D objects in a \p csGroup. The scene is redrawn
|
||||
after this call.
|
||||
|
||||
|
||||
@@ -47,10 +47,15 @@
|
||||
extern XFontStruct* fl_xxfont();
|
||||
#endif // USE_XFT
|
||||
|
||||
/** Returns the current font's height */
|
||||
int gl_height() {return fl_height();}
|
||||
/** Returns the current font's descent */
|
||||
int gl_descent() {return fl_descent();}
|
||||
/** Returns the width of the string in the current fnt */
|
||||
double gl_width(const char* s) {return fl_width(s);}
|
||||
/** Returns the width of n characters of the string in the current font */
|
||||
double gl_width(const char* s, int n) {return fl_width(s,n);}
|
||||
/** Returns the width of the character in the current font */
|
||||
double gl_width(uchar c) {return fl_width(c);}
|
||||
|
||||
static Fl_Font_Descriptor *gl_fontsize;
|
||||
@@ -65,6 +70,9 @@ static Fl_Font_Descriptor *gl_fontsize;
|
||||
# undef USE_OksiD_style_GL_font_selection // turn this off for XFT also
|
||||
#endif
|
||||
|
||||
/**
|
||||
Sets the current OpenGL font to the same font as calling fl_font()
|
||||
*/
|
||||
void gl_font(int fontid, int size) {
|
||||
fl_font(fontid, size);
|
||||
if (!fl_fontsize->listbase) {
|
||||
@@ -192,6 +200,10 @@ void gl_remove_displaylist_fonts()
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Draws an array of n characters of the string in the current font
|
||||
at the current position.
|
||||
*/
|
||||
void gl_draw(const char* str, int n) {
|
||||
#ifdef __APPLE__
|
||||
// Should be converting the text here, as for other platforms???
|
||||
@@ -223,24 +235,39 @@ void gl_draw(const char* str, int n) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Draws n charachters of the string in the current font at the given position
|
||||
*/
|
||||
void gl_draw(const char* str, int n, int x, int y) {
|
||||
glRasterPos2i(x, y);
|
||||
gl_draw(str, n);
|
||||
}
|
||||
|
||||
/**
|
||||
Draws n charachters of the string in the current font at the given position
|
||||
*/
|
||||
void gl_draw(const char* str, int n, float x, float y) {
|
||||
glRasterPos2f(x, y);
|
||||
gl_draw(str, n);
|
||||
}
|
||||
|
||||
/**
|
||||
Draws a nul-terminated string in the current font at the current position
|
||||
*/
|
||||
void gl_draw(const char* str) {
|
||||
gl_draw(str, strlen(str));
|
||||
}
|
||||
|
||||
/**
|
||||
Draws a nul-terminated string in the current font at the given position
|
||||
*/
|
||||
void gl_draw(const char* str, int x, int y) {
|
||||
gl_draw(str, strlen(str), x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
Draws a nul-terminated string in the current font at the given position
|
||||
*/
|
||||
void gl_draw(const char* str, float x, float y) {
|
||||
gl_draw(str, strlen(str), x, y);
|
||||
}
|
||||
@@ -250,6 +277,11 @@ static void gl_draw_invert(const char* str, int n, int x, int y) {
|
||||
gl_draw(str, n);
|
||||
}
|
||||
|
||||
/**
|
||||
Draws a string formatted into a box, with newlines and tabs expanded,
|
||||
other control characters changed to ^X. and aligned with the edges or
|
||||
center. Exactly the same output as fl_draw().
|
||||
*/
|
||||
void gl_draw(
|
||||
const char* str, // the (multi-line) string
|
||||
int x, int y, int w, int h, // bounding box
|
||||
@@ -259,6 +291,11 @@ void gl_draw(
|
||||
|
||||
void gl_measure(const char* str, int& x, int& y) {fl_measure(str,x,y);}
|
||||
|
||||
/**
|
||||
Outlines the given rectangle with the current color.
|
||||
If Fl_Gl_Window::ortho() has been called, then the rectangle will
|
||||
exactly fill the given pixel rectangle.
|
||||
*/
|
||||
void gl_rect(int x, int y, int w, int h) {
|
||||
if (w < 0) {w = -w; x = x-w;}
|
||||
if (h < 0) {h = -h; y = y-h;}
|
||||
@@ -276,6 +313,12 @@ extern uchar fl_overlay;
|
||||
extern int fl_overlay_depth;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Sets the curent OpenGL color to an FLTK color.
|
||||
|
||||
For color-index modes it will use fl_xpixel(c), which is only
|
||||
right if the window uses the default colormap!
|
||||
*/
|
||||
void gl_color(Fl_Color i) {
|
||||
#if HAVE_GL_OVERLAY
|
||||
#if defined(WIN32)
|
||||
|
||||
@@ -62,6 +62,7 @@ static Fl_Gl_Choice* gl_choice;
|
||||
|
||||
Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
|
||||
|
||||
/** Creates an OpenGL context */
|
||||
void gl_start() {
|
||||
if (!context) {
|
||||
#if defined(USE_X11)
|
||||
@@ -102,6 +103,7 @@ void gl_start() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Releases an OpenGL context */
|
||||
void gl_finish() {
|
||||
glFlush();
|
||||
#if !defined(WIN32) && !defined(__APPLE__)
|
||||
|
||||
Reference in New Issue
Block a user