[racket] question on OpenGL support

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Apr 11 16:34:47 EDT 2011

I looked into this.

Through the .spec files, there's reference to COMPSIZE which is meant
to explain what the size of the array is computed with. And the spec
files don't give any further details on this. I looked in the written
spec for glGetTexLevelParameteriv and it has some explanation for
that. Given that that is totally un-parseable, I would just have the
Racket user pass in the cvector that they want filled.

If we just had that, we'd have everything OpenGL offers. I'd like then
write a nice macro for creating a manual wrapper for a function like
this and slowly start using them for the many functions that need 'em.

Jay

2011/4/11 Stephan Houben <stephanh at planet.nl>:
> Hi list,
>
> On 04/09/2011 05:51 AM, Jay Kominek wrote:
>>
>> The OpenGL APIs, all the versions, all the
>> extensions, are described in some fairly parseable files available
>> fromhttp://www.opengl.org/registry/  - look for the .spec files
>> towards the bottom. I'm pretty sure you should be able to generate the
>> bindings from those files, and more easily than dealing with C
>> headers.
>
> I wrote a bit of code to parse these files and it works fine so far.
> I would like some advice though on how to wrap arrays in "output" mode.
>
> Take for example the following function:
>
> GetTexLevelParameteriv(target, level, pname, params)
>        return          void
>        param           target          TextureTarget in value
>        param           level           CheckedInt32 in value
>        param           pname           GetTextureParameter in value
>        param           params          Int32 out array [COMPSIZE(pname)]
>
> This corresponds to the C header:
>
>   void glGetTexLevelParameteriv( GLenum target,
>                                      GLint level,
>                                      GLenum pname,
>                                      GLint *params )
>
>
>
> This function fills array "params" with some data.
> The length of params depends on pname and is not directly specified.
>
> I now wrap this as follows:
>
> (_fun (target : _int32) (level : _int32) (pname : _int32) (params :
> _pointer) -> _void)
>
> So params is just a raw pointer. I should perhaps use _i32vector in "output"
> mode instead but:
> 1. I don't have an expression for the length, and
> 2. I don't want to have the wrapper allocate and return an array; rather I
> want to mirror
>   the C api exactly and pass in an array which is filled by the function.
>
> The latter I consider especially important, since it ensures that all the
> docs for the C API can be used directly.
>
> So what I really want is that a _i32vector is passed in for parameter
> "params", and then filled
> by the function, so that the Racket program can observe the mutated vector.
> Can this be achieved?
>
> Thanks,
>
> Stephan
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93



Posted on the users mailing list.