metalangle icon indicating copy to clipboard operation
metalangle copied to clipboard

is it possible to create an Angle surface from an external Metal Layer

Open escamoteur opened this issue 4 years ago • 2 comments

Hi,

I'm extremely grateful that you wrote this library!

I'm evaluating to use Angle to implement a WebGL plugin for Flutter Apps. The graphic backend of Flutter on iOs and MacOS is currently migrated to use metal instead of OpenGL.

So my question is, if I can get access to the Metal layer of a Flutter Texture, would it be posible to create an OpenGL ES surface from this that could be used with MetalAngle to draw on it?

Cheers Thomas

escamoteur avatar Jan 25 '21 15:01 escamoteur

Hi, Yes, you can import external Metal texture to MetalANGLE to create an EGLImage object, then you use it to create OpenGL texture object that can be used as attachment of a framebuffer which will be able to be rendered into. This is example:

  1. Import MTLTexture to create EGLImage object: https://github.com/kakashidinho/metalangle/blob/9cfbd26f3dc600713704de5ebb33f542fa65c739/src/tests/gl_tests/ImageTestMetal.mm#L332
  2. Bind EGLImage to GL texture object which can be used by OpenGL functions: https://github.com/kakashidinho/metalangle/blob/9cfbd26f3dc600713704de5ebb33f542fa65c739/src/tests/gl_tests/ImageTestMetal.mm#L348

kakashidinho avatar Jan 26 '21 05:01 kakashidinho

Thanks a lot!

escamoteur avatar Jan 26 '21 10:01 escamoteur