OpenGL for Win32
A picture is worth a thousand words.
*** The contents of this page are obsolete ***
OpenGL is the most widely adopted, cross-platform standard for 3D rendering
and 3D hardware acceleration. The software runtime library ships with all
Windows, MacOS, Linux and Unix systems.
OpenGL is built for compatibility across hardware and operating systems.
This architecture makes it easy to port OpenGL programs from one system to
The OpenGL Perl module allows a Perl program to use OpenGL by letting it
make OpenGL function calls.
You will find here a ppm package for this module. It uses
GLUT for Win32, a
port by Nate Robins of the original GLUT (OpenGL Utility Toolkit) library written by Mark
This is a port of the version 0.54 of the module. All the functions
supported by the module (and by Windows) works now.
Of course, the GLX library is not implemented: it's an OpenGL library for
the X Window System. So, don't use the
glx* functions in your
script! Caution: the
glpOpenWindow function uses internaly some
GLX functions; don't use it.
- The WGL library is not implemented. I'm working on this extension. Be patient!
- I increased the doc but it remains light well:
Implementation dependent differences:
(from the Nate Robins readme-file README-win32.txt )
There are a few differences between the Win32 version of GLUT and the X11
version of GLUT. Those are outlined here. Note that MOST of these
differences are allowed by the GLUT specification. Bugs and unsupported
features are outlined in the next section.
The following command line options have no meaning (and are ignored) in
GLUT for Win32: -display, -indirect, -direct, -sync.
- glutInitWindowPosition, glutPositionWindow:
Win32 has two different coordinate systems for windows. One is in terms
of client space and the other is the whole window space (including the
decorations). If you glutPositionWindow(0, 0), GLUT for Win32 will place
the window CLIENT area at 0, 0. This will cause the window decorations
(title bar and left edge) to be OFF-SCREEN, but it gives the user the
most flexibility in positioning. HOWEVER, if the user specifies
glutInitWindowPosition(0, 0), the window is placed relative to window
space at 0, 0. This will cause the window to be opened in the upper left
corner with all the decorations showing. This behaviour is acceptable
under the current GLUT specification.
- glutSetIconTitle, glutSetWindowTitle:
There is no separation between Icon title and Window title in Win32.
Therefore, setting an icon title in Win32 has no effect.
As indicated in the GLUT specification, cursors may be different on
different platforms. This is the case in GLUT for Win32. For the most
part, the cursors will match the meaning, but not necessarily the shape.
Notable exceptions are the GLUT_CURSOR_INFO & GLUT_CURSOR_SPRAY which use
the crosshair cursor and the GLUT_CURSOR_CYCLE which uses the 'no' or
'destroy' cursor in Win32.
Win32 seems to be unable to determine if a window is fully obscured.
Therefore, the visibility of a GLUT window is only reflected by its
Iconic, Hidden or Shown state. That is, even if a window is fully
obscured, in GLUT for Win32, it is still "visible".
Window Focus is handled differently in Win32 and X. Specifically, the
"window manager" in Win32 uses a "click to focus" policy. That is, in
order for a window to receive focus, a mouse button must be clicked in
it. Likewise, in order for a window to loose focus, a mouse button must
be clicked outside the window (or in another window). Therefore, the
Enter and Leave notification provided by GLUT may behave differently in
the Win32 and in X11 versions. There is a viable workaround for this. A
program called "Tweak UI" is provided by Microsoft which can be used to
change the focus policy in Win32 to "focus follows mouse". It is
available from the Microsoft Web Pages:
GLUT for Win32 always copies the colormap. There is never any sharing of
colormaps. This is probably okay, since Win32 merges the logical palette
and the physical palette anyway, so even if there are two windows with
totally different colors in their colormaps, Win32 will find a
(hopefully) good match between them.
- glutIdleFunc + menus: The glut idle function will NOT be called when
a menu is active. This causes all animation to stop when a menu is active
(in general, this is probably okay). Timer functions will still fire, however.
If the timer callback draws into the rendering context, the drawing will not
show up until after the menu has finished, though.
Win32 only likes to work with left and right mouse buttons. Especially so
with popup menus. Therefore, when attaching the menu to the middle mouse
button, the LEFT mouse button must be used to select from the menu.
- glutSpaceball*, glutButtonBox*, glutTablet*, glutDials*:
None of the special input devices are supported at this time.
When resizing or moving a GLUT for Win32 window, no updating is
performed. This causes the window to leave "tracks" on the screen when
getting bigger or when previously obscured parts are being revealed. I
put in a bit of a kludgy workaround for those that absolutely can't have
the weird lines. The reshape callback is called multiple times for
reshapes. Therefore, in the reshape callback, some drawing can be done.
It should probably be limited to a color buffer clear.
The video resizing capabilities of GLUT 3.3+ for X11 is currently
unimplemented (this is probably ok, since it really isn't part of the
spec until 4.0). I doubt that this will ever be part of GLUT for Win32,
since there is no hardware to support it. A hack could simply change the
resolution of the desktop.
The package is in my
If you are using ActiveState's Perl distribution (Perl5.6 or Perl5.8),
the easiest way to install this module is to use
Type (or cut & paste) this command in a DOS console:
ppm install http://www.bribes.org/perl/ppm/OpenGL.ppd
The documentation, in html format, is at its usual location.
You can download the patched source file here:
Instructions for compiling the module with MSVC++ are in the
You can also use this patch:
Keep in mind that this module is still in beta stage for Windows.
Report bug (for this version only) to
To test the module, I translated in Perl some classic C programs for OpenGL.
Download the package (
demos.zip) and run
the scripts to test the module on your machine.
The last screenshot is the one of the script
adaptation in Perl of the Chris Halsall's programme
Back to Top
BðP © 2004 J-L Morel - Contact : email@example.com