1

私はiosでのopenglプログラミングが初めてです。そこで、Xcode に付属する opegles ゲーム テンプレートから始めました。それはそのまま機能します。ただし、2 つの opengles ビューを並べて設定するのに苦労しています。これが私の実装です。

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];
}

ViewController は GLKViewController から派生します。私は現在、次のように VC で 2 つのビューを並べて配置するために、ひどく大雑把な方法を使用しています。

- (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++;
}

iPad でこのコードを実行すると、glkView:(GLKView*) drawInRect:(CGRect) が呼び出されたときに次のエラーが発生します: OpenGLGame[1183:907] Failed to make complete framebuffer object 8cd6.

最初のビューは正しく表示されますが、フルスクリーンです。

誰かが私がここで欠けているものを理解するのを手伝ってくれますか?

ありがとう

4

0 に答える 0