mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 08:06:35 +08:00
OpenGL documentation fixes (included header files).
Also reformatted very long lines, removed trailing spaces. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12204 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -20,14 +20,14 @@ drawing your widgets. To do this you use the
|
|||||||
\ref opengl_gl_finish "gl_finish()"
|
\ref opengl_gl_finish "gl_finish()"
|
||||||
functions around your OpenGL code.
|
functions around your OpenGL code.
|
||||||
|
|
||||||
You must include FLTK's \p <FL/gl.h> header
|
You must include FLTK's \p <FL/gl.h> header file. It will include
|
||||||
file. It will include the file \p <GL/gl.h>, define
|
the file \p <GL/gl.h> (on macOS: \p <OpenGL/gl.h>), define
|
||||||
some extra drawing functions provided by FLTK, and include the
|
some extra drawing functions provided by FLTK, and include the
|
||||||
\p <windows.h> header file needed by WIN32
|
\p <windows.h> header file needed by WIN32 applications.
|
||||||
applications.
|
|
||||||
|
|
||||||
Some simple coding rules (see \ref osissues_retina) allow to write cross-platform code that will draw high resolution
|
Some simple coding rules (see \ref osissues_retina) allow to write
|
||||||
OpenGL graphics if run on 'retina' displays with Mac OS X.
|
cross-platform code that will draw high resolution
|
||||||
|
OpenGL graphics if run on 'retina' displays with MacOS.
|
||||||
|
|
||||||
\section opengl_subclass Making a Subclass of Fl_Gl_Window
|
\section opengl_subclass Making a Subclass of Fl_Gl_Window
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ int MyWindow::handle(int event) {
|
|||||||
case FL_DRAG:
|
case FL_DRAG:
|
||||||
... mouse moved while down event ...
|
... mouse moved while down event ...
|
||||||
return 1;
|
return 1;
|
||||||
case FL_RELEASE:
|
case FL_RELEASE:
|
||||||
... mouse up event ...
|
... mouse up event ...
|
||||||
return 1;
|
return 1;
|
||||||
case FL_FOCUS :
|
case FL_FOCUS :
|
||||||
@@ -146,7 +146,7 @@ set up! If your display changes, you should call
|
|||||||
call any OpenGL drawing functions from inside \p handle()!
|
call any OpenGL drawing functions from inside \p handle()!
|
||||||
|
|
||||||
You can call \e some OpenGL stuff like hit detection and texture
|
You can call \e some OpenGL stuff like hit detection and texture
|
||||||
loading functions by doing:
|
loading functions by doing:
|
||||||
|
|
||||||
\code
|
\code
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
@@ -224,7 +224,7 @@ get the drawable height so that you can flip the Y
|
|||||||
coordinates.
|
coordinates.
|
||||||
|
|
||||||
Unfortunately, there are a bunch of limitations you must
|
Unfortunately, there are a bunch of limitations you must
|
||||||
adhere to for maximum portability:
|
adhere to for maximum portability:
|
||||||
|
|
||||||
\li You must choose a default visual with Fl::gl_visual().
|
\li You must choose a default visual with Fl::gl_visual().
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ void gl_rect(int x, int y, int w, int h) <br>
|
|||||||
void gl_rectf(int x, int y, int w, int h)
|
void gl_rectf(int x, int y, int w, int h)
|
||||||
|
|
||||||
\par
|
\par
|
||||||
Outlines or fills a rectangle with the current color. If
|
Outlines or fills a rectangle with the current color. If
|
||||||
Fl_Gl_Window::ortho() has been called, then the rectangle will exactly
|
Fl_Gl_Window::ortho() has been called, then the rectangle will exactly
|
||||||
fill the pixel rectangle passed.
|
fill the pixel rectangle passed.
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ void OptimizerWindow::draw() {
|
|||||||
context_->makeCurrent(fl_display, fl_window);
|
context_->makeCurrent(fl_display, fl_window);
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
... perform other context setup as desired ...
|
... perform other context setup as desired ...
|
||||||
|
|
||||||
// Then create the draw action to handle drawing things...
|
// Then create the draw action to handle drawing things...
|
||||||
|
|
||||||
@@ -456,21 +456,26 @@ showing how to use OpenGL 3.0 (or higher versions) with FLTK in a cross-platform
|
|||||||
It contains also OpenGL3-glut-test.cxx which shows how to use FLTK's GLUT compatibility
|
It contains also OpenGL3-glut-test.cxx which shows how to use FLTK's GLUT compatibility
|
||||||
and OpenGL 3.
|
and OpenGL 3.
|
||||||
|
|
||||||
<b>On the MSWindows and Unix/Linux platforms</b>, FLTK creates contexts implementing
|
<b>On the MSWindows and Unix/Linux platforms</b>, FLTK creates contexts
|
||||||
the highest OpenGL version supported by the hardware,
|
implementing the highest OpenGL version supported by the hardware,
|
||||||
which are also compatible with lower OpenGL versions. Thus, FLTK allows
|
which are also compatible with lower OpenGL versions. Thus, FLTK allows
|
||||||
source code targeting any version of OpenGL. Access to functions from OpenGL versions above 1.1 requires to load function pointers at runtime on these platforms. FLTK recommends to use the GLEW library to perform this. It is therefore
|
source code targeting any version of OpenGL. Access to functions from OpenGL
|
||||||
necessary to install the GLEW library (see below). <b>On the Mac OS X platform</b>,
|
versions above 1.1 requires to load function pointers at runtime on these platforms.
|
||||||
FLTK creates by default contexts implementing OpenGL versions 1 or 2.
|
FLTK recommends to use the GLEW library to perform this. It is therefore
|
||||||
|
necessary to install the GLEW library (see below). <b>On the macOS platform</b>,
|
||||||
|
FLTK creates by default contexts implementing OpenGL versions 1 or 2.
|
||||||
To access OpenGL 3.0 (or higher versions), use the <tt>FL_OPENGL3</tt> flag (see below).
|
To access OpenGL 3.0 (or higher versions), use the <tt>FL_OPENGL3</tt> flag (see below).
|
||||||
Mac OS 10.7 or above is required; GLEW is possible but not necessary.
|
Mac OS 10.7 or above is required; GLEW is possible but not necessary.
|
||||||
|
|
||||||
\par GLEW installation (Unix/Linux and MSWindows platforms)
|
\par GLEW installation (Unix/Linux and MSWindows platforms)
|
||||||
GLEW is available as a package for most Linux distributions and in source form at http://glew.sourceforge.net/.
|
GLEW is available as a package for most Linux distributions and in source
|
||||||
For the MSWindows platform, a Visual Studio static library (glew32.lib) can be downloaded from the same web site; a MinGW-style static library (libglew32.a) can be built from source with the make command.
|
form at http://glew.sourceforge.net/.
|
||||||
|
For the MSWindows platform, a Visual Studio static library (glew32.lib) can
|
||||||
|
be downloaded from the same web site; a MinGW-style static library (libglew32.a)
|
||||||
|
can be built from source with the make command.
|
||||||
|
|
||||||
\par Source-level changes for OpenGL 3:
|
\par Source-level changes for OpenGL 3:
|
||||||
\li Put this in all OpenGL-using source files (instead of \#include <FL/gl.h>,
|
\li Put this in all OpenGL-using source files (instead of \#include <FL/gl.h>,
|
||||||
and before \#include <FL/glut.h> if you use GLUT):
|
and before \#include <FL/glut.h> if you use GLUT):
|
||||||
\code
|
\code
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
@@ -484,8 +489,8 @@ and before \#include <FL/glut.h> if you use GLUT):
|
|||||||
\endcode
|
\endcode
|
||||||
\li Add the <tt>FL_OPENGL3</tt> flag when calling Fl_Gl_Window::mode(int a)
|
\li Add the <tt>FL_OPENGL3</tt> flag when calling Fl_Gl_Window::mode(int a)
|
||||||
or glutInitDisplayMode().
|
or glutInitDisplayMode().
|
||||||
\li Put this in the <tt>handle(int event)</tt> member function of the first to be created
|
\li Put this in the <tt>handle(int event)</tt> member function of the first
|
||||||
among your Fl_Gl_Window-derived classes:
|
to be created among your Fl_Gl_Window-derived classes:
|
||||||
\code
|
\code
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
@@ -504,7 +509,7 @@ among your Fl_Gl_Window-derived classes:
|
|||||||
\endcode
|
\endcode
|
||||||
after the first glutCreateWindow() call.
|
after the first glutCreateWindow() call.
|
||||||
|
|
||||||
If GLEW is installed on the Mac OS development platform, it is possible
|
If GLEW is installed on the Mac OS development platform, it is possible
|
||||||
to use the same code for all platforms, with one exception: put
|
to use the same code for all platforms, with one exception: put
|
||||||
\code
|
\code
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -514,7 +519,7 @@ glewExperimental = GL_TRUE;
|
|||||||
before the glewInit() call.
|
before the glewInit() call.
|
||||||
|
|
||||||
\par Changes in the build process
|
\par Changes in the build process
|
||||||
Link with libGLEW.so (on Unix/Linux), libglew32.a (with MinGW) or glew32.lib
|
Link with libGLEW.so (on Unix/Linux), libglew32.a (with MinGW) or glew32.lib
|
||||||
(with MS Visual Studio); no change is needed on the Mac OS platform.
|
(with MS Visual Studio); no change is needed on the Mac OS platform.
|
||||||
|
|
||||||
\htmlonly
|
\htmlonly
|
||||||
|
|||||||
Reference in New Issue
Block a user