Thanks to your advices I was able to make it work more or less, using eglCreateImage and glEGLImageTargetTexture2DOES.
One thing I am not so sure about now is how to properly synchronize the ANGLE internal Metal command buffer with the one used by the headset. It seems that the current Metal implementation in ANGLE does not have the GL_EXT_semaphore extension, so I cannot use that. Does anybody know a workaround? My code currently looks like this:
```
// 1. Create FBO from the passed cp_drawable_t:
color_texture = cp_drawable_get_color_texture(drawable, eye);
egl_image = eglCreateImage(
egl_display, EGL_NO_CONTEXT, EGL_METAL_TEXTURE_ANGLE,
color_texture, NULL);
glGenTextures(1, &gl_tex);
glBindTexture(GL_TEXTURE_2D, gl_tex);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image);
glGenFramebuffers(1, &gl_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, gl_fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, gl_tex, 0);
// 2. Do the OpenGL rendering
...
// 3. Delete used textures and fbo
glDeleteFramebuffers(1, &gl_fbo);
glDeleteTextures(1, &gl_tex);
// 4. Present and encode an empty command buffer to the drawable.
id<MTLCommandBuffer> command_buffer;
command_buffer = [engine->command_queue commandBuffer];
cp_drawable_encode_present(drawable, command_buffer);
[command_buffer commit];
```
The screen seems flicker from time to time, which I think comes from metal not properly waiting for ANGLE to finish before swapping the target buffer.
Regards,
G