how to off-screen rendering like glFramebufferTexture2D() in Metal

Hi all,

I want render contents to off-screen rendering in Metal, like using glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTxture, 0); in opengles.////glTxture is a opengles 2d texture

So in metal , what can I do?

Thanks

Replies

In order to do that in Metal, you use textures you want to render to as attachments (color, depth or stencil) in MTLRenderPipelineDescriptor https://developer.apple.com/documentation/metal/mtlrenderpipelinedescriptor. IMHO this is much easier to setup then horrible GL framebuffer setup, especially for rendering to more than one target at once.

Regards

Hi MikeAlpha,

sure, I know using mtlrenderpipeline and renderpassdescriptor to attach a metal texture for offscreen draw.

But my found some strange thing.When I get a mtltexture from a cvpixelbuffer, and setup a metal render pass to draw this texture, i debug the texture is right by drawing right reslut ,but cvpixelbuffer is the same image.

So, why pixelbuffer could not be kept the same result with metal texture?