- Home /
What does Texture.GetNativeTexturePtr() return when using Metal?
I'm trying to add metal support to a plugin I'm writing, and the value being passed to looks like a pointer, but I'm not exactly sure at the moment... Can someone tell me how to get hold of maybe the MTLTexture* for a texture? or what this passes to my C function when used?
Answer by SoylentGraham · Mar 16, 2015 at 11:30 PM
Managed to get my code working shortly after posting... In the IOS springboard code are a few metal types, including MTLTextureRef, which can give me access to MTLTexture... so, converted the void* to an obj-c object
OBJC_OBJECT_PTR MTLTextureRef mTexture;
mTexture = (__bridge MTLTextureRef)TexturePtr; // bridge attribute allows conversion with no refcount changes
auto w = [mTexture width]; // and other methods/properties
This has returned my texture's width, so good start. I'm sure someone could recommend some stable cast-checks though?
$$anonymous$$ake sure that texturePtr is not NULL, that's the only value you need to check for. I usually use (__bridge __nonnull id) for casting.
Your answer
Follow this Question
Related Questions
GetNativeTexturePtr is not working in iOS plugin 1 Answer
Saving Unity Texture2D updated with OpenGL FBO via custom plugin 2 Answers
Extremely slow texture upload in plugin when a model is being drawn 1 Answer
Problem trying to update texture using glTexImage2D on iOS. 0 Answers
Issue with glDrawArrays in plugin 2 Answers