Hi,

I tried lots of ways to pass an array, based on the few examples found here and 
there.
My example is:
GLES2Buffer class>>gen: n into: buffers
    self ffiCall: #(void glGenBuffers(int n, int* buffers))

With buffers := FFIExternalArray newType: 'int' size: n (or FFIExternalArray 
gcExternalNewType: 'int' size: n), the above signature executes without error, 
but buffers is not updated, so I guess it is copied beforehand.
If I replace int* with FFIExternalArray, the values are written correctly in my 
array.

If I replace int* with ByteArray instead I can use any one of 
ByteArray/IntegerArray/FloatArray ! Only ShortArray, LongArray and DoubleArray 
are missing then, but they are not crucial right now.
So for example:
GLES2Buffer class>>create
    buffer := IntegerArray new: 1.
    GLES2Buffer gen: 1 into: buffer.
    ^self new setHandle: (buffer at: 1)

:)

Same goes for passing coordinates to OpenGL, just with #(-1 -1 -1 1 1 1 1 -1) 
asFloatArray. Perfect.

Cheers,
Thibault

> Hi,
> 
> Just checked? contrary to what I believed, strings are passed by copy (not by
> reference, as ByteArray)? logical for safety but with penalty on
> performance... so yes, using a ByteArray is the correct way to do it. (Or an
> external value holder, which is a glorified way for passing a ByteArray, but
> this probably do not work fine for ?char*" because I didn?t preview it :P)
> 
> Esteban

Reply via email to