CAOpenGLLayer displaying a remote context

I have a sub-classed CAOpenGLLayer class that overrides drawInCGLContext there I draw a rectangle with OpenGL . CAOpenGLLayer added to CALayer and displayed.

So when I would like to do something, I would need to do this in drawInCGLContext using this architecture.

What I would like to have is some kind of context used by another class for drawing, animation or rendering, but will be displayed every time drawInCGLContext .

So basically the only thing my subclass has to do is show the remote (OpenGL)context , what is the best way to achieve this? Or should I consider a different approach?

* Do not use CALayer not an option.

+6
source share
1 answer

Have you considered using framebuffer (FBO)? You can create one that is supported by texture. Your โ€œremoteโ€ drawing class could paint in FBO, which will cause the drawing to go over to a texture that supports it. You can then use this texture elsewhere, for example, blitting it on the screen in your subclass of CAOpenGLLayer. See this link to learn how to use FBO.

+3
source

Source: https://habr.com/ru/post/901032/


All Articles