How to make an unboxed array of floats I can get a Ptr to
I am trying to do some work w开发者_如何学Cith HopenGL and I need a Ptr that points to a array of floats. From what I have read uarray and storableArray seem to be the way to go, in some combination some way.
You don't say whether you already have an array and need a pointer to it or you want to create one.
If you need to create an array and then get a pointer to it you can indeed use storable arrays. In order to create it, use the classes and helperfunctions defined Data.Array.MArray
. StorableArray
is an instance of the MArray
class so all those function can be used to create and manipulate the array. When you want to get the Ptr
to the array, use the withStorableArray
function.
I hope that fits your usecase.
If you use Storable arrays or Foreign arrays (in Foreign.*) you are able to get a pointer to pass to C or friends.
精彩评论