HP Workstation zx2000, Workstation zx6000 Implementation Manual

OpenGL implementation guide
for HP-UX 11.X (IPF version)
Document Part Number: 5969-3152
june 2003
© 2003 Hewlett-Packard Company
ATI™ is used under license and are registered trademarks of ATI Technologies Inc. in the United States and other countries.
under license. X/Open® is a registered trademark, and the X device is a trademark of X/Open Company Ltd. in the UK and
other countries. Hewlett-Packard Company shall not be liable for technical or editorial errors or omissions contained herein or for
incidental or consequential damages in connection with the furnishing, performance, or use of this material. The information in this document is provided “as is” without warranty of any kind, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose, and is subject to change without notice. The warranties for HP products are set forth in the express limited warranty statements accompanying such products. Nothing herein should be construed as constituting an additional warranty.
This document contains proprietary information that is protected by copyright. No part of this document may be photocopied, reproduced, or translated to another language without the prior written consent of Hewlett-Packard Company.
WARNING: Text set off in this manner indicates that failure to follow directions could result in bodily
Å
harm or loss of life.
CAUTION: Text set off in this manner indicates that failure to follow directions could result in damage to
Ä
equipment or loss of information.
OpenGL implementation guide for HP-UX 11.X (IPF version) First Edition (june 2003)
Document Part Number: 5969-3152
contents
1 overview of OpenGL
introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–1
the OpenGL product. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–1
hp’s implementation of OpenGL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–2
standard OpenGL product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–6
mixing of OpenGL and Xlib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–7
gamma correction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–7
OpenGL extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–8
draw array set extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–8
3D texture extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–8
occlusion extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–12
visibility test extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–14
texture autogen MIPmap extension. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–16
X Window extensions for hp’s implementation of OpenGL. . . . . . . . . . . . . . . . . . . . . . . . . . . 1–16
rendering details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–19
default visuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–19
EXP and EXP2 fogging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–19
vertices outside of a begin/end pair. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–19
index mode dithering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–19
environment variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–20
2 installation and setup
verification instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–1
is your system software preloaded with instant ignition? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–1
verify that OpenGL is on your workstation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–1
installing OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–2
1. read this entire procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–2
2. install OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–2
3. check log file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–3
4. verify the product. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–3
the OpenGL file structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–3
3 running OpenGL programs
virtual GLX (VGL) mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–1
visual support for the VGL mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–1
special considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–1
running hp's implementation of the OpenGL stereo application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–2
OpenGL Implementation Guide iii
Contents
4 compiling and linking programs
overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–1
including header files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–2
linking shared libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–2
compiling 32-bit and 64-bit applications for OpenGL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–3
OpenGL procedure calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–3
5 programming hints
OpenGL correctness hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–1
4D values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–1
texture coordinates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–1
OpenGL performance hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–1
display list performance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–2
texture downloading performance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–5
selection performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–5
state change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–5
optimization of lighting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–6
occlusion culling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–6
high frame rate applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–6
rescaling normals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–7
iv OpenGL Implementation Guide
OpenGL is a hardware-independent application programming interface (API) that provides an interface to graphics operations. HP’s implementation of OpenGL converts API commands to graphical images via hardware and/or software functionality.
The information in this manual is valid only for OpenGL on IPF. For information on OpenGL on PA-RISC, refer to the PA-RISC version of the OpenGL Implementation Guide.
introduction
The OpenGL interface consists of a set of commands that allow applications to define and manipulate three-dimensional objects. The commands include:
geometric primitive definitions
viewing operations
lighting specifications
primitive attributes
1
overview of OpenGL
pipeline control
rasterization control
OpenGL has been implemented on a large number of vendor platforms where the graphics hardware supports a wide range of capabilities (for example, frame buffer only devices, fully accelerated devices, devices without a frame buffer, and so on).
For more information on OpenGL, refer to these documents, published by Addison-Wesley and shipped with HP’s implementation of OpenGL:
OpenGL Programming Guide
Instruction on programming in OpenGL, offered in a tutorial format.
OpenGL Reference Manual
A reference that contains details on all standard OpenGL functions, as well as utility (GLU) functions and X Window (GLX) functions.
OpenGL Programming for the X Window System
Instruction on interfacing OpenGL with the X Window system.
the OpenGL product
This section provides information about HP’ s implementation of the OpenGL product, as well as information about the standard OpenGL product.
OpenGL implementation guide 1–1
overview of OpenGL
hp’s implementation of OpenGL
Topics covered in this section are:
HP’s implementation of the OpenGL libraries
supported graphics devices
supported visuals
visual support for other graphics devices
buffer sharing between multiple processes
support for 64-bit programming
support for threads
hp’s implementation of the OpenGL libraries
The OpenGL product does not support archived libraries. HP’s implementation of OpenGL provides the following libraries:
libGL.so.2: Stub library that loads the appropriate rendering library
libXfGL.so.2: OpenGL library for use with XFree86
libGLU.so.2: OpenGL utilities library
There are two sets of libraries:
The path for the 32-bit libraries is:
/opt/graphics/OpenGL/lib/hpux32
The path for the 64-bit libraries is:
/opt/graphics/OpenGL/lib/hpux64
supported graphics devices
The graphics devices that support OpenGL on IPF are ATI Fire GL4, ATI FireGL X1, and ATI FireGL Z1.
1–2 OpenGL implementation guide
supported visuals
In this section, each visual table will have a graphics device associated with it. For information on visual support for graphics devices not in the above list, read the subsequent section “visual
support for other graphics devices” on page 1-4.
Visual Table for ATI Fire GL4
X Visual Information OpenGL GLX Information
overview of OpenGL
Class Depth Color
Map Size
Buffer Size
Overlay=1 or
Image=0
RGBA=1 or Index=0
Double Buffer
# Aux. Buffers
Color Buffer
Stencil Accumulation
Buffer
RGBA Z R G B A
PseudoColor 8 256 8 1 0 0 0 0000 0 0 0 0 0 0
PseudoColor 8 256 8 1 0 1 0 0000 0 0 0 0 0 0
TrueColor 24 256 24 0 1 0 0 8880 24 4 16 16 16 0
TrueColor 24 256 24 0 1 1 0 8880 24 4 16 16 16 0
TrueColor 24 256 32 0 1 0 0 8888 24 4 16 16 16 16
TrueColor 24 256 32 0 1 1 0 8888 24 4 16 16 16 16
Visual Table for ATI FireGL X1 and ATI FireGL Z1
X Visual Information OpenGL GLX Information
Class Depth Color
Map Size
Buffer Size
Overlay=1 or
Image=0
RGBA=1 or Index=0
Double Buffer
# Aux. Buffers
Color Buffer
Stencil Accumulation
Buffer
PseudoColor 8 256 8 1 0 0 0 0000 0 0 0 0 0 0
PseudoColor 8 256 8 1 0 1 0 0000 0 0 0 0 0 0
TrueColor 24 256 24 0 1 0 0 8880 24 8 16 16 16 0
TrueColor 24 256 24 0 1 1 0 8880 24 8 16 16 16 0
TrueColor 24 256 32 0 1 0 0 8888 24 8 16 16 16 16
TrueColor 24 256 32 0 1 1 0 8888 24 8 16 16 16 16
OpenGL implementation guide 1–3
RGBA Z R G B A
overview of OpenGL
stereo visual support for ATI Fire GL4
When a monitor is configured in a stereo capable mode, ATI Fire GL4 will have the following additional stereo visuals available. For more information on OpenGL stereo, read the section
“running hp's implementation of the OpenGL stereo application” on page 3-2.
Stereo Visual Support for ATI Fire GL4
X Visual InformationOpenGL GLX Information
Class Depth Color
Map Size
Buffer Size
Overlay=1 or
Image=0
RGBA=1 or Index=0
Double Buffer
Stereo # Aux.
Buffers
Color Buffer Stencil Accumulation
Buffer
RGBAZ R G B A
TrueColor 24 256 24 0 1 1 1 0 8 8 8 0 24 4 16 16 16 0
TrueColor 24 256 32 0 1 1 1 0 8 8 8 8 24 4 16 16 16 16
stereo visual support for ATI Fire GL4
Stereo is not supported in the initial release of the FireGL X1/Z1 driver. It will be supported in a future release.
visual support for other graphics devices
The OpenGL product can also be used with the Virtual Memory Driver (VMD) in Virtual GLX mode (VGL). VMD allows you to use many X11 dra wables (local or remote) as “virtual de vices” for three-dimensional graphics with OpenGL. This includes rendering to X terminals and other non-GLX extended X Servers.
Visual Table for VMD/VGL
X Visual Information OpenGL GLX Information
Class Depth Color
Map Size
Buffer Size
Overlay=1 or Image=0
RGBA=1 or Index=0
Double Buffer
# Aux. Buffers
Color Buffer Stencil Accumulation
Buffer
RGBA Z R G B A
PseudoColor 8 256 8 0 0 * 0 0000 24 4 0 0 0 0
PseudoColor 8 256 8 0 0 * 0 0000 0 0 0 0 0 0
TrueColor 8 256 8 1 1 * 0 3320 24 4 16 16 16 0
TrueColor 24 256 24 0 1 * 0 888** 24 4 16 16 16 16
*Double buffering is set to True (1) if the X visual supports the X double-buffering extension (DBE). **Alpha will only work correctly on 12- and 24-bit TrueColor and DirectColor visuals when the X Server does not use the high-order nybble/byte in the X visual. Also, note that when alpha is present, Buffer Size will be 16 for the 12-bit visuals and 32 for the 24-bit visuals.
1–4 OpenGL implementation guide
threads support
OpenGL supports Level 2 threads. This means HP OpenGL can be used in threaded applications, and more than one thread can use OpenGL.
Using OpenGL graphics in a kernel threaded application requires that the application link with libpthread.so (not the archived version, libpthread.a).
OpenGL libraries are not cancel safe or fork safe. A given context can only be current in one thread at a time. Enable your X11 library to use threads by calling XInitThreads () in your program. An example
of a threaded OpenGL program is given in /opt/graphics/OpenGL/demos/threads.
additional documentation
For more information on using threads, see the following documentation:
The http://docs.hp.com Web site (search for “Threads” and “Multiprocessing”)
The OpenGL Programming Guide
The OpenGL Reference Manual
Threadtime by S. Norton and M. Dipasquale
overview of OpenGL
OpenGL implementation guide 1–5
overview of OpenGL
64-bit programming
For information on porting your application to take advantage of 64-bit capabilities, see the
http://docs.hp.com
64-bit OpenGL allows “large data space” because the pointers are now 64-bit. But, the OpenGL data types themselves are the same as the 32-bit library. For example, GLint is a 32-bit integer, not a 64-bit long.
All 64-bit OpenGL libraries are located in /opt/graphics/OpenGL/lib/hpux64. The following sample compile and link lines may help you to build your application once it has been ported to take advantage of 64-bit capabilities:
Sample 32-bit compile and link:
cc -Ae -I/opt/graphics/OpenGL/include \
-I/usr/include/X11R6 -o cube.32 cube.c \
-L/opt/graphics/OpenGL/lib/hpux32 \
-L/usr/lib/hpux32/X11R6 -lGLU -lGL -lXhp11 -lXext -lX11 -lm
Sample 64-bit compile and link:
cc -Aa +DD64
-I/opt/graphics/OpenGL/include -I/usr/include/X11R6 -o cube.64 \ cube.c -L/opt/graphics/OpenGL/lib/hpux64 \
-L/usr/lib/hpux64/X11R6 -L/usr/lib/hpux64 -L/usr/lib \
-lGLU -lGL -lXhp11 -lXext -lX11 -lm
Web site. Search for “64-bit Computing” to find the topic on “Porting.”
standard OpenGL product
This section covers the following topics:
the OpenGL utilities library (GLU)
input and output routines
the OpenGL extensions for the X Window system (GLX)
OpenGL Utilities Library (GLU)
The OpenGL Utilities Library (GLU) provides a useful set of drawing routines that perform such tasks as:
generating texture coordinates
transforming coordinates
tessellating polygons
rendering surfaces
providing descriptions of curves and surfaces (NURBS)
handling errors
For a detailed description of these routines, refer to the Reference section or the OpenGL
Reference Manual.
input and output routines
OpenGL was designed to be independent of operating systems and window systems, therefore, it does not have commands that perform such tasks as opening a window. To obtain these capabilities, you will need to use X Windows routines (those whose names start with “glX”).
1–6 OpenGL implementation guide
the OpenGL extensions for the X Window system (GLX)
HP’s OpenGL implementation currently supports version 1.2 of the glx extension. The OpenGL Extension to the X Window System (GLX) provide routines for:
choosing a visual
managing the OpenGL rendering context
off-screen rendering
double buffering
using X fonts
For a detailed description of these routines, refer to the Reference section or the OpenGL
Reference Manual.
mixing of OpenGL and Xlib
The OpenGL implementation conforms to the specification definition for mixing Xlib and OpenGL rendering to the same drawable. The following points should be considered when mixing Xlib and OpenGL:
overview of OpenGL
OpenGL and Xlib renderers are implemented through separate pipelines and control streams.
Thus, rendering synchronization must be performed as necessary by the user’s application via the GLX glXWaitX() and glXWaitGL() function calls.
Xlib rendering does not affect the Z-buffer, so rendering in X and then OpenGL w ould result
in the OpenGL rendering replacing the Xlib rendering. This is true if the last OpenGL rendering to the Z-buffer at that location resulted in the depth test passing. Xlib rendering is always to the visible buffer (front buffer).
Note that mixing Xlib rendering with OpenGL rendering as well as with VMD, when using alpha buffers, can produce unexpected side effects and should be avoided.
gamma correction
Gamma correction is used to alter hardware colormaps to compensate for the non-linearities in the phosphor brightness of monitors. Gamma correction can be used to improve the “ropy” or modulated appearance of antialiased lines. Gamma correction is also used to improve the appearance of shaded graphics images, as well as scanned photographic images that have not already been gamma corrected. A utility for adjusting the display’s gamma correction is pro vided at /opt/graphics/common/bin/gamma.
For details on this feature, read the section “Gamma Correction” found in the Graphics
Administration Guide.
OpenGL implementation guide 1–7
overview of OpenGL
OpenGL extensions
The extensions listed in this section are extensions that HP has created; that is, in addition to those standard functions described in the OpenGL Programming Guide, OpenGL Reference Manual, and OpenGL Programming for the X Window System.
draw array set extension
For additional information, see Chapter 5, “programming hints.”
3D texture extension
The 3D-texture extension is useful for volumetric rendering of solid surfaces such as a marble vase, or for rendering images where geometric alignment is important (such as an MRI medical image). For this extension, the texture maps ha ve width and height as the y did for 2D, b ut also an additional dimension depth not included in 2D. The third coordinate forms a right-handed coordinate system, as the following illustration shows.
r (depth)
t (height)
s (width)
Right-Handed Coordinate System for 3D Texturing
Each MIPmap level consists of a block of data (see Each MIPmap is a Block in 3-D Texturing below). Each MIPmap level of the texture map is treated as being arranged in a sequence of adjacent rectangles. Each rectangle is a 2-dimensional image, so each MIPmap level is a (2m + 2b) (2n + 2b) (2l + 2b) block where b is a border width of either 0 or 1, and m, n and l are non-negative integers.
Each MIPmap is a Block in 3-D Texturing
1–8 OpenGL implementation guide
GL_LINEAR_MIPMAP_LINEAR Filtering may use Two Blocks
Enumerated Types for 3D Texturing
Extended Area Enumerated Type Description
overview of OpenGL
Pixel Storage GL_[UN]PACK_IMAGE_HEIGHT_EXT
Default: 0 for each
Pixel Storage GL_[UN]PACK_SKIP_IMAGES_EXT
Default: 0 for each
Texture Wrap Modes GL_TEXTURE_WRAP_R_EXT
Default: GL_REPEAT
Enable/Disable GL_MAX_3D_TEXTURE_SIZE_EXT,
GL_TEXTURE_BINDING_3D_EXT Default: N/A
Get Formats GL_MAX_3D_TEXTURE_SIZE_EXT,
GL_TEXTURE_BINDING_3D_EXT Default: N/A
Proxy GL_PROXY_TEXTURE_3D_EXT
Default: N/A
steps for 3D texturing programming
To use the 3D texture extension (see sample program below):
1. Enable the 3D texture extension using glEnable(GL_TEXTURE_3D_EXT);
The height of the image from which the texture is created; it supersedes the value of the height passed into glTexImage3DEXT.
The initial skip of contiguous rectangles of the texture.
The wrap mode applied to the r texture coordinate.
The method to enable/disable 3D texturing.
The maximum size of the 3D texture allowed; bind query
The proxy texture that can be used to query the configurations.
2. Create a 3D texture using glTexImage3DEXT;
3. Specify or generate the s, t and r texture coordinates using glTexGen or glTexCoord3*;
4. Specify other parameters such as filters just as you would for 2D texturing, but use GL_TEXTURE_3D_EXT for the target.
OpenGL implementation guide 1–9
Loading...
+ 29 hidden pages