У меня пиксельный буфер (CVPixelBufferRef
) kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
.Я могу преобразовать его в текстуру следующим образом:
if CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, // allocator: The CFAllocator to use for allocating the texture object. This parameter can be NULL.
fWebRTC.fvideoTextureCacheRef, // textureCache: The texture cache object that will manage the texture.
aPixelBuffer, // sourceImage: The CVImageBuffer that you want to create a texture from.
nil, // textureAttributes: A CFDictionary containing the attributes to be used for creating the CVOpenGLESTexture objects. This parameter can be NULL.
GL_TEXTURE_2D, // target: The target texture. GL_TEXTURE_2D and GL_RENDERBUFFER are the only targets currently supported.
GL_LUMINANCE, // internalFormat: The number of color components in the texture. Examples are GL_RGBA, GL_LUMINANCE, GL_RGBA8_OES, GL_RED, and GL_RG.
aWidth, // width: The width of the texture image.
aHeight, // height The height of the texture image.
GL_LUMINANCE, // format: The format of the pixel data. Examples are GL_RGBA and GL_LUMINANCE.
GL_UNSIGNED_BYTE, // type: The data type of the pixel data. One example is GL_UNSIGNED_BYTE.
0, // planeIndex: The plane of the CVImageBuffer to map bind. Ignored for non-planar CVImageBuffers.
@fWebRTC.fTextureRef) <> kCVReturnSuccess then begin // textureOut: A pointer to a CVOpenGLESTexture where the newly created texture object will be placed.
проблема в том, что при GL_LUMINANCE
текстура будет напечатана в оттенках серого :( Так как я могу преобразовать мои kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
CVPixelBufferRef
в текстуру, котораяЯ могу позже нарисовать в полном цвете?