title: Failed to make complete framebuffer object 8cd6 (iOS, programmatically created OpenGL view)
body: <p>I've been having a problem getting my programmatically created OpenGL view to work on certain iOS versions/devices. It seem to be most common on Jailbroken devices, but does also happen on normal devices. It appears to only be v4.1 or 4.2.1 that it fails on.</p>
  
  <p>The device I have is jailbroken (it's not mine and certainly not my choice to jailbreak it!) and has v4.1 (8B117) of iOS on it.</p>
  
  <p>The error is 8cd6, which means that it failed to attach the framebuffer (or something along those lines).</p>
  
  <p>I've searched and searched, but none of the other solutions I've found have helped. Most of them are using a depth buffer too, but mine is purely 2D and has no depth buffer.</p>
  
  <p>Here's how I create the buffers:</p>
  
  <pre><code>glGenFramebuffersOES(1, &amp;defaultFramebuffer);
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
  
  glGenRenderbuffersOES(1, &amp;colorRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
  
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);
  </code></pre>
  
  <p>Other setup values:</p>
  
  <pre><code>glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrthof(0, rect.size.width, 0, rect.size.height, -1, 1);
  glMatrixMode(GL_MODELVIEW);
  glViewport(0, 0, rect.size.width, rect.size.height);
  
  glDisable(GL_DEPTH_TEST);
  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND_SRC);
  glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  glClear(GL_COLOR_BUFFER_BIT);
  
  int* mts = calloc(1, sizeof(int));
  glGetIntegerv(GL_MAX_TEXTURE_SIZE, mts);
  </code></pre>
  
  <p>resizeFromLayer:</p>
  
  <pre><code>-(BOOL) resizeFromLayer: (CAEAGLLayer*) _layer
  {
      // Allocate color buffer backing based on the current layer size
      glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
  
      NSLog(@"Layer Bounds: %f x %f", _layer.bounds.size.width, _layer.bounds.size.height);
      NSLog(@"Layer Position: %f x %f", _layer.bounds.origin.x, _layer.bounds.origin.y);
      if(![context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable: _layer])
      {
          NSLog(@"renderBufferStorage failed!");
      }
  
      glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;backingWidth);
      glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;backingHeight);
      NSLog(@"Backing: %d x %d", backingWidth, backingHeight);
  
      if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
      {
          NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
          return NO;
      }
  
      return YES;
  }
  </code></pre>
  
  <p>It's the line "Failed to make complete framebuffer object" that gets called with the error code 8cd6.</p>