I have a swift app where I use the native C++ lib and there is a method that takes as an argument void *
on MTLTexture
void RenderAPI_Metal::EndModifyTexture(void* textureHandle)
{
id<MTLTexture> tex = (__bridge id<MTLTexture>)textureHandle;
...
}
and Swift call is
func foo(texture: MTLTexture) {
...
EndModifyTexture(&texture)
...
}
So, on the Swift side, I call the method and pass a pointer, and then on the C++ side when I try to cast it back I got an error
om.apple.scenekit.scnview-renderer (20): EXC_BAD_ACCESS (code=1, address=0x0)
So, according to the error looks like the pointer is nil, however, when I check it in the debug I see that it has an address void* textureHandle
is 0x0000000280a08178
What is the problem here? Why did I pass MTLTexture
and then I got a problem casting it back?
P.S.
I can't change the implementation, C++ method should receive void*