0
我知道蘋果提供了一個名爲GLCameraRipple的示例,它使用CVOpenGLESTextureCacheCreateTextureFromImage來實現此目的。但是當我更改爲glTexImage2D時,它什麼都不顯示,我的代碼出了什麼問題?iphone OpenGLES視頻紋理
if (format == kCVPixelFormatType_32BGRA) {
CVPixelBufferRef pixelBuf = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(pixelBuf, 0);
void *baseaddress = CVPixelBufferGetBaseAddress(pixelBuf);
glGenTextures(1, &textureID);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, baseaddress);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
CVPixelBufferUnlockBaseAddress(pixelBuf, 0);
}
非常感謝您的幫助!