HP Workstation zx2000 HP OpenGL Implementation Guide for HP-UX 11.X (IPF versi - Page 35

programming hints, OpenGL correctness hints, 4D values, texture coordinates

Page 35 highlights

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. For further information on OpenGL programming hints that are not HP 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. The programming hints in this chapter are covered in these sections: ■ OpenGL correctness hints ■ OpenGL performance 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, and so on, if possible supply a w value that is not near the floating point limits of MINFLOAT or MAXFLOAT. Using w values near the floating point limits increases the likelihood of floating point precision errors in calculations such as lighting, transformations, and perspective division. Also, for best accuracy and performance, normalize your 4D positions such that w is 1.0. For example, instead of specifying a 4D position like (0.0, 0.0, 5e10, 1.5e38) use the equivalent normalized position (0.0, 0.0, 3.33e-28, 1.0). texture coordinates When using non-orthographic projection, keep in mind the texture coordinates will be divided by w as an intermediate calculation. HP's implementation of OpenGL estimates that for VMD, the texture coordinates used in perspective projections will have only five significant digits of precision. Therefore, when you have texturing close to a window edge and the decomposition of the primitive causes the vertices to have very closely-spaced texture coordinates after perspective projection, you may see loss of texturing precision. This loss of precision may make the texture primitive seem locally smeared. OpenGL performance hints Hints provided in this section are intended to help improve your applications performance when using HP's implementation of OpenGL. OpenGL implementation guide 5-1

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

OpenGL implementation guide
5–1
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. For further information on OpenGL programming hints that are not
HP 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.
The programming hints in this chapter are covered in these sections:
OpenGL correctness hints
OpenGL performance 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, and so on, if possible supply a
w
value that is not near the floating point limits of
MINFLOAT
or
MAXFLOAT
. Using
w
values near
the floating point limits increases the likelihood of floating point precision errors in calculations
such as lighting, transformations, and perspective division.
Also, for best accuracy and performance, normalize your 4D positions such that
w
is
1.0
. For
example, instead of specifying a 4D position like (0.0, 0.0, 5e10, 1.5e38) use the equivalent
normalized position (0.0, 0.0, 3.33e-28, 1.0).
texture coordinates
When using non-orthographic projection, keep in mind the texture coordinates will be divided by
w
as an intermediate calculation. HP’s implementation of OpenGL estimates that for VMD, the
texture coordinates used in perspective projections will have only five significant digits of
precision. Therefore, when you have texturing close to a window edge and the decomposition of
the primitive causes the vertices to have very closely-spaced texture coordinates after perspective
projection, you may see loss of texturing precision. This loss of precision may make the texture
primitive seem locally smeared.
OpenGL performance hints
Hints provided in this section are intended to help improve your applications performance when
using HP’s implementation of OpenGL.