Come creare un CVOpenGLTextureRef da un OpenGL Texture
-
24-10-2019 - |
Domanda
Ho un po 'di messa a punto del progetto utilizzando OpenGL e video Nucleo. Rendo un FBO e utilizzare questo come una texture per altre parti del Programma, ma sarebbe bello passare questo riferimento Struttura in forma di una CVOpenGLTextureRef. Ma i cant trovare qualsiasi doumentation Utile come creare questo tipo di dati da un nome Texture e Target (senza copiare i dati).
Soluzione
As I understand it, to read data from an OpenGL context, you need to use a CVOpenGLBufferRef
(which is a type of CVImageBufferRef
). The documentation claims that these wrap pbuffers, but I would guess they work with FBOs. I haven’t tried it.
To render the data from a CVOpenGLBufferRef
, you need to draw it to a texture using a CVOpenGLTextureCacheRef
, which manages a set of CVOpenGLTextureRef
s.
If you only want do draw the unmodified buffer contents, it’s probably more efficient to work within OpenGL. (Note that you can share textures/buffers between contexts using share groups, if necessary.)
If you do need to shuffle buffers around between contexts, and don’t want all that fluffy high-level abstraction and helpful documentation that you get with Core Video, you might want to look into IOSurface and CGLIOSurface.