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

Igor Stasenko siguctua at gmail.com
Wed Apr 14 03:10:03 UTC 2010


Hello,

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).
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.

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list