[m-rev.] diff: cleanup C code in opengl binding

Julien Fischer juliensf at students.cs.mu.OZ.AU
Tue Jan 20 15:24:26 AEDT 2004


Estimated hours taken: 0.2
Branches: main

Cleanup the C code in the opengl binding.

Fix a typo.

extras/graphics/mercury_opengl/mglu.m:
	Fix a typo. s/autors/authors/.

extras/graphics/mercury_opengl/mogl.m:
	Make C code in this module conform to the C coding guidelines.

Julien.

Index: mglu.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/graphics/mercury_opengl/mglu.m,v
retrieving revision 1.4
diff -u -r1.4 mglu.m
--- mglu.m	21 Oct 2003 08:21:14 -0000	1.4
+++ mglu.m	20 Jan 2004 01:15:40 -0000
@@ -5,7 +5,7 @@
 %-----------------------------------------------------------------------------%
 %
 % file: mglu.m
-% main autors: conway, ohutch.
+% main authors: conway, ohutch.
 %
 % This file provides bindings to the GLU library.
 %
Index: mogl.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/graphics/mercury_opengl/mogl.m,v
retrieving revision 1.7
diff -u -r1.7 mogl.m
--- mogl.m	14 Jan 2004 06:59:44 -0000	1.7
+++ mogl.m	20 Jan 2004 01:14:39 -0000
@@ -721,6 +721,7 @@
 :- pragma foreign_decl("C", "
 	#include <stdio.h>
 	#include <math.h>
+	#include <assert.h>
 	#include <GL/gl.h>
 ").

@@ -771,8 +772,7 @@
 	err = glGetError();

 	for (i=0; i < 7; i++)
-		if (errcodes[i] == err)
-		{
+		if (errcodes[i] == err) {
 			Err =  i;
 			break;
 		}
@@ -864,12 +864,9 @@
 	vertex2(X::in, Y::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glVertex2f((GLfloat) X, (GLfloat) Y);
-	}
-	else
-	{
+	} else {
 		glVertex2d((GLdouble) X, (GLdouble) Y);
 	}
 	IO = IO0;
@@ -879,12 +876,9 @@
 	vertex3(X::in, Y::in, Z::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glVertex3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
-	}
-	else
-	{
+	} else {
 		glVertex3d((GLdouble) X, (GLdouble) Y, (GLdouble) Z);
 	}
 	IO = IO0;
@@ -894,12 +888,9 @@
 	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))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glVertex4f((GLfloat) X, (GLfloat) Y, (GLfloat) Z, (GLfloat) W);
-	}
-	else
-	{
+	} else {
 		glVertex4d((GLdouble) X, (GLdouble) Y, (GLdouble) Z,
 			(GLdouble) W);
 	}
@@ -910,12 +901,9 @@
 	rect(X1::in, Y1::in, X2::in, Y2::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if(sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glRectf((GLfloat) X1, (GLfloat) Y1, (GLfloat) X2, (GLfloat) Y2);
-	}
-	else
-	{
+	} else {
 		glRectd((GLdouble) X1, (GLdouble) Y1, (GLdouble) X2,
 			(GLdouble) Y2);
 	}
@@ -928,12 +916,9 @@
 	tex_coord1(X::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glTexCoord1f((GLfloat) X);
-	}
-	else
-	{
+	} else {
 		glTexCoord1d((GLdouble) X);
 	}
 	IO = IO0;
@@ -943,12 +928,9 @@
 	tex_coord2(X::in, Y::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glTexCoord2f((GLfloat) X, (GLfloat) Y);
-	}
-	else
-	{
+	} else {
 		glTexCoord2d((GLdouble) X, (GLdouble) Y);
 	}
 	IO = IO0;
@@ -958,12 +940,9 @@
 	tex_coord3(X::in, Y::in, Z::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glTexCoord3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
-	}
-	else
-	{
+	} else {
 		glTexCoord3d((GLdouble) X, (GLdouble) Y, (GLdouble) Z);
 	}
 	IO = IO0;
@@ -973,13 +952,10 @@
 	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))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glTexCoord4f((GLfloat) X, (GLfloat) Y, (GLfloat) Z,
 			(GLfloat) W);
-	}
-	else
-	{
+	} else {
 		glTexCoord4d((GLdouble) X, (GLdouble) Y, (GLdouble) Z,
 			(GLdouble) W);
 	}
@@ -992,12 +968,9 @@
 	normal3(X::in, Y::in, Z::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glNormal3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
-	}
-	else
-	{
+	} else {
 		glNormal3d((GLdouble) X, (GLdouble) Y, (GLdouble) Z);
 	}
 	IO = IO0;
@@ -1009,12 +982,9 @@
 	color3(R::in, G::in, B::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glColor3f((GLfloat) R, (GLfloat) G, (GLfloat) B);
-	}
-	else
-	{
+	} else {
 		glColor3d((GLdouble) R, (GLdouble) G, (GLdouble) B);
 	}
 	IO = IO0;
@@ -1024,12 +994,9 @@
 	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))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glColor4f((GLfloat) R, (GLfloat) G, (GLfloat) B, (GLfloat) A);
-	}
-	else
-	{
+	} else {
 		glColor4d((GLdouble) R, (GLdouble) G, (GLdouble) B,
 			(GLdouble) A);
 	}
@@ -1040,12 +1007,9 @@
 	index(I::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if(sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glIndexf((GLfloat) I);
-	}
-	else
-	{
+	} else {
 		glIndexd((GLdouble) I);
 	}
 	IO = IO0;
@@ -1134,9 +1098,9 @@
 		A13::in, A14::in, A15::in, A16::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		GLfloat	a[16];
+
 		a[0] = (GLfloat) A1; a[1] = (GLfloat) A2;
 		a[2] = (GLfloat) A3; a[3] = (GLfloat) A4;
 		a[4] = (GLfloat) A5; a[5] = (GLfloat) A6;
@@ -1147,7 +1111,8 @@
 		a[14] = (GLfloat) A15; a[15] = (GLfloat) A16;
 		glLoadMatrixf(a);
 	} else {
-		GLdouble	a[16];
+		GLdouble a[16];
+
 		a[0] = (GLdouble) A1; a[1] = (GLdouble) A2;
 		a[2] = (GLdouble) A3; a[3] = (GLdouble) A4;
 		a[4] = (GLdouble) A5; a[5] = (GLdouble) A6;
@@ -1189,9 +1154,9 @@
 		A13::in, A14::in, A15::in, A16::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if (sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		GLfloat	a[16];
+
 		a[0] = (GLfloat) A1; a[1] = (GLfloat) A2;
 		a[2] = (GLfloat) A3; a[3] = (GLfloat) A4;
 		a[4] = (GLfloat) A5; a[5] = (GLfloat) A6;
@@ -1202,7 +1167,8 @@
 		a[14] = (GLfloat) A15; a[15] = (GLfloat) A16;
 		glMultMatrixf(a);
 	} else {
-		GLdouble	a[16];
+		GLdouble a[16];
+
 		a[0] = (GLdouble) A1; a[1] = (GLdouble) A2;
 		a[2] = (GLdouble) A3; a[3] = (GLdouble) A4;
 		a[4] = (GLdouble) A5; a[5] = (GLdouble) A6;
@@ -1228,8 +1194,7 @@
 	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))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glRotatef((GLfloat) Theta,
 			(GLfloat) X, (GLfloat) Y, (GLfloat) Z);
 	} else {
@@ -1243,8 +1208,7 @@
 	translate(X::in, Y::in, Z::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if(sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glTranslatef((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
 	} else {
 		glTranslated((GLdouble) X, (GLdouble) Y, (GLdouble) Z);
@@ -1256,8 +1220,7 @@
 	scale(X::in, Y::in, Z::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if(sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glScalef((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
 	} else {
 		glScaled((GLdouble) X, (GLdouble) Y, (GLdouble) Z);
@@ -1413,8 +1376,7 @@
 	raster_pos2(X::in, Y::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if(sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glRasterPos2f((GLfloat) X, (GLfloat) Y);
 	} else {
 		glRasterPos2d((GLdouble) X, (GLdouble) Y);
@@ -1426,8 +1388,7 @@
 	raster_pos3(X::in, Y::in, Z::in, IO0::di, IO::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	if(sizeof(MR_Float) == sizeof(GLfloat))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glRasterPos3f((GLfloat) X, (GLfloat) Y, (GLfloat) Z);
 	} else {
 		glRasterPos3d((GLdouble) X, (GLdouble) Y, (GLfloat) Z);
@@ -1439,8 +1400,7 @@
 	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))
-	{
+	if (sizeof(MR_Float) == sizeof(GLfloat)) {
 		glRasterPos4f((GLfloat) X, (GLfloat) Y, (GLfloat) Z,
 			(GLfloat) W);
 	} else {
@@ -2918,10 +2878,11 @@
 	is_enabled_2(FlagVal::in, Offset::in, R::out, IO0::di, IO::uo),
 	[may_call_mercury, promise_pure],
 "
-	if(glIsEnabled(control_flag_flags[FlagVal] + Offset))
+	if (glIsEnabled(control_flag_flags[FlagVal] + Offset)) {
 		R = ML_bool_return_yes();
-	else
+	} else {
 		R = ML_bool_return_no();
+	}
 	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