Some DirectX methods return structs by value, but when I try
calling them I either get garbage or an access violation.
Usually COM methods return structs by pointer as a parameter, but
these are returning the struct as the actual return value, as in
this definition:
extern(Windows):
struct D2D1_SIZE_F { float width, height; }
interface ID2D1Bitmap : ID2D1Image {
D2D1_SIZE_F GetSize();
}
If I rewrite GetSize to return by pointer as a parameter, it
appears to work and I get the correct width and height without an
AV being thrown. And I can add a helper method that returns by
value:
interface ID2D1Bitmap : ID2D1Image {
void GetSize(D2D1_SIZE_F* size);
final D2D1_SIZE_F GetSize() {
D2D1_SIZE_F size;
GetSize(&size);
return size;
}
}
But does anyone know why the original definition works in C++ but
not D? Is it a bug? (I'm compiling with -m64.)