1

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!

Josh
  • 35
  • 3

1 Answers1

3

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Thanks very much, I have made that correction now. New problem is that its projecting the texture as a camera stream - so it appears my AVAssetReader isn't working correctly. Strange because I am able to pull the frames out and save them as individually as images, only when its projected it appears as a camera feed. – Josh Oct 06 '11 at 01:33