On Sunday, 26 March 2017 at 10:34:21 UTC, Dlearner wrote:
I came back to this project and realised my mistakes (Importer
is a class for the C++ API, and we're using the C API).
So I fixed all my errors, but now I get an access violation.
As far as I can tell, it seems to be an issue with
`aiGetMaterialTexture`. It is meant to return an aiString with
a filename (default value of "$texture.png"), I believe. But I
get:
aiString(13, x"67 6C 61 73 73 5F 64 69 66 2E 70 6E 67 00 FF FF
FF ... FF"c)
[shortened for brevity]
The data is "glass_dif.png", followed by a null terminator,
followed by a bunch of 0xFFs. 13 is the length of
"glass_dif.png". Judging from the definition of aiString [1], the
0xFFs are just unused space. So, this looks good.
I'm meant to add this on to a directory string so I can load an
image, but obviously this wouldn't work.
To convert an aiString to a D string, it should be possible to
slice the data with the length:
aiString x;
const(char)[] y = x.data[0 .. x.length];
You have to be cautiots of lifetime requirements, of course. If
needed, you can make a copy with dup (mutable copy) or idup
(immutable copy):
const(char)[] y = x.data[0 .. x.length].dup;
string z = x.data[0 .. x.length].idup;
[1] http://www.assimp.org/lib_html/structai_string.html