[squeak-dev] Re: [ANN] OpenGL specs parser/FFI methods generator

Andreas Raab andreas.raab at gmx.de
Wed Apr 14 03:22:04 UTC 2010


On 4/13/2010 8:10 PM, Igor Stasenko wrote:
> i just submitted a code, which could help us greatly in having
> up-to-date and full OpenGL API coverage in Squeak.
>
> This package extracts data directly from spec files, used by OpenGL
> folks for generating C headers (gl.h / glext.h etc).

Sweet! I had no idea these spec files existed. Do you know if the spec 
files cover OpenGL ES as well? Also, have you run this against the 
existing OpenGL code to see if it produces matching output? (more to 
verify your translation than anything else)

I'm definitely interested in looking at this. The original OpenGL calls 
were generated by code that I've lost in the mean time so it's great to 
have a way of recreating it from first principles!

Cheers,
   - Andreas


> So it is 100% correct.
> Parsing these files is much easier than C headers.
> There's also a lot of additional data , which helps to automatically
> categorise the methods and generate correct callout code.
>
> The parsed data can be later used for generating an FFI/Alien OpenGL
> callout code with full coverage of all existing extensions.
> And you don't need to keep this package in image after you done
> generating the code.
> Or, it can stay, just make sure that you prune all parsed data by issuing:
>
> GLAPIData reset.
>
> The sources for parsing is located at:
>
> http://www.opengl.org/registry/#specfiles
>
> Place all *.spec and *.tm files into a single directory, and then issue:
>
>   GLAPIData parseAll: (FileDirectory on: 'your/path').
>
>
> There is an example, how to generate an FFI callout methods.
>
> Use:
>
>   GLAPIData gl generateFFIMethodsInto: (FileStream newFileNamed:
> 'gl.st') forClass: 'OpenGL'
>
> Then, you can file-in the generated code right into your image:
>
>   (FileStream oldFileNamed: 'gl.st') fileIn
>
> The resulting file is about 700kbytes big, having methods like:
>
> !OpenGL methodsFor: 'EXT_framebuffer_multisample' stamp:
> 'Igor.Stasenko 4/14/2010 05:22'!
> glRenderbufferStorageMultisampleEXT: target with: samples with:
> internalformat with: width with: height
> 	"This method was automatically generated from OpenGL specs"
> 	"See http://squeaksource.com/OpenGLSpecs for details"
> 	<apicall: void 'glRenderbufferStorageMultisampleEXT' (GLenum GLsizei
> GLenum GLsizei GLsizei)>
> 	^ self externalCallFailed
>
>
> P.S. I plan to use this data directly by native code, in a way like:
>
> glTexCoord2hNV: s with: t
> 	<primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin'>
> 	^ self glAPICall: 'glTexCoord2hNV'
>
> since i don't need a type data placed in method. I guess, Alien could
> use similar approach.
>




More information about the Squeak-dev mailing list