File: 00-README

package info (click to toggle)
haskell-glut 2.4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,624 kB
  • ctags: 28
  • sloc: haskell: 10,610; ansic: 121; makefile: 2
file content (189 lines) | stat: -rw-r--r-- 5,461 bytes parent folder | download | duplicates (16)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
This file lists the programs that are referenced in the OpenGL Programming
Guide, Fourth Edition, by chapter. For each program, the version of OpenGL
that is required is listed with the program.

Chapter 1: Introduction to OpenGL

        Hello.hs        (1.0)
        Double.hs       (1.0)

Chapter 2: State Management and Drawing Geometric Objects

        Lines.hs        (1.0)
        Polys.hs        (1.0)
        VArray.hs       (1.1)
        MVArray.hs      (1.4)

Chapter 3: Viewing

        Cube.hs         (1.0)
        Model.hs        (1.0)
        Clip.hs         (1.0)
        Planet.hs       (1.0)
        Robot.hs        (1.0)
        UnProject.hs    (1.1)

Chapter 4: Color

        Smooth.hs       (1.0)

Chapter 5: Lighting

        Light.hs        (1.0)
        MoveLight.hs    (1.0)
        Material.hs     (1.0)
        ColorMat.hs     (1.1)
        Scene.hs        (1.0)

Chapter 6: Blending, Antialiasing, Fog, and Polygon Offset

        BlendEqn.hs     (1.3 or ARB_imaging_subset)
        Alpha.hs        (1.0)
        Alpha3D.hs      (1.1)
        AARGB.hs        (1.1)
        AAIndex.hs      (1.1)
        Multisamp.hs    (1.3)
        Fog.hs          (1.0)
        FogIndex.hs     (1.0)
        FogCoord.hs     (1.4)
        PointP.hs       (1.4)
        PolyOff.hs      (1.1)

Chapter 7: Display Lists

        Torus.hs        (1.0)
        DList.hs        (1.0)
        Stroke.hs       (1.0)

Chapter 8: Drawing Pixels, Bitmaps, Fonts, and Images

        DrawF.hs        (1.0)
        Font.hs         (1.0)
        Image.hs        (1.1)
        ColorTable.hs   (ARB_imaging_subset)
        Convolution.hs  (ARB_imaging_subset)
        ColorMatrix.hs  (ARB_imaging_subset)
        Histogram.hs    (ARB_imaging_subset)
        Minmax.hs       (ARB_imaging_subset)

Chapter 9: Texture Mapping

        Checker.hs      (1.0)
        TexSub.hs       (1.1)
        Texture3D.hs    (1.2)
        Mipmap.hs       (1.0)
        TexBind.hs      (1.1)
        TexGen.hs       (1.1)
        CubeMap.hs      (1.3)
        MultiTex.hs     (1.3 or ARB_multitexture)
        Combiner.hs     (1.3)
        ShadowMap.hs    (1.4)
        Wrap.hs         (1.0)
        TexProx.hs      (1.1)

Chapter 10: The Framebuffer

        Stencil.hs      (1.0)
        AccPersp.hs     (1.0)
        AccAnti.hs      (1.0)
        DOF.hs          (1.0)

Chapter 11: Tessellators and Quadrics

        Tess.hs         (1.1)
        TessWind.hs     (1.1)
        Quadric.hs      (1.1)

Chapter 12: Evaluators and NURBS

        BezCurve.hs     (1.1)
        BezSurf.hs      (1.1)
        BezMesh.hs      (1.1)
        TextureSurf.hs  (1.1)
        Surface.hs      (1.1)
        SurfPoints.hs   (1.2)
        Trim.hs         (1.1)

Chapter 13: Selection and Feedback

        Select.hs       (1.1)
        PickSquare.hs   (1.0)
        PickDepth.hs    (1.0)
        Feedback.hs     (1.0)

Chapter 14: Now That You Know

        <No programs included>

Color Plates:

        Teapots.hs      (1.1)

Some remarks regarding the style of the programs:

To ease comparisons, the Haskell programs in this directory try to stay as
close to the original examples in C as possible. Consequently, they should
not be considered as examples for the best way to implement things in
Haskell.

The Haskell OpenGL binding uses overloading quite extensively, which makes
its use quite flexible, e.g.:

   class Vertex a where
      vertex  ::     a -> IO ()
      vertexv :: Ptr a -> IO ()

This single class subsumes all 24 vertex specification calls in OpenGL's C
binding, i.e. glVertex{234}{sifd}[v](), with the help of the following
class and instances:

   class VertexComponent a  -- an opaque class

   VertexComponent GLshort
   VertexComponent GLint
   VertexComponent GLfloat
   VertexComponent GLdouble

   VertexComponent a => Vertex (Vertex2 a)
   VertexComponent a => Vertex (Vertex3 a)
   VertexComponent a => Vertex (Vertex4 a)

There is a small inconvenience with this when used in "toy" programs:
Haskell's numeric literals are overloaded, too, so the programmer's help is
needed to disambiguate the type of expressions like:

   vertex (Vertex3 0 0 1)

Let's assume we mean the equivalent of glVertex3f() here. One can either
use an explicitly typed helper function:

   let vertex3f = vertex :: Vertex3 GLfloat -> IO ()
   in vertex3f (Vertex3 0 0 1)

This comes in handy when there are a lot of uses of vertex3f. An
alternative is to use a type annotation for the literal:

   vertex (Vertex3 0 0 (1 :: GLfloat))

or a type annotation for the vertex:

   vertex (Vertex3 0 0 1 :: Vertex3 GLfloat)

This is largely a matter of taste and normally not a problem in "real"
programs with type signatures for functions.

Sometimes different callbacks need to share some state, which is done via
global variables in the C examples. To achieve a unified presentation, all
Haskell examples use a `State' type for this purpose, which collects the
different parts of the global state, i.e. one or more IORefs. There are
alternatives for modeling this, which should be considered in own programs,
depending on the use cases:

 * Separate IORefs: This makes it explicit which parts of the program need
   which parts of the state.

 * A single IORef/MVar containing all the state: This enables one to change
   the whole state atomically, which is often quite handy in multithreaded
   programs.

 * A custom monad: This can hide all the state threading behind the scenes.