title: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT when trying to attach texture
body: <p>I get an error <code>GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT</code> after I try to create a framebuffer that renders to a texture. I can't figure out what is wrong, any help is greatly appreciated.</p>
  
  <p>Edit: Fixed it! Working code:</p>
  
  <pre><code>    glGenTextures(1, &amp;texture);
      glBindTexture(GL_TEXTURE_2D, texture);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 768, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
      glBindTexture(GL_TEXTURE_2D, 0);
  
      glGenRenderbuffers(1, &amp;rboID);
      glBindRenderbuffer(GL_RENDERBUFFER, rboID);
      glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 768, 1024);
      glBindRenderbuffer(GL_RENDERBUFFER, 0);
  
      glGenFramebuffers(1, &amp;backFramebuffer);
      glBindFramebuffer(GL_FRAMEBUFFER, backFramebuffer);
      glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
      glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboID);
      [self checkFramebufferStatus];
      glBindFramebuffer(GL_FRAMEBUFFER, 0);
  </code></pre>
  
  <p>Note: If your version doesn't work, make sure you check for errors after each and every call AND that you clear the error before your first call, else you'll be error-checking the code before that.</p>