From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5b7ee26df9f9c357 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!5g2000yqz.googlegroups.com!not-for-mail From: Gene Newsgroups: comp.lang.ada Subject: Re: OpenGL in Ada Date: Fri, 9 Jul 2010 08:11:52 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <68dd0333-f502-4351-9e50-4ec83bddc44e@k39g2000yqd.googlegroups.com> NNTP-Posting-Host: 184.12.82.25 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1278688312 27480 127.0.0.1 (9 Jul 2010 15:11:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 9 Jul 2010 15:11:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 5g2000yqz.googlegroups.com; posting-host=184.12.82.25; posting-account=-BkjswoAAACC3NU8b6V8c50JQ2JBOs04 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12289 Date: 2010-07-09T08:11:52-07:00 List-Id: On Jul 7, 10:42=A0pm, Shark8 wrote: > 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: > =A0 =A0 * WINGDIAPI void APIENTRY glColor3b (GLbyte red, GLbyte green, > GLbyte blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3bv (const GLbyte *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3d (GLdouble red, GLdouble green= , > GLdouble blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3dv (const GLdouble *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3f (GLfloat red, GLfloat green, > GLfloat blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3fv (const GLfloat *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3i (GLint red, GLint green, GLin= t > blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3iv (const GLint *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3s (GLshort red, GLshort green, > GLshort blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3sv (const GLshort *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3ub (GLubyte red, GLubyte green, > GLubyte blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3ubv (const GLubyte *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3ui (GLuint red, GLuint green, > GLuint blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3uiv (const GLuint *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3us (GLushort red, GLushort > green, GLushort blue); > =A0 =A0 * WINGDIAPI void APIENTRY glColor3usv (const GLushort *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4b (GLbyte red, GLbyte green, > GLbyte blue, GLbyte alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4bv (const GLbyte *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4d (GLdouble red, GLdouble green= , > GLdouble blue, GLdouble alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4dv (const GLdouble *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4f (GLfloat red, GLfloat green, > GLfloat blue, GLfloat alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4fv (const GLfloat *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4i (GLint red, GLint green, GLin= t > blue, GLint alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4iv (const GLint *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4s (GLshort red, GLshort green, > GLshort blue, GLshort alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4sv (const GLshort *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4ub (GLubyte red, GLubyte green, > GLubyte blue, GLubyte alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4ubv (const GLubyte *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4ui (GLuint red, GLuint green, > GLuint blue, GLuint alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4uiv (const GLuint *v); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4us (GLushort red, GLushort > green, GLushort blue, GLushort alpha); > =A0 =A0 * WINGDIAPI void APIENTRY glColor4usv (const GLushort *v); > > which was rewritten as: > =A0-- Color Formats > =A0Procedure Color =A0 =A0( red, green, blue : in Byte ); > =A0Procedure Color =A0 =A0( v : RGB_Byte_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue : in double ); > =A0Procedure Color =A0 =A0( v : RGB_Double_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue : in float ); > =A0Procedure Color =A0 =A0( V : RGB_Float_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue : int ); > =A0Procedure Color =A0 =A0( V : RGB_Integer_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue : Short ); > =A0Procedure Color =A0 =A0( V : RGB_Short_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue : Unsigned_Byte ); > =A0Procedure Color =A0 =A0( v : RGB_Unsigned_Byte_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue : in Unsigned_Integer ); > =A0Procedure Color =A0 =A0( v : RGB_Unsigned_Integer_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue : in Unsigned_Short ); > =A0Procedure Color =A0 =A0( v : RGB_Unsigned_Short_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in byte ); > =A0Procedure Color =A0 =A0( v: RGBA_Byte_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in double ); > =A0Procedure Color =A0 =A0( v : RGBA_Double_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in float ); > =A0Procedure Color =A0 =A0( v: RGBA_Float_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in int ); > =A0Procedure Color =A0 =A0( v: RGBA_Integer_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in short ); > =A0Procedure Color =A0 =A0( v: RGBA_Short_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in Unsigned_Byte ); > =A0Procedure Color =A0 =A0( v: RGBA_Unsigned_Byte_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in Unsigned_Integer= ); > =A0Procedure Color =A0 =A0( v: RGBA_Unsigned_Integer_Vector ); > =A0Procedure Color =A0 =A0( red, green, blue, alpha : in Unsigned_Short )= ; > =A0Procedure Color =A0 =A0( 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: > =A0 =A0Type Begin_Mode_Type is > =A0 =A0 =A0( =A0POINTS, LINES, LINE_LOOP, LINE_STRIP, TRIANGLES, > TRIANGLE_STRIP, > =A0 =A0 =A0 =A0 TRIANGLE_FAN, QUADS, QUAD_STRIP, POLYGON > =A0 =A0 =A0); > > =A0 =A0 For Begin_Mode_Type use > =A0 =A0 =A0( =A0POINTS =A0 =A0 =A0 =A0 =A0=3D> GL_POINTS, > =A0 =A0 =A0 =A0 LINES =A0 =A0 =A0 =A0 =A0 =3D> GL_LINES, > =A0 =A0 =A0 =A0 LINE_LOOP =A0 =A0 =A0 =3D> GL_LINE_LOOP, > =A0 =A0 =A0 =A0 LINE_STRIP =A0 =A0 =A0=3D> GL_LINE_STRIP, > =A0 =A0 =A0 =A0 TRIANGLES =A0 =A0 =A0 =3D> GL_TRIANGLES, > =A0 =A0 =A0 =A0 TRIANGLE_STRIP =A0=3D> GL_TRIANGLE_STRIP, > =A0 =A0 =A0 =A0 TRIANGLE_FAN =A0 =A0=3D> GL_TRIANGLE_FAN, > =A0 =A0 =A0 =A0 QUADS =A0 =A0 =A0 =A0 =A0 =3D> GL_QUADS, > =A0 =A0 =A0 =A0 QUAD_STRIP =A0 =A0 =A0=3D> GL_QUAD_STRIP, > =A0 =A0 =A0 =A0 POLYGON =A0 =A0 =A0 =A0 =3D> GL_POLYGON > =A0 =A0 =A0); > > is a type for the glBegin-wrapper which only allows the =A0passing 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? Having done this a couple of times myself, you should consider the approach of writing a specialized program that processes the OpenGL header into a binding. OpenGL will remain a moving target as graphics hardware continues to evolve. Compilers will always have their unique quirks. With all this room for variation, it will probably be easier to maintain a translator than to revise the binding every time the standard changes or grows.