From: Shark8 on 7 Jul 2010 22:42 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?
From: John B. Matthews on 8 Jul 2010 10:15 In article <68dd0333-f502-4351-9e50-4ec83bddc44e(a)k39g2000yqd.googlegroups.com>, Shark8 <onewingedshark(a)gmail.com> wrote: > Would anyone, other than myself, find such a translation of interest? I have used AdaOpenGL in the past. Is your project related in any way? <http://adaopengl.sourceforge.net/> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
From: anon on 8 Jul 2010 22:18 In <nospam-8BBB96.10151708072010(a)news.aioe.org>, "John B. Matthews" <nospam(a)nospam.invalid> writes: >In article ><68dd0333-f502-4351-9e50-4ec83bddc44e(a)k39g2000yqd.googlegroups.com>, > Shark8 <onewingedshark(a)gmail.com> wrote: > >> Would anyone, other than myself, find such a translation of interest? > >I have used AdaOpenGL in the past. Is your project related in any way? > ><http://adaopengl.sourceforge.net/> > >-- >John B. Matthews >trashgod at gmail dot com ><http://sites.google.com/site/drjohnbmatthews> But the last time I downloaded the packages they needed a few modifications for the current GNAT and OpenGL standards that I was using. but it was no problem. And with these APIs packages all you would need to do is replace the openGL libraries calls with the actual routines. Have fun! Let us know when it ready for testing!
From: Gautier write-only on 9 Jul 2010 07:43 On Jul 7, 10:42 pm, Shark8 <onewingedsh...(a)gmail.com> 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. .... > 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? You may save lots of work by looking at the GL bindings there http://globe3d.sf.net which are also Ada-ized (overloaded names, all useless gl* and GL_* stripped) Have fun, Gautier
From: Gene on 9 Jul 2010 11:11 On Jul 7, 10:42 pm, Shark8 <onewingedsh...(a)gmail.com> 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: > * 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? 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.
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Color Ada Keywords Next: Wikibook on Ada Programming - Object Orientation |