MPG
MPG

Reputation: 251

How to render GLKViewController with iphone camera

I have a GLKViewController which renders a cube and also a transformations class which helps it get scaled, moved or rotated. This view controller use the device data as well to rotate the cube. I want to place this cube on iOS camera. Please help.

Upvotes: 0

Views: 1095

Answers (1)

rickster
rickster

Reputation: 126167

Use the AVCapture classes from the AVFoundation framework to get video from the camera, and the CVOpenGLESTextureCache class to get camera frames into OpenGL ES textures. Once you have such a texture, use it like any other — call glBindTexture and issue a draw call. Camera data comes in biplanar YUV format, so you'll need a shader program that reads the Y and UV textures and converts them to an RGB output while drawing.

Apple's GLCameraRipple sample code project demonstrates all of the above.

Upvotes: 1

Related Questions