OpenGL under Xeffort
Displaying OpenGL graphics in Xeffort windows.
Version 1.0
16-Oct-2006
You’ll
need Xeffort of course, and our XOpenGL package (at page bottom) which contains
routines that adapt Xeffort windows to accommodate OpenGL.
You’ll
need the f90gl and f90glu libraries by William
F. Mitchell. Compiled versions of
these libraries are available for HP/Compaq/Digital
Visual Fortran and for Intel
Fortran
You’ll
also need to learn OpenGL programming.
The standard books are “OpenGL Programming Guide – The Official Guide to
Learning OpenGL” and “OpenGL Reference Manual – The Official Reference Document
to OpenGL”, both by the OpenGL Architecture Review Board.
The
libraries mentioned above also contain a package named GLUT that runs the
message loop. We will NOT be using GLUT
because we want Xeffort to run the message loop, create X_Windows, etc. We also assume the X_Windows containing
OpenGL graphics are intended for output display only, i.e., do not solicit
input from the user.
In what
we call the “pure” mode, a window that contains OpenGL graphics contains only
OpenGL graphics, i.e., everything that appears in the window was generated by a
call to an OpenGL routine. Pure OpenGL
windows can produce lovely animation (I use it to display vibration patterns of
mechanical systems and structures.)
However, practical animation often involves creating a separate thread
to continuously update the animation window.
For proper implementation of threads you might want to consider the fthreads package. An overview of this package is avaliable in
the Visual
Fortran Newletter - Issue VII
Now for
“GDI” mode. There is a Microsoft
extension (which sometimes works) that allows GDI graphics (Xeffort’s XLine,
XTextOut, etc.) to be mixed with OpenGL graphics in the same window. These mixed-mode windows are suitable only
for static display.
A
sample project that uses multiple mixed-mode windows is available for download
below.
X_Windows
that are to contain OpenGL graphics should have the WS_CLIPCHILDREN and
WS_CLIPSIBLINGS styles. They should NOT
be given the WS_EX_DBLBUFFERED extended Xeffort style. (Special OpenGL double-buffering is
automatically applied to animations.)
Windows
that display OpenGL graphics are required to be derived from a class that has
the CS_OWNDC style. This is standard
for X_Windows so no special action is needed to meet this requirement.
After creating the X_Window that is to receive OpenGL graphics, call XOpenGLinit passing the xWnd structure, then issue the OpenGL commands, then call XOpenGLshow to update the display. Before destroying the window call XOpenGLfree to prevent memory leaks. Include USE XOpenGL in any routine that references the XOpenGL and/or OpenGL routines, since this USE will make all required modules available.