From: Shark8 <onewingedshark@gmail.com>
Subject: OpenGL in Ada
Date: Wed, 7 Jul 2010 19:42:13 -0700 (PDT)
Date: 2010-07-07T19:42:13-07:00 [thread overview]
Message-ID: <68dd0333-f502-4351-9e50-4ec83bddc44e@k39g2000yqd.googlegroups.com> (raw)
Hello everyone,
I posted about wanting to write an OS in Ada a while ago and, as part
of that effort I've taken to translating the OpenGL API. No, I don't
mean JUST running the headers through ato-Ada converter but actually
translating the API into a more Ada-natural form.
As an example, here is the glColor-'family' of functions:
* WINGDIAPI void APIENTRY glColor3b (GLbyte red, GLbyte green,
GLbyte blue);
* WINGDIAPI void APIENTRY glColor3bv (const GLbyte *v);
* WINGDIAPI void APIENTRY glColor3d (GLdouble red, GLdouble green,
GLdouble blue);
* WINGDIAPI void APIENTRY glColor3dv (const GLdouble *v);
* WINGDIAPI void APIENTRY glColor3f (GLfloat red, GLfloat green,
GLfloat blue);
* WINGDIAPI void APIENTRY glColor3fv (const GLfloat *v);
* WINGDIAPI void APIENTRY glColor3i (GLint red, GLint green, GLint
blue);
* WINGDIAPI void APIENTRY glColor3iv (const GLint *v);
* WINGDIAPI void APIENTRY glColor3s (GLshort red, GLshort green,
GLshort blue);
* WINGDIAPI void APIENTRY glColor3sv (const GLshort *v);
* WINGDIAPI void APIENTRY glColor3ub (GLubyte red, GLubyte green,
GLubyte blue);
* WINGDIAPI void APIENTRY glColor3ubv (const GLubyte *v);
* WINGDIAPI void APIENTRY glColor3ui (GLuint red, GLuint green,
GLuint blue);
* WINGDIAPI void APIENTRY glColor3uiv (const GLuint *v);
* WINGDIAPI void APIENTRY glColor3us (GLushort red, GLushort
green, GLushort blue);
* WINGDIAPI void APIENTRY glColor3usv (const GLushort *v);
* WINGDIAPI void APIENTRY glColor4b (GLbyte red, GLbyte green,
GLbyte blue, GLbyte alpha);
* WINGDIAPI void APIENTRY glColor4bv (const GLbyte *v);
* WINGDIAPI void APIENTRY glColor4d (GLdouble red, GLdouble green,
GLdouble blue, GLdouble alpha);
* WINGDIAPI void APIENTRY glColor4dv (const GLdouble *v);
* WINGDIAPI void APIENTRY glColor4f (GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha);
* WINGDIAPI void APIENTRY glColor4fv (const GLfloat *v);
* WINGDIAPI void APIENTRY glColor4i (GLint red, GLint green, GLint
blue, GLint alpha);
* WINGDIAPI void APIENTRY glColor4iv (const GLint *v);
* WINGDIAPI void APIENTRY glColor4s (GLshort red, GLshort green,
GLshort blue, GLshort alpha);
* WINGDIAPI void APIENTRY glColor4sv (const GLshort *v);
* WINGDIAPI void APIENTRY glColor4ub (GLubyte red, GLubyte green,
GLubyte blue, GLubyte alpha);
* WINGDIAPI void APIENTRY glColor4ubv (const GLubyte *v);
* WINGDIAPI void APIENTRY glColor4ui (GLuint red, GLuint green,
GLuint blue, GLuint alpha);
* WINGDIAPI void APIENTRY glColor4uiv (const GLuint *v);
* WINGDIAPI void APIENTRY glColor4us (GLushort red, GLushort
green, GLushort blue, GLushort alpha);
* WINGDIAPI void APIENTRY glColor4usv (const GLushort *v);
which was rewritten as:
-- Color Formats
Procedure Color ( red, green, blue : in Byte );
Procedure Color ( v : RGB_Byte_Vector );
Procedure Color ( red, green, blue : in double );
Procedure Color ( v : RGB_Double_Vector );
Procedure Color ( red, green, blue : in float );
Procedure Color ( V : RGB_Float_Vector );
Procedure Color ( red, green, blue : int );
Procedure Color ( V : RGB_Integer_Vector );
Procedure Color ( red, green, blue : Short );
Procedure Color ( V : RGB_Short_Vector );
Procedure Color ( red, green, blue : Unsigned_Byte );
Procedure Color ( v : RGB_Unsigned_Byte_Vector );
Procedure Color ( red, green, blue : in Unsigned_Integer );
Procedure Color ( v : RGB_Unsigned_Integer_Vector );
Procedure Color ( red, green, blue : in Unsigned_Short );
Procedure Color ( v : RGB_Unsigned_Short_Vector );
Procedure Color ( red, green, blue, alpha : in byte );
Procedure Color ( v: RGBA_Byte_Vector );
Procedure Color ( red, green, blue, alpha : in double );
Procedure Color ( v : RGBA_Double_Vector );
Procedure Color ( red, green, blue, alpha : in float );
Procedure Color ( v: RGBA_Float_Vector );
Procedure Color ( red, green, blue, alpha : in int );
Procedure Color ( v: RGBA_Integer_Vector );
Procedure Color ( red, green, blue, alpha : in short );
Procedure Color ( v: RGBA_Short_Vector );
Procedure Color ( red, green, blue, alpha : in Unsigned_Byte );
Procedure Color ( v: RGBA_Unsigned_Byte_Vector );
Procedure Color ( red, green, blue, alpha : in Unsigned_Integer );
Procedure Color ( v: RGBA_Unsigned_Integer_Vector );
Procedure Color ( red, green, blue, alpha : in Unsigned_Short );
Procedure Color ( v: RGBA_Unsigned_Short_Vector );
where X_Y_Vector is an array of elements of type Y and indexed on type
X.
Another thing that I've done is, to the best of my ability, used Ada's
strong typing to make passing invalid parameters less of a problem;
for example:
Type Begin_Mode_Type is
( POINTS, LINES, LINE_LOOP, LINE_STRIP, TRIANGLES,
TRIANGLE_STRIP,
TRIANGLE_FAN, QUADS, QUAD_STRIP, POLYGON
);
For Begin_Mode_Type use
( POINTS => GL_POINTS,
LINES => GL_LINES,
LINE_LOOP => GL_LINE_LOOP,
LINE_STRIP => GL_LINE_STRIP,
TRIANGLES => GL_TRIANGLES,
TRIANGLE_STRIP => GL_TRIANGLE_STRIP,
TRIANGLE_FAN => GL_TRIANGLE_FAN,
QUADS => GL_QUADS,
QUAD_STRIP => GL_QUAD_STRIP,
POLYGON => GL_POLYGON
);
is a type for the glBegin-wrapper which only allows the passing of
valid "mode"-parameters. {That is, range points..polygon.}
My questions are these:
Would anyone, other than myself, find such a translation of interest?
and
When I finish, would anyone want to test it out?
next reply other threads:[~2010-07-08 2:42 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-08 2:42 Shark8 [this message]
2010-07-08 14:15 ` OpenGL in Ada John B. Matthews
2010-07-09 2:18 ` anon
2010-07-12 16:51 ` Warren
2010-07-13 12:26 ` Ludovic Brenta
2010-07-13 13:13 ` Warren
2010-07-09 11:43 ` Gautier write-only
2010-07-09 15:11 ` Gene
2010-07-09 17:38 ` Shark8
2010-07-09 20:54 ` Gene
2010-07-12 17:04 ` Warren
2010-07-10 4:00 ` BrianG
2010-07-10 11:47 ` Gautier write-only
2010-07-11 2:45 ` BrianG
2010-07-11 4:10 ` Gautier write-only
2010-07-11 5:30 ` tmoran
2010-07-11 20:46 ` anon
2010-07-12 14:17 ` Shark8
2010-07-13 0:45 ` BrianG
2010-07-13 17:50 ` anon
2010-07-13 18:37 ` Shark8
2015-01-15 7:11 ` OpenGL in Ada #2 JillRivas
2015-01-30 14:45 ` OpenGL in Ada Lucretia
2015-01-30 18:41 ` David Botton
-- strict thread matches above, loose matches on Subject: below --
2010-10-05 21:23 Yves Bailly
2010-10-06 3:45 ` anon
2010-10-06 5:10 ` Yves Bailly
2010-10-06 9:51 ` Alex R. Mosteo
2010-10-06 10:38 ` Yves Bailly
2010-10-06 10:59 ` Ludovic Brenta
2010-10-06 16:07 ` Pascal Obry
2010-10-06 17:32 ` Yves Bailly
2010-10-06 8:38 ` Gautier write-only
2010-10-07 1:52 ` BrianG
2010-10-07 22:06 ` Yves Bailly
2010-10-08 17:11 ` Shark8
2010-10-08 15:02 ` Lucretia
2010-10-08 20:42 ` Yves Bailly
2010-10-10 19:49 ` Vadim Godunko
2009-10-28 17:12 Opengl " Pablo
2009-10-28 18:01 ` Pascal Obry
2009-10-28 19:04 ` John B. Matthews
2009-10-29 6:11 ` Gautier write-only
2000-04-27 0:00 OpenGl in ADA Anderson
2000-04-27 0:00 ` Pascal Obry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox