简体   繁体   中英

iPhone OpenGL-ES Video Texture

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!

The default texture parameters require a complete set of mipmaps.

Try using GL_NEAREST or GL_LINEAR for GL_TEXTURE_MIN_FILTER .

You may also need power-of-two texture dimensions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM