[m-rev.] for review: updates for opengl binding

Julien Fischer juliensf at students.cs.mu.OZ.AU
Mon Aug 18 14:31:49 AEST 2003


On Sun, 17 Aug 2003, Fergus Henderson wrote:

> >         Use `.' as a module qualifier rather than `__' or `:'.
>
> Support for "." as a module qualifier is a fairly recently addition.
> In general I would recommend that packages in mercury-extras should
> avoid depending on Mercury features that are not yet present in the
> latest public release of Mercury if it is not necessary.
> So please don't do this to any more packages in the extras directory
> until Mercury 0.12 is released.
>
> However, since you have already done it for this package, you may as
> well go ahead and commit it (once you have addressed the other review
> comments, of course).
>
Ralph suggested considerering s/io\.state/io/g.  This would remove most
of the module qualifiers anyway.  I'll do this and change
the remaining few back to `__'.

> >         Add some missing MR_* prefixes.
>
> For Float -> MR_Float, fine and good.
> For assert() -> MR_assert(), this is probably not appropriate --
> see my comment below.
>
I've changed these back to assert().

> >         Remove comments referring to section numbers in version 1.1 of
> >         the OpenGL spec.
>
> Removing the section numbers, fine.
> But please don't remove the comments themselves.
>
I worded that badly -- I meant to say that I'd removed the section
numbers not the comments themselves (excepting the case where the comment
was the section number).

> > Index: mogl.m
> >  %------------------------------------------------------------------------------%
> > -%
> > -% 2.5	GL Errors
> > -%
> > -%------------------------------------------------------------------------------%
> > -
>
> In the implementation section of this module,
> you have removed the section heading comments entirely.
> I don't think that is a good idea -- I find the section
> headings useful.  So please don't remove them.
>
Done.

> >         Make the formatting and layout of the modules consistent.
>
> Good... but please also make sure that the formatting and layout
> of the modules is consistent with the code elsewhere in the Mercury
> implementation.  Such layout conventions should be documented in the
> Mercury coding standards (compiler/notes/coding_standards.html).
>
I've modified the layout of foreign_procs. so that they are more
consistent with code elsewhere in the Mercury implementation.

> The layout of the if-then-elses here isn't consistent with the layout
> used in compiler/*.m.
>
Changed them back to the ->; form.

A relative diff that addresses these review comments (except for the
stuff regarding module qualifiers) follows:


diff -u mglu.m mglu.m
--- mglu.m	13 Aug 2003 14:40:06 -0000
+++ mglu.m	17 Aug 2003 17:17:26 -0000
@@ -18,7 +18,9 @@
 :- import_module float, int, io, bool.

 %-----------------------------------------------------------------------------%
+%
 % Viewing transformations
+%

 :- pred look_at(float, float, float, float, float, float, float, float, float,
 		io.state, io.state).
@@ -28,7 +30,9 @@
 :- mode perspective(in, in, in, in, di, uo) is det.

 %-----------------------------------------------------------------------------%
+%
 % Quadric functions
+%

 :- type quadric.

@@ -79,7 +83,7 @@
 :- mode disk(in, in, in, in, in, di, uo) is det.

 :- pred partial_disk(quadric, float, float, int, int, float,
-		float, io.state, io.state).
+	float, io.state, io.state).
 :- mode partial_disk(in, in, in, in, in, in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
@@ -93,25 +97,34 @@
 ").

 %------------------------------------------------------------------------------%
+%
+% Viewing transformations
+%

-:- pragma foreign_proc("C", look_at(Ex::in, Ey::in, Ez::in, Cx::in, Cy::in,
-		Cz::in, Ux::in, Uy::in, Uz::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	look_at(Ex::in, Ey::in, Ez::in, Cx::in, Cy::in, Cz::in, Ux::in, Uy::in,
+		Uz::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluLookAt((GLdouble) Ex, (GLdouble) Ey, (GLdouble) Ez,
 		(GLdouble) Cx, (GLdouble) Cy, (GLdouble) Cz,
 		(GLdouble) Ux, (GLdouble) Uy, (GLdouble) Uz);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", perspective(Fovy::in, Asp::in, N::in, F::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	perspective(Fovy::in, Asp::in, N::in, F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluPerspective((GLdouble) Fovy, (GLdouble) Asp,
 		(GLdouble) N, (GLdouble) F);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Quadric functions
+%

 :- pragma foreign_type("C", quadric, "GLUquadric *").

@@ -174,14 +187,18 @@
 bool_to_int(yes) = 1.
 bool_to_int(no) = 0.

-:- pragma foreign_proc("C", new_quadric(Q::out, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	new_quadric(Q::out, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	Q = gluNewQuadric();
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", delete_quadric(Q::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	delete_quadric(Q::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluDeleteQuadric(Q);
 	IO = IO0;
 ").
@@ -192,8 +209,10 @@
 :- pred quadric_draw_style2(quadric, int, io.state, io.state).
 :- mode quadric_draw_style2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", quadric_draw_style2(Q::in, S::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	quadric_draw_style2(Q::in, S::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluQuadricDrawStyle(Q, quadric_draw_style_flags[S]);
 	IO = IO0;
 ").
@@ -204,8 +223,10 @@
 :- pred quadric_orientation2(quadric, int, io.state, io.state).
 :- mode quadric_orientation2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", quadric_orientation2(Q::in, O::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	quadric_orientation2(Q::in, O::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluQuadricOrientation(Q, quadric_orientation_flags[O]);
 	IO = IO0;
 ").
@@ -216,8 +237,10 @@
 :- pred quadric_normals2(quadric, int, io.state, io.state).
 :- mode quadric_normals2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", quadric_normals2(Q::in, N::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	quadric_normals2(Q::in, N::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluQuadricNormals(Q, quadric_normals_flags[N]);
 	IO = IO0;
 ").
@@ -228,36 +251,43 @@
 :- pred quadric_texture2(quadric, int, io.state, io.state).
 :- mode quadric_texture2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", quadric_texture2(Q::in, B::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	quadric_texture2(Q::in, B::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluQuadricTexture(Q, B);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", cylinder(Q::in, BR::in, TR::in, H::in, SL::in,
-			ST::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	cylinder(Q::in, BR::in, TR::in, H::in, SL::in, ST::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluCylinder(Q, BR, TR, H, SL, ST);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", sphere(Q::in, R::in, SL::in, ST::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	sphere(Q::in, R::in, SL::in, ST::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluSphere(Q, R, SL, ST);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", disk(Q::in, IR::in, OR::in, S::in, L::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	disk(Q::in, IR::in, OR::in, S::in, L::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluDisk(Q, IR, OR, S, L);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", partial_disk(Q::in, IR::in, OR::in, S::in, L::in,
-		STA::in, SWA::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	partial_disk(Q::in, IR::in, OR::in, S::in, L::in, STA::in, SWA::in,
+		IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	gluPartialDisk(Q, IR, OR, S, L, STA, SWA);
 	IO = IO0;
 ").
diff -u mogl.m mogl.m
--- mogl.m	13 Aug 2003 14:56:11 -0000
+++ mogl.m	18 Aug 2003 04:10:50 -0000
@@ -21,7 +21,9 @@
 :- import_module io, int, float, list, bool.

 %------------------------------------------------------------------------------%
+%
 % GL Errors.
+%

 :- type mogl.error
 	--->	no_error
@@ -36,7 +38,9 @@
 :- mode get_error(out, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Begin/End objects.
+%

 :- type block_mode
 	--->	points
@@ -60,7 +64,9 @@
 :- mode edge_flag(in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Vertex specification
+%

 :- pred vertex2(float, float, io.state, io.state).
 :- mode vertex2(in, in, di, uo) is det.
@@ -93,7 +99,9 @@
 :- mode color4(in, in, in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Coordinate transformations.
+%

 :- pred depth_range(float, float, io.state, io.state).
 :- mode depth_range(in, in, di, uo) is det.
@@ -163,7 +171,9 @@
 :- mode tex_gen(in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Clipping.
+%

 :- type	clip_plane --->
 		clip(float, float, float, float).
@@ -172,7 +182,9 @@
 :- mode clip_plane(in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Current raster position.
+%

 :- pred raster_pos2(float, float, io.state, io.state).
 :- mode raster_pos2(in, in, di, uo) is det.
@@ -184,7 +196,9 @@
 :- mode raster_pos4(in, in, in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Colors and coloring.
+%

 :- type face_direction	--->	cw ; ccw .

@@ -246,13 +260,17 @@
 :- mode shade_model(in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Points.
+%

 :- pred point_size(float, io.state, io.state).
 :- mode point_size(in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Line segments.
+%

 :- pred line_width(float, io.state, io.state).
 :- mode line_width(in, di, uo) is det.
@@ -261,7 +279,9 @@
 :- mode line_stipple(in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Polygons.
+%

 :- type polygon_stipple == int.		% use bottom 32 bits of each int.

@@ -283,7 +303,9 @@
 :- mode polygon_offset(in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Pixel Rectangles.
+%

 /*

@@ -350,7 +372,9 @@
 */

 %------------------------------------------------------------------------------%
+%
 % Bitmaps.
+%

 /*
 :- pred bitmap(int, int, float, float, float, float, list(int),
@@ -359,7 +383,9 @@
 */

 %------------------------------------------------------------------------------%
+%
 % Texturing.
+%

 /*

@@ -384,7 +410,9 @@
 */

 %------------------------------------------------------------------------------%
+%
 % Fog.
+%

 :- type fog_parameter
 		--->	fog_mode(fog_mode)
@@ -401,7 +429,9 @@
 :- mode fog(in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Per-fragment operations.
+%

 /*

@@ -488,7 +518,9 @@
 */

 %------------------------------------------------------------------------------%
+%
 % Whole framebuffer operations.
+%

 :- type buffer
 	--->	none
@@ -553,12 +585,16 @@
 :- mode accum(in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Evaluators.
+%

 % Evalutators not implemented

 %------------------------------------------------------------------------------%
+%
 % Selection.
+%

 /*

@@ -586,7 +622,9 @@
 */

 %------------------------------------------------------------------------------%
+%
 % Display lists.
+%

 :- type display_list_mode
 	--->	compile
@@ -608,7 +646,9 @@
 :- mode delete_lists(in, in, di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Flush and Finish.
+%

 :- pred flush(io.state, io.state).
 :- mode flush(di, uo) is det.
@@ -617,7 +657,9 @@
 :- mode finish(di, uo) is det.

 %------------------------------------------------------------------------------%
+%
 % Enable/Disable.
+%

 :- type	control_flag
 		--->	normalize
@@ -661,6 +703,9 @@
 ").

 %------------------------------------------------------------------------------%
+%
+% GL Errors.
+%

 :- func error_to_int(int::in) = (mogl.error::out) is semidet.

@@ -682,9 +727,10 @@
 :- pred get_error2(int, io.state, io.state).
 :- mode get_error2(out, di, uo) is det.

-:- pragma foreign_proc("C", get_error2(Err::out, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	get_error2(Err::out, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	static GLenum errcodes[] = {
 		GL_NO_ERROR,
 		GL_INVALID_ENUM,
@@ -712,6 +758,9 @@
 }").

 %------------------------------------------------------------------------------%
+%
+% Begin/End objects.
+%

 :- func block_mode_to_int(block_mode) = int.

@@ -751,14 +800,18 @@
 :- pred begin2(int, io.state, io.state).
 :- mode begin2(in, di, uo) is det.

-:- pragma foreign_proc("C", begin2(Mode::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	begin2(Mode::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glBegin(block_mode_flags[Mode]);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", end(IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	end(IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glEnd();
 	IO = IO0;
 ").
@@ -771,16 +824,23 @@
 :- pred edge_flag2(int, io.state, io.state).
 :- mode edge_flag2(in, di, uo) is det.

-:- pragma foreign_proc("C", edge_flag2(F::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	edge_flag2(F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glEdgeFlag((GLboolean) F);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Vertex specification
+%

-:- pragma foreign_proc("C", vertex2(X::in, Y::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	vertex2(X::in, Y::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glVertex2f((GLfloat) X, (GLfloat) Y);
@@ -792,8 +852,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", vertex3(X::in, Y::in, Z::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	vertex3(X::in, Y::in, Z::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glVertex3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
@@ -805,9 +867,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", vertex4(X::in, Y::in, Z::in, W::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	vertex4(X::in, Y::in, Z::in, W::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glVertex4f((GLfloat) X, (GLfloat) Y, (GLfloat) Z, (GLfloat) W);
@@ -822,8 +885,10 @@

 %------------------------------------------------------------------------------%

-:- pragma foreign_proc("C", tex_coord1(X::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	tex_coord1(X::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glTexCoord1f((GLfloat) X);
@@ -835,8 +900,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", tex_coord2(X::in, Y::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	tex_coord2(X::in, Y::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glTexCoord2f((GLfloat) X, (GLfloat) Y);
@@ -848,8 +915,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", tex_coord3(X::in, Y::in, Z::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	tex_coord3(X::in, Y::in, Z::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glTexCoord3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
@@ -861,9 +930,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", tex_coord4(X::in, Y::in, Z::in, W::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	tex_coord4(X::in, Y::in, Z::in, W::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glTexCoord4f((GLfloat) X, (GLfloat) Y, (GLfloat) Z,
@@ -879,8 +949,10 @@

 %------------------------------------------------------------------------------%

-:- pragma foreign_proc("C", normal3(X::in, Y::in, Z::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	normal3(X::in, Y::in, Z::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glNormal3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
@@ -894,8 +966,10 @@

 %------------------------------------------------------------------------------%

-:- pragma foreign_proc("C", color3(R::in, G::in, B::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	color3(R::in, G::in, B::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glColor3f((GLfloat) R, (GLfloat) G, (GLfloat) B);
@@ -907,9 +981,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", color4(R::in, G::in, B::in, A::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	color4(R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glColor4f((GLfloat) R, (GLfloat) G, (GLfloat) B, (GLfloat) A);
@@ -923,16 +998,22 @@
 ").

 %------------------------------------------------------------------------------%
+%
+% Coordinate transformations.
+%

-:- pragma foreign_proc("C", depth_range(Near::in, Far::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	depth_range(Near::in, Far::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glDepthRange((GLclampd) Near, (GLclampd) Far);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", viewport(X::in, Y::in, Wdth::in, Hght::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	viewport(X::in, Y::in, Wdth::in, Hght::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glViewport((GLint) X, (GLint) Y, (GLsizei) Wdth, (GLsizei) Hght);
 	IO = IO0;
 ").
@@ -963,8 +1044,10 @@
 :- pred matrix_mode2(int, io.state, io.state).
 :- mode matrix_mode2(in, di, uo) is det.

-:- pragma foreign_proc("C", matrix_mode2(I::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	matrix_mode2(I::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glMatrixMode(matrix_mode_flags[I]);
 	IO = IO0;
 ").
@@ -995,7 +1078,8 @@
 		A5::in, A6::in, A7::in, A8::in,
 		A9::in, A10::in, A11::in, A12::in,
 		A13::in, A14::in, A15::in, A16::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		GLfloat	a[16];
@@ -1049,7 +1133,8 @@
 		A5::in, A6::in, A7::in, A8::in,
 		A9::in, A10::in, A11::in, A12::in,
 		A13::in, A14::in, A15::in, A16::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+	[will_not_call_mercury, promise_pure],
+"
 	if (sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		GLfloat	a[16];
@@ -1077,15 +1162,18 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", load_identity(IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	load_identity(IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glLoadIdentity();
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", rotate(Theta::in, X::in, Y::in, Z::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	rotate(Theta::in, X::in, Y::in, Z::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if(sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glRotatef((GLfloat) Theta,
@@ -1097,8 +1185,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", translate(X::in, Y::in, Z::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	translate(X::in, Y::in, Z::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if(sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glTranslatef((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
@@ -1108,8 +1198,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", scale(X::in, Y::in, Z::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	scale(X::in, Y::in, Z::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if(sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glScalef((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
@@ -1119,30 +1211,36 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", frustum(L::in, R::in, B::in, T::in, N::in, F::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	frustum(L::in, R::in, B::in, T::in, N::in, F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFrustum((GLdouble) L, (GLdouble) R, (GLdouble) B,
 		(GLdouble) T, (GLdouble) N, (GLdouble) F);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", ortho(L::in, R::in, B::in, T::in, N::in, F::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	ortho(L::in, R::in, B::in, T::in, N::in, F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glOrtho((GLdouble) L, (GLdouble) R, (GLdouble) B,
 		(GLdouble) T, (GLdouble) N, (GLdouble) F);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", push_matrix(IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	push_matrix(IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glPushMatrix();
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", pop_matrix(IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	pop_matrix(IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glPopMatrix();
 	IO = IO0;
 ").
@@ -1169,9 +1267,9 @@

 :- func texture_gen_parameter_to_int(texture_gen_parameter) = int.

-texture_gen_parameter_to_int(object_linear)	= 0.
-texture_gen_parameter_to_int(eye_linear)	= 1.
-texture_gen_parameter_to_int(sphere_map)	= 2.
+texture_gen_parameter_to_int(object_linear) = 0.
+texture_gen_parameter_to_int(eye_linear)    = 1.
+texture_gen_parameter_to_int(sphere_map)    = 2.

 :- pragma foreign_decl("C", "
 	extern const GLenum texture_gen_flags[];
@@ -1196,8 +1294,10 @@
 :- pred tex_genf2a(int, int, io.state, io.state).
 :- mode tex_genf2a(in, in, di, uo) is det.

-:- pragma foreign_proc("C", tex_genf2a(Coord::in, Param::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	tex_genf2a(Coord::in, Param::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glTexGeni(texture_coord_flags[Coord], GL_TEXTURE_GEN_MODE,
 		texture_gen_flags[Param]);
 	IO = IO0;
@@ -1206,22 +1306,29 @@
 :- pred tex_genf2b(int, float, io.state, io.state).
 :- mode tex_genf2b(in, in, di, uo) is det.

-:- pragma foreign_proc("C", tex_genf2b(Coord::in, Param::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-	glTexGend(texture_coord_flags[Coord], GL_OBJECT_PLANE, (GLdouble) Param);
+:- pragma foreign_proc("C",
+	tex_genf2b(Coord::in, Param::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
+	glTexGend(texture_coord_flags[Coord], GL_OBJECT_PLANE, (GLdouble)Param);
 	IO = IO0;
 ").

 :- pred tex_genf2c(int, float, io.state, io.state).
 :- mode tex_genf2c(in, in, di, uo) is det.

-:- pragma foreign_proc("C", tex_genf2c(Coord::in, Param::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	tex_genf2c(Coord::in, Param::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glTexGend(texture_coord_flags[Coord], GL_EYE_PLANE, (GLdouble) Param);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Clipping.
+%

 clip_plane(Num, clip(X, Y, Z, W), !IO) :-
 	clip_plane2(Num, X, Y, Z, W, !IO).
@@ -1229,10 +1336,10 @@
 :- pred clip_plane2(int, float, float, float, float, io.state, io.state).
 :- mode clip_plane2(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", clip_plane2(I::in, X::in, Y::in, Z::in, W::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	clip_plane2(I::in, X::in, Y::in, Z::in, W::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLdouble p[4];

 	p[0] = (GLdouble) X;
@@ -1244,9 +1351,14 @@
 }").

 %------------------------------------------------------------------------------%
+%
+% Current raster position.
+%

-:- pragma foreign_proc("C", raster_pos2(X::in, Y::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	raster_pos2(X::in, Y::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if(sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glRasterPos2f((GLfloat) X, (GLfloat) Y);
@@ -1256,8 +1368,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", raster_pos3(X::in, Y::in, Z::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	raster_pos3(X::in, Y::in, Z::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if(sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glRasterPos3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
@@ -1267,9 +1381,10 @@
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", raster_pos4(X::in, Y::in, Z::in, W::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	raster_pos4(X::in, Y::in, Z::in, W::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	if(sizeof(MR_Float) == sizeof(GLfloat))
 	{
 		glRasterPos4f((GLfloat) X, (GLfloat) Y, (GLfloat) Z,
@@ -1282,6 +1397,9 @@
 ").

 %------------------------------------------------------------------------------%
+%
+% Colors and coloring.
+%

 :- func face_direction_to_int(face_direction) = int.

@@ -1361,8 +1479,10 @@
 :- pred front_face2(int, io.state, io.state).
 :- mode front_face2(in, di, uo) is det.

-:- pragma foreign_proc("C", front_face2(F::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	front_face2(F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFrontFace(face_direction_flags[F]);
 	IO = IO0;
 ").
@@ -1385,10 +1505,10 @@
 :- pred material_ambient(int, float, float, float, float, io.state, io.state).
 :- mode material_ambient(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", material_ambient(F::in, R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	material_ambient(F::in, R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1402,10 +1522,10 @@
 :- pred material_diffuse(int, float, float, float, float, io.state, io.state).
 :- mode material_diffuse(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", material_diffuse(F::in, R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	material_diffuse(F::in, R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1420,10 +1540,11 @@
 	io.state).
 :- mode material_ambient_and_diffuse(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", material_ambient_and_diffuse(F::in, R::in, G::in,
-		B::in, A::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	material_ambient_and_diffuse(F::in, R::in, G::in, B::in, A::in, IO0::di,
+		IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1437,10 +1558,10 @@
 :- pred material_specular(int, float, float, float, float, io.state, io.state).
 :- mode material_specular(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", material_specular(F::in, R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	material_specular(F::in, R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1454,10 +1575,10 @@
 :- pred material_emission(int, float, float, float, float, io.state, io.state).
 :- mode material_emission(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", material_emission(F::in, R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	material_emission(F::in, R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1471,9 +1592,10 @@
 :- pred material_shininess(int, float, io.state, io.state).
 :- mode material_shininess(in, in, di, uo) is det.

-:- pragma foreign_proc("C", material_shininess(F::in, S::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	material_shininess(F::in, S::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glMaterialf(face_side_flags[F], GL_SHININESS, (GLfloat) S);
 	IO = IO0;
 }").
@@ -1481,10 +1603,10 @@
 :- pred material_color_indexes(int, float, float, float, io.state, io.state).
 :- mode material_color_indexes(in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", material_color_indexes(F::in, R::in, G::in, B::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	material_color_indexes(F::in, R::in, G::in, B::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[3];

 	params[0] = (GLfloat) R;
@@ -1518,10 +1640,10 @@
 :- pred light_ambient(int, float, float, float, float, io.state, io.state).
 :- mode light_ambient(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_ambient(F::in, R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_ambient(F::in, R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1535,10 +1657,10 @@
 :- pred light_diffuse(int, float, float, float, float, io.state, io.state).
 :- mode light_diffuse(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_diffuse(F::in, R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_diffuse(F::in, R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1552,10 +1674,10 @@
 :- pred light_specular(int, float, float, float, float, io.state, io.state).
 :- mode light_specular(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_specular(F::in, R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_specular(F::in, R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) R;
@@ -1569,10 +1691,10 @@
 :- pred light_position(int, float, float, float, float, io.state, io.state).
 :- mode light_position(in, in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_position(F::in, X::in, Y::in, Z::in, W::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_position(F::in, X::in, Y::in, Z::in, W::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[4];

 	params[0] = (GLfloat) X;
@@ -1586,10 +1708,10 @@
 :- pred light_spot_direction(int, float, float, float, io.state, io.state).
 :- mode light_spot_direction(in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_spot_direction(F::in, I::in, J::in, K::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_spot_direction(F::in, I::in, J::in, K::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat	params[3];

 	params[0] = (GLfloat) I;
@@ -1602,9 +1724,10 @@
 :- pred light_spot_exponent(int, float, io.state, io.state).
 :- mode light_spot_exponent(in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_spot_exponent(F::in, E::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_spot_exponent(F::in, E::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glLightf(F + GL_LIGHT0, GL_SPOT_EXPONENT, (GLfloat) E);
 	IO = IO0;
 }").
@@ -1612,9 +1735,10 @@
 :- pred light_spot_cutoff(int, float, io.state, io.state).
 :- mode light_spot_cutoff(in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_spot_cutoff(F::in, E::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_spot_cutoff(F::in, E::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glLightf(F + GL_LIGHT0, GL_SPOT_CUTOFF, (GLfloat) E);
 	IO = IO0;
 }").
@@ -1622,10 +1746,10 @@
 :- pred light_constant_attenuation(int, float, io.state, io.state).
 :- mode light_constant_attenuation(in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_constant_attenuation(F::in, E::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_constant_attenuation(F::in, E::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glLightf(F + GL_LIGHT0, GL_CONSTANT_ATTENUATION, (GLfloat) E);
 	IO = IO0;
 }").
@@ -1633,10 +1757,10 @@
 :- pred light_linear_attenuation(int, float, io.state, io.state).
 :- mode light_linear_attenuation(in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_linear_attenuation(F::in, E::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_linear_attenuation(F::in, E::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glLightf(F + GL_LIGHT0, GL_LINEAR_ATTENUATION, (GLfloat) E);
 	IO = IO0;
 }").
@@ -1644,10 +1768,10 @@
 :- pred light_quadratic_attenuation(int, float, io.state, io.state).
 :- mode light_quadratic_attenuation(in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_quadratic_attenuation(F::in, E::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_quadratic_attenuation(F::in, E::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glLightf(F + GL_LIGHT0, GL_QUADRATIC_ATTENUATION, (GLfloat) E);
 	IO = IO0;
 }").
@@ -1667,10 +1791,10 @@
 :- pred light_model_ambient(float, float, float, float, io.state, io.state).
 :- mode light_model_ambient(in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", light_model_ambient(R::in, G::in, B::in, A::in,
-		IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_model_ambient(R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	GLfloat params[4];

 	params[0] = (GLfloat) R;
@@ -1684,9 +1808,10 @@
 :- pred light_model_local_viewer(int, io.state, io.state).
 :- mode light_model_local_viewer(in, di, uo) is det.

-:- pragma foreign_proc("C", light_model_local_viewer(F::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_model_local_viewer(F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (GLint) F);
 	IO = IO0;
 }").
@@ -1694,9 +1819,10 @@
 :- pred light_model_two_side(int, io.state, io.state).
 :- mode light_model_two_side(in, di, uo) is det.

-:- pragma foreign_proc("C", light_model_two_side(F::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	light_model_two_side(F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"{
 	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (GLint) F);
 	IO = IO0;
 }").
@@ -1708,9 +1834,10 @@
 :- pred color_material2(int, int, io.state, io.state).
 :- mode color_material2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", color_material2(Face::in, Mode::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	color_material2(Face::in, Mode::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glColorMaterial(face_side_flags[Face], color_material_mode_flags[Mode]);
 	IO = IO0;
 ").
@@ -1721,35 +1848,52 @@
 :- pred shade_model2(int, io.state, io.state).
 :- mode shade_model2(in, di, uo) is det.

-:- pragma foreign_proc("C", shade_model2(Model::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	shade_model2(Model::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glShadeModel(shade_model_flags[Model]);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Points.
+%

-:- pragma foreign_proc("C", point_size(Size::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	point_size(Size::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glPointSize((GLfloat) Size);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Line segments.
+%

-:- pragma foreign_proc("C", line_width(Size::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	line_width(Size::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glLineWidth((GLfloat) Size);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", line_stipple(Fac::in, Pat::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	line_stipple(Fac::in, Pat::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glLineStipple((GLint) Fac, (GLushort) Pat);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Polygons.
+%

 :- func polygon_mode_to_int(polygon_mode) = int.

@@ -1775,8 +1919,10 @@
 :- pred cull_face2(int, io.state, io.state).
 :- mode cull_face2(in, di, uo) is det.

-:- pragma foreign_proc("C", cull_face2(F::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	cull_face2(F::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glCullFace(face_side_flags[F]);
 	IO = IO0;
 ").
@@ -1793,21 +1939,26 @@
 :- pred polygon_mode2(int, int, io.state, io.state).
 :- mode polygon_mode2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", polygon_mode2(Face::in, Mode::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	polygon_mode2(Face::in, Mode::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glPolygonMode(face_side_flags[Face], polygon_mode_flags[Mode]);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", polygon_offset(Fac::in, Units::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	polygon_offset(Fac::in, Units::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glPolygonOffset((GLfloat) Fac, (GLfloat) Units);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Pixel Rectangles.
+%

 /*

@@ -1875,9 +2026,8 @@

 %------------------------------------------------------------------------------%
 %
-% 3.7	Bitmaps
+% Bitmaps
 %
-%------------------------------------------------------------------------------%

 /*
 :- pred bitmap(int, int, float, float, float, float, list(int),
@@ -1887,9 +2037,8 @@

 %------------------------------------------------------------------------------%
 %
-% 3.8	Texturing
+% Texturing
 %
-%------------------------------------------------------------------------------%

 /*
 :- type texture_target
@@ -1912,6 +2061,9 @@
 */

 %------------------------------------------------------------------------------%
+%
+% Fog.
+%

 :- func fog_mode_to_int(fog_mode) = int.

@@ -1943,8 +2095,10 @@
 :- pred fog_mode(int, io.state, io.state).
 :- mode fog_mode(in, di, uo) is det.

-:- pragma foreign_proc("C", fog_mode(M::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	fog_mode(M::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFogi(GL_FOG_MODE, (GLint) fog_mode_flags[M]);
 	IO = IO0;
 ").
@@ -1952,8 +2106,10 @@
 :- pred fog_density(float, io.state, io.state).
 :- mode fog_density(in, di, uo) is det.

-:- pragma foreign_proc("C", fog_density(P::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	fog_density(P::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFogf(GL_FOG_DENSITY, (GLfloat) P);
 	IO = IO0;
 ").
@@ -1961,8 +2117,10 @@
 :- pred fog_start(float, io.state, io.state).
 :- mode fog_start(in, di, uo) is det.

-:- pragma foreign_proc("C", fog_start(P::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	fog_start(P::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFogf(GL_FOG_START, (GLfloat) P);
 	IO = IO0;
 ").
@@ -1970,15 +2128,21 @@
 :- pred fog_end(float, io.state, io.state).
 :- mode fog_end(in, di, uo) is det.

-:- pragma foreign_proc("C", fog_end(P::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	fog_end(P::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFogf(GL_FOG_END, (GLfloat) P);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%
+%
+% Per-fragment operations.
+%

 /*
+
 :- pred scissor(int, int, int, int, io__state, io__state).
 :- mode scissor(in, in, in, in, di, uo) is det.

@@ -2058,9 +2222,13 @@
 		;	nand
 		;	set
 		.
+
 */

 %------------------------------------------------------------------------------%
+%
+% Whole framebuffer operations.
+%

 :- func buffer_to_int(buffer) = int.

@@ -2105,14 +2273,18 @@
 :- pred draw_buffer2(int, io.state, io.state).
 :- mode draw_buffer2(in, di, uo) is det.

-:- pragma foreign_proc("C", draw_buffer2(B::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	draw_buffer2(B::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glDrawBuffer(buffer_flags[B]);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", index_mask(I::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	index_mask(I::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glIndexMask((GLuint) I);
 	IO = IO0;
 ").
@@ -2124,9 +2296,10 @@
 :- pred color_mask2(int, int, int, int, io.state, io.state).
 :- mode color_mask2(in, in, in, in, di, uo) is det.

-:- pragma foreign_proc("C", color_mask2(A::in, B::in, C::in, D::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	color_mask2(A::in, B::in, C::in, D::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glColorMask((GLboolean) A, (GLboolean) B, (GLboolean) C, (GLboolean) D);
 	IO = IO0;
 ").
@@ -2137,14 +2310,18 @@
 :- pred depth_mask2(int, io.state, io.state).
 :- mode depth_mask2(in, di, uo) is det.

-:- pragma foreign_proc("C", depth_mask2(M::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	depth_mask2(M::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glDepthMask((GLboolean) M);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", stencil_mask(M::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	stencil_mask(M::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glStencilMask((GLuint) M);
 	IO = IO0;
 ").
@@ -2166,9 +2343,10 @@

 :- func lookup_buffer_bit(int)	= int.

-:- pragma foreign_proc("C", lookup_buffer_bit(F::in) = (B::out),
-	[will_not_call_mercury, promise_pure], "
-{
+:- pragma foreign_proc("C",
+	lookup_buffer_bit(F::in) = (B::out),
+	[will_not_call_mercury, promise_pure],
+"{
 	static GLbitfield a[] = {
 		GL_COLOR_BUFFER_BIT,
 		GL_DEPTH_BUFFER_BIT,
@@ -2181,40 +2359,50 @@

 :- pred clear2(int::in, io.state::di, io.state::uo) is det.

-:- pragma foreign_proc("C", clear2(Mask::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	clear2(Mask::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glClear(Mask);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", clear_color(R::in, G::in, B::in, A::in, IO0::di,
-		IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	clear_color(R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glClearColor((GLclampf) R, (GLclampf) G, (GLclampf) B, (GLclampf) A);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", clear_index(I::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	clear_index(I::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glClearIndex((GLfloat) I);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", clear_depth(I::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	clear_depth(I::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glClearDepth((GLfloat) I);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", clear_stencil(I::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	clear_stencil(I::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glClearStencil((GLint) I);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", clear_accum(R::in, G::in, B::in, A::in, IO0::di,
-			IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	clear_accum(R::in, G::in, B::in, A::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glClearAccum((GLfloat) R, (GLfloat) G, (GLfloat) B, (GLfloat) A);
 	IO = IO0;
 ").
@@ -2247,8 +2435,10 @@
 :- pred accum2(int, float, io.state, io.state).
 :- mode accum2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", accum2(Op::in, Param::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	accum2(Op::in, Param::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glAccum(accum_op_flags[Op], Param);
 	IO = IO0;
 ").
@@ -2258,6 +2448,9 @@
 % Evalutators not implemented

 %------------------------------------------------------------------------------%
+%
+% Selection.
+%

 /*

@@ -2285,6 +2478,9 @@
 */

 %------------------------------------------------------------------------------%
+%
+% Display lists.
+%

 :- func display_list_mode_to_int(display_list_mode) = int.

@@ -2308,50 +2504,64 @@
 :- pred new_list2(int, int, io.state, io.state).
 :- mode new_list2(in, in, di, uo) is det.

-:- pragma foreign_proc("C", new_list2(N::in, M::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	new_list2(N::in, M::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glNewList((GLuint) N, display_list_mode_flags[M]);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", end_list(IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	end_list(IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glEndList();
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", call_list(N::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	call_list(N::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glCallList((GLuint) N);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", gen_lists(N::in, M::out, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
-	M = (Integer) glGenLists((GLsizei) N);
+:- pragma foreign_proc("C",
+	gen_lists(N::in, M::out, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
+	M = (MR_Integer) glGenLists((GLsizei) N);
 	IO = IO0;
 ").

-:- pragma foreign_proc("C", delete_lists(N::in, M::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	delete_lists(N::in, M::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glDeleteLists((GLuint) N, (GLsizei) M);
 	IO = IO0;
 ").

 %------------------------------------------------------------------------------%

-:- pragma foreign_proc("C", flush(IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	flush(IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFlush();
 	IO = IO0;
-	MR_assert(glGetError() == GL_NO_ERROR);
+	assert(glGetError() == GL_NO_ERROR);
 ").

-:- pragma foreign_proc("C", finish(IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	finish(IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glFinish();
 	IO = IO0;
-	MR_assert(glGetError() == GL_NO_ERROR);
+	assert(glGetError() == GL_NO_ERROR);
 ").

 %------------------------------------------------------------------------------%
@@ -2409,18 +2619,21 @@
 ").

 enable(Flag, !IO) :-
-	( if		Flag = clip_plane(I)
-	  then		enable3(control_flag_to_int(Flag), I, !IO)
-	  else if	Flag = light(I)
-	  then		enable3(control_flag_to_int(Flag), I, !IO)
-	  else		enable2(control_flag_to_int(Flag), !IO)
+	( Flag = clip_plane(I) ->
+	  	enable3(control_flag_to_int(Flag), I, !IO)
+	; Flag = light(I) ->
+	  	enable3(control_flag_to_int(Flag), I, !IO)
+	;
+		enable2(control_flag_to_int(Flag), !IO)
 	).

 :- pred enable2(int, io.state, io.state).
 :- mode enable2(in, di, uo) is det.

-:- pragma foreign_proc("C", enable2(I::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	enable2(I::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glEnable(control_flag_flags[I]);
 	IO = IO0;
 ").
@@ -2428,25 +2641,30 @@
 :- pred enable3(int, int, io.state, io.state).
 :- mode enable3(in, in, di, uo) is det.

-:- pragma foreign_proc("C", enable3(I::in, J::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	enable3(I::in, J::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glEnable(control_flag_flags[I]+J);
 	IO = IO0;
 ").

 disable(Flag, !IO) :-
-	( if		Flag = clip_plane(I)
-	  then 		disable3(control_flag_to_int(Flag), I, !IO)
-	  else if 	Flag = light(I)
-	  then		disable3(control_flag_to_int(Flag), I, !IO)
-	  else		disable2(control_flag_to_int(Flag), !IO)
+	( Flag = clip_plane(I)  ->
+		disable3(control_flag_to_int(Flag), I, !IO)
+	; Flag = light(I) ->
+		disable3(control_flag_to_int(Flag), I, !IO)
+	;
+		disable2(control_flag_to_int(Flag), !IO)
 	).

 :- pred disable2(int, io.state, io.state).
 :- mode disable2(in, di, uo) is det.

-:- pragma foreign_proc("C", disable2(I::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	disable2(I::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glDisable(control_flag_flags[I]);
 	IO = IO0;
 ").
@@ -2454,8 +2672,10 @@
 :- pred disable3(int, int, io.state, io.state).
 :- mode disable3(in, in, di, uo) is det.

-:- pragma foreign_proc("C", disable3(I::in, J::in, IO0::di, IO::uo),
-	[will_not_call_mercury, promise_pure], "
+:- pragma foreign_proc("C",
+	disable3(I::in, J::in, IO0::di, IO::uo),
+	[will_not_call_mercury, promise_pure],
+"
 	glDisable(control_flag_flags[I]+J);
 	IO = IO0;
 ").
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list