| 1 |
This file lists the programs that are referenced in the OpenGL Programming |
| 2 |
Guide, Fourth Edition, by chapter. For each program, the version of OpenGL |
| 3 |
that is required is listed with the program. |
| 4 |
|
| 5 |
Chapter 1: Introduction to OpenGL |
| 6 |
|
| 7 |
Hello.hs (1.0) |
| 8 |
Double.hs (1.0) |
| 9 |
|
| 10 |
Chapter 2: State Management and Drawing Geometric Objects |
| 11 |
|
| 12 |
Lines.hs (1.0) |
| 13 |
Polys.hs (1.0) |
| 14 |
VArray.hs (1.1) |
| 15 |
MVArray.hs (1.4) |
| 16 |
|
| 17 |
Chapter 3: Viewing |
| 18 |
|
| 19 |
Cube.hs (1.0) |
| 20 |
Model.hs (1.0) |
| 21 |
Clip.hs (1.0) |
| 22 |
Planet.hs (1.0) |
| 23 |
Robot.hs (1.0) |
| 24 |
UnProject.hs (1.1) |
| 25 |
|
| 26 |
Chapter 4: Color |
| 27 |
|
| 28 |
Smooth.hs (1.0) |
| 29 |
|
| 30 |
Chapter 5: Lighting |
| 31 |
|
| 32 |
Light.hs (1.0) |
| 33 |
MoveLight.hs (1.0) |
| 34 |
Material.hs (1.0) |
| 35 |
ColorMat.hs (1.1) |
| 36 |
Scene.hs (1.0) |
| 37 |
|
| 38 |
Chapter 6: Blending, Antialiasing, Fog, and Polygon Offset |
| 39 |
|
| 40 |
BlendEqn.hs (1.3 or ARB_imaging_subset) |
| 41 |
Alpha.hs (1.0) |
| 42 |
Alpha3D.hs (1.1) |
| 43 |
AARGB.hs (1.1) |
| 44 |
AAIndex.hs (1.1) |
| 45 |
Multisamp.hs (1.3) |
| 46 |
Fog.hs (1.0) |
| 47 |
FogIndex.hs (1.0) |
| 48 |
FogCoord.hs (1.4) |
| 49 |
PointP.hs (1.4) |
| 50 |
PolyOff.hs (1.1) |
| 51 |
|
| 52 |
Chapter 7: Display Lists |
| 53 |
|
| 54 |
Torus.hs (1.0) |
| 55 |
DList.hs (1.0) |
| 56 |
Stroke.hs (1.0) |
| 57 |
|
| 58 |
Chapter 8: Drawing Pixels, Bitmaps, Fonts, and Images |
| 59 |
|
| 60 |
DrawF.hs (1.0) |
| 61 |
Font.hs (1.0) |
| 62 |
Image.hs (1.1) |
| 63 |
ColorTable.hs (ARB_imaging_subset) |
| 64 |
Convolution.hs (ARB_imaging_subset) |
| 65 |
ColorMatrix.hs (ARB_imaging_subset) |
| 66 |
Histogram.hs (ARB_imaging_subset) |
| 67 |
Minmax.hs (ARB_imaging_subset) |
| 68 |
|
| 69 |
Chapter 9: Texture Mapping |
| 70 |
|
| 71 |
Checker.hs (1.0) |
| 72 |
TexSub.hs (1.1) |
| 73 |
Texture3D.hs (1.2) |
| 74 |
Mipmap.hs (1.0) |
| 75 |
TexBind.hs (1.1) |
| 76 |
TexGen.hs (1.1) |
| 77 |
CubeMap.hs (1.3) |
| 78 |
MultiTex.hs (1.3 or ARB_multitexture) |
| 79 |
Combiner.hs (1.3) |
| 80 |
ShadowMap.hs (1.4) |
| 81 |
Wrap.hs (1.0) |
| 82 |
TexProx.hs (1.1) |
| 83 |
|
| 84 |
Chapter 10: The Framebuffer |
| 85 |
|
| 86 |
Stencil.hs (1.0) |
| 87 |
AccPersp.hs (1.0) |
| 88 |
AccAnti.hs (1.0) |
| 89 |
DOF.hs (1.0) |
| 90 |
|
| 91 |
Chapter 11: Tessellators and Quadrics |
| 92 |
|
| 93 |
Tess.hs (1.1) |
| 94 |
TessWind.hs (1.1) |
| 95 |
Quadric.hs (1.1) |
| 96 |
|
| 97 |
Chapter 12: Evaluators and NURBS |
| 98 |
|
| 99 |
BezCurve.hs (1.1) |
| 100 |
BezSurf.hs (1.1) |
| 101 |
BezMesh.hs (1.1) |
| 102 |
TextureSurf.hs (1.1) |
| 103 |
Surface.hs (1.1) |
| 104 |
SurfPoints.hs (1.2) |
| 105 |
Trim.hs (1.1) |
| 106 |
|
| 107 |
Chapter 13: Selection and Feedback |
| 108 |
|
| 109 |
Select.hs (1.1) |
| 110 |
PickSquare.hs (1.0) |
| 111 |
PickDepth.hs (1.0) |
| 112 |
Feedback.hs (1.0) |
| 113 |
|
| 114 |
Chapter 14: Now That You Know |
| 115 |
|
| 116 |
<No programs included> |
| 117 |
|
| 118 |
Color Plates: |
| 119 |
|
| 120 |
Teapots.hs (1.1) |
| 121 |
|
| 122 |
Some remarks regarding the style of the programs: |
| 123 |
|
| 124 |
To ease comparisons, the Haskell programs in this directory try to stay as |
| 125 |
close to the original examples in C as possible. Consequently, they should |
| 126 |
not be considered as examples for the best way to implement things in |
| 127 |
Haskell. |
| 128 |
|
| 129 |
The Haskell OpenGL binding uses overloading quite extensively, which makes |
| 130 |
its use quite flexible, e.g.: |
| 131 |
|
| 132 |
class Vertex a where |
| 133 |
vertex :: a -> IO () |
| 134 |
vertexv :: Ptr a -> IO () |
| 135 |
|
| 136 |
This single class subsumes all 24 vertex specification calls in OpenGL's C |
| 137 |
binding, i.e. glVertex{234}{sifd}[v](), with the help of the following |
| 138 |
class and instances: |
| 139 |
|
| 140 |
class VertexComponent a -- an opaque class |
| 141 |
|
| 142 |
VertexComponent GLshort |
| 143 |
VertexComponent GLint |
| 144 |
VertexComponent GLfloat |
| 145 |
VertexComponent GLdouble |
| 146 |
|
| 147 |
VertexComponent a => Vertex (Vertex2 a) |
| 148 |
VertexComponent a => Vertex (Vertex3 a) |
| 149 |
VertexComponent a => Vertex (Vertex4 a) |
| 150 |
|
| 151 |
There is a small inconvenience with this when used in "toy" programs: |
| 152 |
Haskell's numeric literals are overloaded, too, so the programmer's help is |
| 153 |
needed to disambiguate the type of expressions like: |
| 154 |
|
| 155 |
vertex (Vertex3 0 0 1) |
| 156 |
|
| 157 |
Let's assume we mean the equivalent of glVertex3f() here. One can either |
| 158 |
use an explicitly typed helper function: |
| 159 |
|
| 160 |
let vertex3f = vertex :: Vertex3 GLfloat -> IO () |
| 161 |
in vertex3f (Vertex3 0 0 1) |
| 162 |
|
| 163 |
This comes in handy when there are a lot of uses of vertex3f. An |
| 164 |
alternative is to use a type annotation for the literal: |
| 165 |
|
| 166 |
vertex (Vertex3 0 0 (1 :: GLfloat)) |
| 167 |
|
| 168 |
or a type annotation for the vertex: |
| 169 |
|
| 170 |
vertex (Vertex3 0 0 1 :: Vertex3 GLfloat) |
| 171 |
|
| 172 |
This is largely a matter of taste and normally not a problem in "real" |
| 173 |
programs with type signatures for functions. |
| 174 |
|
| 175 |
Sometimes different callbacks need to share some state, which is done via |
| 176 |
global variables in the C examples. To achieve a unified presentation, all |
| 177 |
Haskell examples use a `State' type for this purpose, which collects the |
| 178 |
different parts of the global state, i.e. one or more IORefs. There are |
| 179 |
alternatives for modeling this, which should be considered in own programs, |
| 180 |
depending on the use cases: |
| 181 |
|
| 182 |
* Separate IORefs: This makes it explicit which parts of the program need |
| 183 |
which parts of the state. |
| 184 |
|
| 185 |
* A single IORef/MVar containing all the state: This enables one to change |
| 186 |
the whole state atomically, which is often quite handy in multithreaded |
| 187 |
programs. |
| 188 |
|
| 189 |
* A custom monad: This can hide all the state threading behind the scenes. |