title: How to disable or configure clipping when rendering to texture using FBO in OpenGL?
body: <p>I have a question about the way the FBO clips the visible scene.
  All this happens in iPhone's OpenGL ES.</p>
  
  <p>I'm rendering in 2D and using render-to-texture with FBO. </p>
  
  <p>I find that when any part of the scene passes any side of the rectangle of screen size (480*320) that it appears clipped from the FBO generated texture.</p>
  
  <p>Why does it do that? How do I disable or configure it?</p>
  
  <p><strong>I've tried</strong> disabling scissor test by </p>
  
  <p><code>lDisable(GL_SCISSOR_TEST);</code></p>
  
  <p><strong>I've tried</strong> to set up needed section by</p>
  
  <pre><code>`glEnable(GL_SCISSOR_TEST);
  glScissor(0, 0, 100, 100);`
  </code></pre>
  
  <p><strong>I've tried</strong> to adjust Viewport by</p>
  
  <p><code>glViewport(0,0, 512,512);</code></p>
  
  <p>it doesn't work as needed.  Instead of extending the render area to needed 512*512 it looks like it still clips the area to 480*320 and stretches it afterwards to 512*512</p>
  
  <p><strong>All these didn't bring needed result.</strong></p>
  
  <p>In my code:
  I create the texture</p>
  
  <pre><code>GLuint textureID;   
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_BLEND);
  
  glGenTextures(1, &amp;textureID);
  glBindTexture(GL_TEXTURE_2D, textureID);
  
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);`
  </code></pre>
  
  <p>Create FBO and attach texture to it</p>
  
  <pre><code>GLuint textureFrameBuffer;
  GLint prevFBO;
  glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &amp;prevFBO);
  
  // create framebuffer
  glGenFramebuffersOES(1, &amp;textureFrameBuffer);
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, textureFrameBuffer);
  
  // attach renderbuffer
  glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, textureID, 0);
  
  if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
      NSLog(@"ERROR - WHILE CREATING FBO");
  
  // unbind frame buffer
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, prevFBO);
  </code></pre>
  
  <p>And then, when I draw some stuff to FBO and render the square with this texture,</p>
  
  <pre><code>static const float textCoords[] = 
  {
      0, 1,
      1, 1,
      0, 0,
      1, 0,
  };
  
  static const float quadVerts[] = 
  {
      0, 320,
      320, 320,
      0, 0,
      320, 0,
  };
  glEnable(GL_TEXTURE_2D);    
  glBindTexture(GL_TEXTURE_2D, textureID);    
  glVertexPointer(2, GL_FLOAT, 0, quadVerts);
  glTexCoordPointer(2, GL_FLOAT, 0, textCoords);      
  glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  </code></pre>
  
  <p>To my opinion I should see the square filled with all the stuff I had drawn to my FBO. Whereas, I only see a part of it – clipped rectangle of size 480x320 at lower left corner.
  <strong>So, the question is steel actual</strong></p>