GMS 2 [SOLVED] Return 1d Array from Native Extension Function?

Samuel Venable

Time Killer
Is it possible to return a 1d array from a native, non-gml extension? i.e. a dll/dylib/so

string in gamemaker extensions is a pointer, so would that mean I'd simply return a std::vector?

Or would the compiler I would use, which all compilers implement std::vector differently, make this impossible?


The only way I know of is to do this (C++) as the example;
  • (GML) Create buffer with the size of the array that you have on the C++ size
  • (GML) Send buffer_get_address(buffer) to C++ as a 'ty_string' (a pointer)
  • (C++) Fill the buffer with your information
  • (GML) Use buffer_peek or whatever to use the data as you wish
I did actually send a request the other day for 'buffer_set_pointer(address, type, length)' so you can specify the address of the buffer when creating the data on the C++ side first and tell GMS where the buffer is, what type it is, and the length. But we shall see if anything comes of it.

Joe Ellis

@Lonewolff, I love that you sent that request, I have a feeling that it will be on the bottom of their priority list, but it should be something that's available for people who know how to use it.
Also from my experience is exactly the same as lonewolff, create the buffer(1d array) in the exact right size that the dll will fill after getting the buffer's address (I just wrote this for a 2nd validation (no rivalry (at least not unfriendly)) ) )
Last edited: