OGLImp.book Page 1 Tuesday, February 14, 2006 9:15 AM OpenGL Implementation Guide for HP-UX 11.
OGLImp.book Page 2 Tuesday, February 14, 2006 9:15 AM Legal Notices The information contained in this document is subject to change without notice. Hewlett-Packard assumes no responsibility for the use or reliability of its software on equipment that is not furnished by Hewlett-Packard. This document contains proprietary information that is protected by copyright. All rights reserved.
OGLImp.book Page 1 Tuesday, February 14, 2006 9:15 AM Contents 1. overview of OpenGL introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 the OpenGL product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 hp’s implementation of OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 hp’s implementation of the OpenGL libraries . .
OGLImp.book Page 2 Tuesday, February 14, 2006 9:15 AM Contents new environment variables as of release 1.05. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2. installation and setup verification instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . is your system software preloaded with instant ignition? . . . . . . . . . . . . . . . . . . . . . verify that OpenGL is on your workstation. . . . . . . . . . . . . . . . . . . . . . . .
OGLImp.book Page 3 Tuesday, February 14, 2006 9:15 AM Contents 5. programming hints OpenGL correctness hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4D values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . texture coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . OpenGL performance hints . . . . . . . . . . . . . .
OGLImp.
OGLImp.book Page 5 Tuesday, February 14, 2006 9:15 AM 1 overview of OpenGL 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.
OGLImp.book Page 6 Tuesday, February 14, 2006 9:15 AM overview of OpenGL introduction introduction The OpenGL interface consists of a set of commands that allow applications to define and manipulate three-dimensional objects.
OGLImp.book Page 7 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product the OpenGL product This section provides information about HP’s implementation of the OpenGL product, as well as information about the standard OpenGL product.
OGLImp.book Page 8 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product The arrows in the graphic represent symbolic links. /opt/graphics/OpenGL/lib libGL.1 libGL.2 libGL.s1 pa20_64 libGL.2 libGL.s1 In the library directory, you will see various versions. For example: • libGL.1 is a 10.20 compatible library for applications which were built on 10.20. • libGL.2 is the library which is for applications built on 11.x (this is why libGL.sl is a symbolic link to libGL.2).
OGLImp.book Page 9 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product 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.
OGLImp.book Page 10 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product Table 1-3 Visual Table for HP Fire GL-UX (Continued) X Visual Information OpenGL GLX Information Overlay=1 RGBA=1 Buffer or or Size Index=0 Image=0 Double # Aux.
OGLImp.book Page 11 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product Table 1-6 Stereo Visual Support for HP Fire GL-UX X Visual Information OpenGL GLX Information Class Color Depth Map Size Overlay RGBA= Double # Aux.
OGLImp.book Page 12 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product a. Depth- and stencil buffers are only allocated for image-plane visuals. b. Double buffering is set to True (1) if the X visual supports the X double-buffering extension (DBE). c. Alpha will only work correctly on 12- and 24-bit TrueColor and DirectColor visuals when the X server does not use the high-order nibble/byte in the X visual.
OGLImp.book Page 13 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product calls must be restricted to a single thread, which remains the same thread for the duration of the process. This is not the same as OpenGL calls being made in one thread at a time. Other threads can be used for computations, etc. Using OpenGL graphics in a Kernel threaded application requires that the application link with libpthread.sl (not the archived version, libpthread.a).
OGLImp.book Page 14 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product 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/pa20_64.
OGLImp.book Page 15 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product at some loss of performance. For full single display performance, define the HPOGL_SLS_LOCK_WINDOW environment variable before executing the program. The define value should be the display number where the window will reside. When the window is on this display, full performance can be had; when it is on other displays, the window will be blank. For more information see the XServer documentation of SLS.
OGLImp.book Page 16 Tuesday, February 14, 2006 9:15 AM overview of OpenGL the OpenGL product • • • 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.
OGLImp.book Page 17 Tuesday, February 14, 2006 9:15 AM overview of OpenGL mixing of OpenGL and Xlib mixing of OpenGL and Xlib The OpenGL implementation conforms to the specification definition for mixing of Xlib and OpenGL rendering to the same drawable.
OGLImp.book Page 18 Tuesday, February 14, 2006 9:15 AM overview of OpenGL Gamma correction 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.
OGLImp.book Page 19 Tuesday, February 14, 2006 9:15 AM overview of OpenGL OpenGL extensions OpenGL extensions The extensions listed in this section are extensions that Hewlett-Packard 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. visibility test extensions HP supports extensions for visibility testing and occlusion culling.
OGLImp.
OGLImp.book Page 21 Tuesday, February 14, 2006 9:15 AM overview of OpenGL OpenGL extensions GL_HP_supersample extension This supersample extension defines a mechanism for enabling and disabling a full scene anti-aliasing method. It is supported on Visualize fx-10b, FireGL-UX and FireGL T2/X1/X3 graphics hardware. On the FireGL hardware the X Server must be configured to enable this capability in order for the extension to be present.
OGLImp.book Page 22 Tuesday, February 14, 2006 9:15 AM overview of OpenGL rendering details rendering details This section provides the details for several of HP’s rendering capabilities. These rendering capabilities range from the way HP implements its default visuals to the way HP deals with the decomposition of concave quadrilaterals. default visuals Instead of placing the default visual in the deepest image buffer, HP puts the default visual in the overlay planes.
OGLImp.book Page 23 Tuesday, February 14, 2006 9:15 AM overview of OpenGL rendering details decomposition of concave quadrilaterals HP determines whether the concave quadrilateral will become front-facing or back-facing prior to dividing the quadrilateral into triangles. HP then divides the surface into two triangles between vertices zero and two or one and three depending on the vertex causing concavity.
OGLImp.book Page 24 Tuesday, February 14, 2006 9:15 AM overview of OpenGL environment variables environment variables Here is a list of environment variables used by HP’s implementation of OpenGL. HPOGL_ALLOW_LOCAL_INDIRECT_CONTEXTS This variable may be set if a need arises to really create a local indirect context. By default, if an indirect context is requested for a local HP display connection, a direct context will be created instead because the performance will be much better.
OGLImp.book Page 25 Tuesday, February 14, 2006 9:15 AM overview of OpenGL environment variables . This variable allows the user to specify the coordinate space to be used for lighting. By default, HP’s implementation of the OpenGL will select the lighting space. Possible values are: HPOGL_LIGHTING_SPACE=OC HPOGL_LIGHTING_SPACE=EC where OC = Object Coordinates and EC = Eye Coordinates. For details on the lighting space, see the sections “Lighting Space” and “Optimization of Lighting” found in Chapter 5.
OGLImp.book Page 26 Tuesday, February 14, 2006 9:15 AM overview of OpenGL environment variables Additionally, an application can programmatically switch between the slower and faster double buffering methods using the following new glHint calls: glHint(GL_BUFFER_SWAP_MODE_HINT_HP, GL_FASTEST); Switches to the faster double buffering method. glHint(GL_BUFFER_SWAP_MODE_HINT_HP, GL_NICEST); Switches to the slower double buffering method.
OGLImp.book Page 27 Tuesday, February 14, 2006 9:15 AM 2 installation and setup For HP-UX 11.X, the box containing the “HP-UX 11.0 Install and Core OS” CD-ROM will also hold a second CD-ROM entitled “HP-UX 11.0 Core Operating Systems Options.
OGLImp.book Page 28 Tuesday, February 14, 2006 9:15 AM installation and setup products are both available on the HP-UX 11.0 Core Operating Systems Options CD-ROM in the “Graphics and Technical Computing Software” bundle (B6268AA).
OGLImp.book Page 29 Tuesday, February 14, 2006 9:15 AM installation and setup verification instructions verification instructions This section provides you with the necessary information for determining if your OpenGL product has been installed. is your system software preloaded with instant ignition? Your workstation is preloaded with software, which may include OpenGL, if it was ordered with the Instant Ignition option.
OGLImp.book Page 30 Tuesday, February 14, 2006 9:15 AM installation and setup installing OpenGL installing OpenGL Installing the software involves the following steps: 1. Install OpenGL. 2. Check log file. 3. Verify the product. Each step is described on the subsequent sections. 1. install OpenGL For 11.00 and 11.11, OpenGL is bundled with the HP-UX Core Operating Systems Option CD-ROM in the “Graphics and Technical Computing Software” bundle B6268AA.
OGLImp.book Page 31 Tuesday, February 14, 2006 9:15 AM installation and setup installing OpenGL Table 2-1 Table 2-2 Chapter 2 OpenGL Development Environment Filesets for 11.0 and 11.
OGLImp.book Page 32 Tuesday, February 14, 2006 9:15 AM installation and setup installing OpenGL 2. check log file Once you have completed the installation process, look at the contents of the file /var/adm/sw/swinstall.log. This file lists the filesets loaded, the customize scripts that ran during the installation process, and informative messages. Error messages that resulted from attempts to write across an NFS mount point may appear in this file and, if present, may be ignored.
OGLImp.book Page 33 Tuesday, February 14, 2006 9:15 AM installation and setup installing OpenGL 3. verify the product Here are three methods for determining if you have correctly installed OpenGL on your system. • Run the program /opt/graphics/OpenGL/demos/verify_install If OpenGL has been correctly installed on your system, running verify_install will cause a window containing a 3D rendering of the text “OpenGL” to open on your monitor.
OGLImp.book Page 34 Tuesday, February 14, 2006 9:15 AM installation and setup the OpenGL file structure the OpenGL file structure The OpenGL file structure is compliant with the file structure of the 11.x file systems. Here is a list of files and directories that are a part of the OpenGL file structure. /opt/graphics/OpenGL/contrib/libwidget This directory contains a Motif widget library and source code. /opt/graphics/OpenGL/include/GL This directory contains header files needed for OpenGL development.
OGLImp.book Page 35 Tuesday, February 14, 2006 9:15 AM installation and setup the OpenGL file structure For 11.0 there are two sets of libraries, one for 64-bit and one for 32-bit. /opt/graphics/OpenGL/lib The 64-bit libraries are in a subdirectory: /opt/graphics/OpenGL/lib/pa20_64 The following graphic depicts the organization of these libraries, which follows the HP-UX standard for 64-bit libraries. In the library directory, you will see various versions. For example: • libGL.1 is a 10.
OGLImp.
OGLImp.book Page 37 Tuesday, February 14, 2006 9:15 AM 3 running OpenGL programs This chapter gives a description of the Virtual GLX mode, Virtual Memory Driver (VMD), and support of threaded applications.
OGLImp.book Page 38 Tuesday, February 14, 2006 9:15 AM running OpenGL programs virtual GLX (VGL) mode virtual GLX (VGL) mode Virtual GLX (VGL) defines a special transparent mode within hp's implementation of OpenGL that allows an hp client to render through OpenGL to X servers and/or X terminals that do not support OpenGL or the X server extension for GLX.
OGLImp.book Page 39 Tuesday, February 14, 2006 9:15 AM running OpenGL programs virtual GLX (VGL) mode • OpenGL and Xlib rendering when mixed and sent to the same drawable in VGL mode may behave differently than if a GLX capable X server were used. This is because in VGL mode OpenGL rendering is not strictly bounded by the limits of primitives rendered as is the case when a GLX server is used. In fact, rendering a single GLX primitive can result in repainting the entire drawable.
OGLImp.book Page 40 Tuesday, February 14, 2006 9:15 AM running OpenGL programs running hp's implementation of the OpenGL stereo application running hp's implementation of the OpenGL stereo application Following are the steps required to run hp's implementation of OpenGL "stereo in a window" mode: 1. Find out if your monitor is currently configured in a mode that supports stereo. This can be done by running the command: export DISPLAY=myhost:x.
OGLImp.book Page 41 Tuesday, February 14, 2006 9:15 AM running OpenGL programs running hp's implementation of the OpenGL stereo application After successfully re-configuring your monitor, the X Server will be restarted. If you are configuring a Visualize fx display proceed to you can verify the availability of GLX stereo visuals now by running the xglinfo command again. If you are configuring a FireGL graphics device an additional step is required.
OGLImp.
OGLImp.book Page 43 Tuesday, February 14, 2006 9:15 AM 4 compiling and linking programs This chapter provides information for including header files in your program, linking shared libraries, compiling 32-bit and 64-bit applications for OpenGL and OpenGL procedure calls.
OGLImp.book Page 44 Tuesday, February 14, 2006 9:15 AM compiling and linking programs overview overview Table 4-1 contains a list of the subdirectories in the directory /opt/graphics/OpenGL These subdirectories contain header files and libraries which may be used when compiling and linking your programs. Table 4-1 44 Subdirectory This Directory Contains... include/GL Header files needed for OpenGL development. lib 32-bit run-time shared libraries. lib/pa20_64 64-bit run-time shared libraries.
OGLImp.book Page 45 Tuesday, February 14, 2006 9:15 AM compiling and linking programs including header files including header files Most OpenGL programs and applications that only use the standard OpenGL data types, definitions, and function declarations, need only include the header file gl.h under the /opt/graphics/OpenGL/include/GL directory. Use the following syntax: #include Still other header files may be needed by your program, depending on your application.
OGLImp.book Page 46 Tuesday, February 14, 2006 9:15 AM compiling and linking programs linking shared libraries linking shared libraries OpenGL is supported on workstations using shared libraries that must be linked with the application program. When you compile your OpenGL programs, you must link the application with the OpenGL library libGL. Notice that the OpenGL library is dependent on the hp X extensions library (libXext).
OGLImp.book Page 47 Tuesday, February 14, 2006 9:15 AM compiling and linking programs compiling 32-bit and 64-bit applications for OpenGL compiling 32-bit and 64-bit applications for OpenGL 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 -g -Aa -D_hpUX_SOURCE -z \ -I/opt/graphics/OpenGL/include \ -I/usr/include/X11R6 -o cube.32 cube.
OGLImp.book Page 48 Tuesday, February 14, 2006 9:15 AM compiling and linking programs OpenGL procedure calls OpenGL procedure calls In order to facilitate maximum performance, the OpenGL library uses a unique procedure calling convention. This convention is supported only by the HP C and C++ compilers.
OGLImp.book Page 49 Tuesday, February 14, 2006 9:15 AM 5 programming hints The topics covered in this chapter are intended to give you some helpful programming hints as you begin to develop your OpenGL applications. Note that these hints are specific to hp’s implementation of OpenGL.
OGLImp.book Page 50 Tuesday, February 14, 2006 9:15 AM programming hints specific, see Appendix G in the OpenGL Programming Guide and section 6.6 “Maximizing OpenGL Performance” in the OpenGL Programming for the X Window System manual.
OGLImp.book Page 51 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL correctness hints OpenGL correctness hints Hints provided in this section are intended to help you correctly use HP’s implementation of OpenGL. 4D values When specifying 4D values, such as vertices, light positions, etc, if possible supply a w value that is not near the floating point limits of MINFLOAT or MAXFLOAT.
OGLImp.book Page 52 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints OpenGL performance hints Hints provided in this section are intended to help improve your applications performance when using HP’s implementation of OpenGL. display list performance The topics covered here are areas where you can gain substantial improvements in program performance when using OpenGL display lists.
OGLImp.book Page 53 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints draw array set extensions glDrawArraySethp is a Hewlett-Packard OpenGL 1.1 extension to vertex arrays which provides a high-speed mechanism for rendering multiple primitives. Use of glDrawArraySethp will be easy for applications which currently store geometry in vertex arrays and use multiple calls to glDrawArrays for rendering primitives from the arrays.
OGLImp.book Page 54 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints mode Specifies the primitive or primitives that will be created from the vertices. Ten symbolic constants are accepted: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON. list A sequence of starting indices in the enabled arrays. Each index is the start of a primitive in the set.
OGLImp.book Page 55 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints ... many more vertices... glEnd(); than this: glBegin(GL_TRIANGLES); glColor3f(1,2,3); glVertex3f(...); ... many more vertices... glEnd(); For performance efficiency avoid glMaterial state changes, especially within a glBegin/glEnd pair.
OGLImp.book Page 56 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints glNormal3fv(&v2); glVertex3fv(&p5); glNormal3fv(&v2); glVertex3fv(&p6); ... glEnd(); The reason this is faster is the display list can optimize this type of primitive into a single, very efficient structure. The small cost of adding extra data is offset by this optimization. Performance is increased by maximizing the number of vertices per Begin/End pair.
OGLImp.book Page 57 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints state change OpenGL state setting commands can be classified into two different categories. The first category is vertex-data commands. These are the calls that can occur between a glBegin/glEnd pair: glVertex glColor glIndex glNormal glEdgeFlag glMaterial glTexCoord The processing of these calls is very fast.
OGLImp.book Page 58 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints • Grouping your state changes together (that is, several modal state changes at one time), and then rendering primitives, will provide better performance than doing the modal state changes one by one and intermixing them with primitives. • Grouping primitives that require the same modal state together to minimize modal state changes.
OGLImp.book Page 59 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints • Single buffered applications • Alpha planes • Depth 8 visuals • Stereo • Gradient backgrounds rescaling normals When normal rescaling is enabled, a new operation is added to the transformation of the normal vector into eye coordinates. The normal vector is rescaled after it is multiplied by the inverse modelview matrix and before it is normalized.
OGLImp.book Page 60 Tuesday, February 14, 2006 9:15 AM programming hints OpenGL performance hints Therefore, if the modelview matrix is M, the transformed plane equation is: the rescaled normal is and the fully transformed normal is If rescaling is disabled, f is 1, otherwise f is computed as follows: Let mij denote the matrix element in row i and column j of M-1, numbering the topmost row of the matrix as row 1, and the left most column as column 1.