When I load an image, it works. Making a functor also works. If I have both the code for loading an image with IMG_Load and the functor at the same time, there’s an APPCRASH error.
Besides avoiding the need to check return codes in most place, the C++ interface initializes things and makes it easier to construct terms (and it does the PL_new_functor() for you). You can see an example of creating a term in PlResourceError() in SWI-cpp.h (the interface for constructing such a term has changed slightly between versions 1 and 2 of the C++ interface, but is still basically the same). If you can give me an example of the term you’re trying to construct, I can give you the C++ code to do that. (e.g., are you trying to construct image(gnu,50))?
BTW, instead of using printf() for debugging, you can use Sdprintf().
That solves the issue. I’ll keep in mind there’s a C++ interface.
BTW, I am using PL_pointer. PL_put_pointer(a1, loadedSurface); PL_put_pointer(a2, newTexture);
the second argument is of type term_t and is the second Prolog argument.
Probably “blobs” are a better interface than raw pointers; but they require a bit more work. I’m planning on a C++ interface to blobs, to make it easier to use them.
As for PL_register_foreign() et al, the 2nd argument is the arity: this determines the number of term_t arguments you need to put in your function. E.g., the “regex” foreign library has: