Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Definitely you seem to be calling setContext on a standard UIView, rather than on an EAGLView. Your view controller should probably implement -loadView, and do something like this:</p> <pre><code>- (void)loadView { self.view = [[EAGLView alloc] initWithFrame:[UIScreen mainScreen].bounds]; } </code></pre> <p>One thing that seems odd is that you're initializing your view controller with initWithNibName rather than initWithFrame, which is what I would expect you need to do when doing away with nib/xib files.</p> <p>Here's what I'm doing, maybe it will help. </p> <p>(Note that: I have a custom view controller, which has a UIView and a subview which is the EAGLView. (I'm also working on adding an ADBanner subview). I'm not calling 'init' on my controller, its <em>view</em> gets loaded when I try to add it to the window as a subview.)</p> <p>main.m - similar.</p> <p>AppDelegate.m:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Create the window programatically: window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; controller = [GLViewController alloc]; [window addSubview:controller.view]; glView = [controller.glView retain]; [window makeKeyAndVisible]; return YES; } </code></pre> <p>ViewController.h:</p> <pre><code>@interface GLViewController : UIViewController &lt;ADBannerViewDelegate&gt; { EAGLView *glView; } @property(nonatomic, retain) /*IBOutlet*/ EAGLView *glView; @end </code></pre> <p>ViewController.m:</p> <pre><code>- (void)loadView { self.view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds]; } -(void)viewDidLoad { [super viewDidLoad]; glView = [[EAGLView alloc] initWithFrame:[UIScreen mainScreen].bounds]; glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin; glView.userInteractionEnabled=YES; [self.view addSubview:glView]; } </code></pre> <p>EAGLView.m:</p> <pre><code>- (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;// JPS - WARNING: this does not work on iOS 3.2!!! self.contentScaleFactor = [UIScreen mainScreen].scale; CGSize displaySize = [[UIScreen mainScreen]currentMode].size; CGRect displayRect = [UIScreen mainScreen].bounds; eaglLayer.frame = displayRect; eaglLayer.opaque = YES; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys : [NSNumber numberWithBool : NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; context = [[EAGLContext alloc] initWithAPI : kEAGLRenderingAPIOpenGLES1]; if (!context || ![EAGLContext setCurrentContext : context]) { [self release]; return; } glGenFramebuffersOES(1, &amp;viewFramebuffer); glGenRenderbuffersOES(1, &amp;viewRenderbuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer *)self.layer]; glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;backingWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;backingHeight); glGenRenderbuffersOES(1, &amp;depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); // Set up thd display link to sync rendering with vblank animating = FALSE; displayLinkSupported = FALSE; animationFrameInterval = 1; displayLink = nil; animationTimer = nil; // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer // class is used as fallback when it isn't available. NSString *reqSysVer = @"3.1"; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) displayLinkSupported = TRUE; } return self; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload