title: OpenGL: Framebuffer, incomplete texture attachment
body: <p>I've searched for couple hours for a solution to my problem. 
  First of all. I have HD 7800 series amd GPU, newest drivers.</p>
  
  <p>I'm trying to create framebuffer class which has all the framebuffer functions I will need. It seems I got renderbuffers to work, but drawing to texture is causing really weird errors. </p>
  
  <pre><code>FrameBuffer::FrameBuffer(int width, int height)
  {
      createFrameBuffer();
  //  createDepthBufferAttachment(width, height); //commented out for testing (THIS WORKS)
      createTextureAttachment(width, height);
  //  createDepthTextureAttachment(width, height); //commented out for testing
      glBindFramebuffer(GL_FRAMEBUFFER, fbo);
      if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
          std::cerr &lt;&lt; glCheckFramebufferStatus(GL_FRAMEBUFFER) &lt;&lt; "\nFramebuffer failed to generate! 0\n";
      }
      unbindFrameBuffer();
  
  
  }
  
  FrameBuffer::~FrameBuffer()
  {
      if (fbo != NULL)
          glDeleteFramebuffers(1, &amp;fbo);
      if (colorTexture != NULL)
          glDeleteTextures(1, &amp;colorTexture);
      if (depthBuffer != NULL)
          glDeleteRenderbuffers(1, &amp;depthBuffer);
      if (depthTexture != NULL)
          glDeleteTextures(1, &amp;depthTexture);
  }
  
  void FrameBuffer::createFrameBuffer(){
      glGenFramebuffers(1, &amp;fbo);
  
  }
  
  void FrameBuffer::createTextureAttachment(int width, int height){
      glGenTextures(1, &amp;colorTexture);
      glBindTexture(GL_TEXTURE_2D, colorTexture);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, GL_RGBA, 0, GL_UNSIGNED_BYTE, NULL);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
      glBindTexture(GL_TEXTURE_2D, 0);
      glBindFramebuffer(GL_FRAMEBUFFER, fbo);
      glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0);
      if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
          std::cerr &lt;&lt; glCheckFramebufferStatus(GL_FRAMEBUFFER) &lt;&lt; "\nFramebuffer failed to generate! 1\n";
      }
      glBindFramebuffer(GL_FRAMEBUFFER, 0);
  
  }
  void FrameBuffer::createDepthTextureAttachment(int width, int height){
      glGenTextures(1, &amp;depthTexture);
      glBindTexture(GL_TEXTURE_2D, depthTexture);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, width, height, GL_DEPTH_COMPONENT, 0, GL_FLOAT, NULL);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
      glBindTexture(GL_TEXTURE_2D, 0);
      glBindFramebuffer(GL_FRAMEBUFFER, fbo);
      glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0);
      if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
          std::cerr &lt;&lt; glCheckFramebufferStatus(GL_FRAMEBUFFER) &lt;&lt; "\nFramebuffer failed to generate! 2\n";
      }
      glBindFramebuffer(GL_FRAMEBUFFER, 0);
  
  }
  
  void FrameBuffer::createDepthBufferAttachment(int width, int height){
      glGenRenderbuffers(1, &amp;depthBuffer);
      glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
      glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
      glBindRenderbuffer(GL_RENDERBUFFER, 0);
      glBindFramebuffer(GL_FRAMEBUFFER, fbo);
      glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer);
      if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
          std::cerr &lt;&lt; glCheckFramebufferStatus(GL_FRAMEBUFFER) &lt;&lt; "\nFramebuffer failed to generate! 3\n";
      }
      glBindFramebuffer(GL_FRAMEBUFFER, 0);
  }
  
  void FrameBuffer::bindFrameBuffer( int width, int height){
      glBindTexture(GL_TEXTURE_2D, 0);
      glBindFramebuffer(GL_FRAMEBUFFER, fbo);
      glViewport(0, 0, width, height);
  }
  
  void FrameBuffer::unbindFrameBuffer(){
      glBindFramebuffer(GL_FRAMEBUFFER, 0);
      glViewport(0, 0, DisplayManager::getWidth(), DisplayManager::getHeight());
  }
  </code></pre>
  
  <p>glCheckFrameBufferStatus returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
  at both checks. The same happens with the createDepthTextureAttachment()
  Neither one seems to not work</p>
  
  <p>createDepthBufferAttachment() works fine. </p>
  
  <p>More info:
  Yes, indeed I'm actually giving width and height to the function, they are both 1024. 
  I've tried changing the GL_RGBA to GL_RGB, and Tried different sizes of GL_DEPTH_COMPONENT too.</p>
  
  <p>At the moment I'm intending on using only 1 texture, not all 3 functions. </p>
  
  <p>I don't know if it matters but SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); is set. </p>
  
  <p>I've also tried glFramebufferTexture() function instead. </p>
  
  <p>Thank you in advance!</p>