You want to try and avoid inter-mingling objective-c and c++ as much as possible, it will create code that is very hard to debug and even harder to understand by others potentially joining your project.
It is essential that you ground a sense of framework and work in a modular fashion in respect to how the platform wants to you to interact with objective-c modules and how your c++ modules fit with these.
If you're using c++, that indicates to me that you want to abstract away from objective-c and use c++ as your main language, then do so. Objective-c will only handle the low-tier ios system-specific features.
What purpose do you have for crossing the two languages over in such a complicated way, this speaks to me of bad software design and poor consideration of design methodologies.
I can only advise to keep it straight forward:
//Init
In your ViewController.mm just invoke a main engine class(c++) such as:
-(void)viewDidLoad
{
/*unrelated ios-specific init code*/
[super viewDidLoad];
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
engine = new engine();//your engine class, that contains init, update and draw methods
if(!self.context || ![EAGLContext setCurrentContext:self.context])
{
NSLog(@"Failed to create ES context");
}
GLKView * view = (GLKView *)self.view;
view.context = self.context;
GRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
view.drawableDepthFormat = GLKViewDrawableDepthFormat16;
if(engine != NULL)
engine->init(screenWidth, screenHeight);
}
//Update
-(void)update {
engine->update();
}
//Draw
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
engine->draw((GLfloat)view.drawableWidth,(GLfloat)view.drawableHeight);
[self.context presentRenderbuffer:GL_RENDERBUFFER];
}
You will need to assert a solid architecture for communicating between your lower-level objective-c and higher-level c++ classes if you wish to use all the features the platform has to offer.