1

I am new to opengl programming on ios. So I started with the opegles game template that comes in Xcode. That works as it is. However, I have been struggling with setting up two opengles views side by side. Here's my implementation.

In AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

   self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad"    bundle:nil] autorelease];
    self.anotherViewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
    self.window.rootViewController = self.viewController;
    [self.window addSubview:self.anotherViewController.view];
}

The ViewController derives from GLKViewController. I am currently using a horribly crude way to position the two views side by side in the VC like this:

- (void) viewDidLoad{
   [super viewDidLoad];

   self.context = [[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2] autorelease];

   if (!self.context) {
       NSLog(@"Failed to create ES context");
   }
   static int staticX = 0;
   self.view = [[GLKView alloc] initWithFrame:CGRectMake(100, 100, 50 * staticX, 50)];
   GLKView *view = (GLKView *)self.view;

   view.frame = CGRectMake(100, 100, 50 * staticX, 50);
   view.context = self.context;
   view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
   [self setupGL:self.context];
   staticX++;
}

When I run this code on my iPad I get this error when the glkView:(GLKView*) drawInRect:(CGRect) gets called: OpenGLGame[1183:907] Failed to make complete framebuffer object 8cd6.

The first view shows up correctly but is full screen.

Can someone please help me with figuring out what I am missing here?

thanks

0 Answers0