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.
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.