Home ios - mixing opengl and metal rendering in a view
Post
Cancel

ios - mixing opengl and metal rendering in a view

Sample

Create a Metal Texture from the Pixel Buffer

Start by instantiating a Metal texture cache as follows:

1
2
3
4
5
6
cvret = CVMetalTextureCacheCreate(
                kCFAllocatorDefault,
                nil,
                _metalDevice,
                nil,
                &_CVMTLTextureCache);

Then, create a CVPixelBuffer-backed Metal texture image from the texture cache:

1
2
3
4
5
6
7
8
cvret = CVMetalTextureCacheCreateTextureFromImage(
                kCFAllocatorDefault,
                _CVMTLTextureCache,
                _CVPixelBuffer, nil,
                _formatInfo->mtlFormat,
                _size.width, _size.height,
                0,
                &_CVMTLTexture);
This post is licensed under CC BY 4.0 by the author.