iPhone OpenGL-ES 视频纹理
我有一种感觉,我在这里忽略了一些简单的事情...
我有一个 AR 应用程序,可以在检测到标记时显示 3D 对象。该对象只是一个平面 3D 矩形 - 我可以毫无问题地将图像纹理绑定到它。但是,我需要绑定视频文件(.m4v)作为对象纹理。我成功地使用 AVAssetReader 读取文件,但是当像这样绑定纹理时,该对象仅显示为白色。
CMSampleBufferRef sampleBuffer = [mOutput copyNextSampleBuffer];
CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress( pixelBuffer, 0 );
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 320, 240, 0, GL_BGRA, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddress(pixelBuffer));
CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 );
CFRelease(sampleBuffer);
如果您能提供任何帮助,我将不胜感激。谢谢!
I have a feeling I'm overlooking something simple here...
I have an AR application that displays a 3D object upon marker detection. The object is simply a flat 3d rectangle - which I am able to bind image textures to without issue. However, I need to bind a video file (.m4v) as the objects texture. I am successfully reading the file with a AVAssetReader, however when binding the texture like so, the object just appears white.
CMSampleBufferRef sampleBuffer = [mOutput copyNextSampleBuffer];
CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress( pixelBuffer, 0 );
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 320, 240, 0, GL_BGRA, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddress(pixelBuffer));
CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 );
CFRelease(sampleBuffer);
I'd appreciate any help you can give. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认纹理参数需要一套完整的 mipmap。
尝试对
GL_TEXTURE_MIN_FILTER
使用GL_NEAREST
或GL_LINEAR
。您可能还需要二次方纹理尺寸。
The default texture parameters require a complete set of mipmaps.
Try using
GL_NEAREST
orGL_LINEAR
forGL_TEXTURE_MIN_FILTER
.You may also need power-of-two texture dimensions.