I'm working on an OpenGL project using GLKit for the iPhone and need to draw several different objects at once and rotate and translate them independently. Nearly every GLKit example I've seen places the vertex/color/texture data within the render class (usually the GLKViewController). What I need to do is create separate classes to hold the object data and simply call an object's draw method from a GLKViewController class. Something like:
-(void)glkView:(GLKView *)view drawInRect:(CGRect)rect{
[mycube draw:view];
}
-(void)glkViewControllerUpdate:(GLKViewController *)controller{
[mycube updateposition:controller.timesincelastdraw];
}
How should I go about implementing this? How can I draw to an EAGLContext from a separate class? Are there any examples I can take a look at? Thanks.