title: Can I specify a viewport per render target?
body: <p>First my problem: I'm trying to render to multiple buffers in an FBO. I set multiple buffers using <code>glDrawBuffers</code>, and rendering to them using the appropriate <code>gl_FragData</code>. All good and well, but in my situation one of the buffers should be downsampled, by a quarter to be exact (<code>w/2</code>, <code>h/2</code>).</p>
  
  <p>Of course, I can do this by blitting those specific buffers afterwards or I can simply do the downsampling on the CPU (current solution). But then I read about viewport arrays and found this quote in the <a href="http://www.opengl.org/registry/specs/ARB/viewport_array.txt" rel="nofollow">ARB specification</a>, which seems to be exactly what I want, without any extra conversions.</p>
  
  <blockquote>
    <p>Additionally, when combined with multiple framebuffer attachments, it
    allows a different viewport rectangle to be selected for each.</p>
  </blockquote>
  
  <p>Of course, the specification never mentions afterwards how to do this or what they actually mean, <code>multiple framebuffer attachments</code> is quite generic. I only noticed I can set a specific viewport as an output of the geometry shader (output <code>gl_ViewportIndex</code>). So I could call the geometry twice for each viewport in the array. But as far as I understand, this will simply call the fragment shader with another viewport transformation applied, not one per target buffer. This of course makes not much sense for my usecase, also I can't see how this could ever help to select a viewport per framebuffer attachment</p>
  
  <p>For my situation it does not make much sense to add a geometry shader. And as viewport transform is only applied after the fragment shader, it does make sense to have a viewport per render target, which the previous quote seems to confirm. Is this actually possible, and if so, how would I accomplish this?</p>
  
  <p>Oh, and I've tried the obvious already: resizing the renderbuffer of that target (let's say I use <code>GL_COLOR_ATTACHMENT1</code>) to the downsampled version and setting index 1 of the viewport array to the according size. I ended up with a picture of the lower left quadrant of the image, essentially telling me the viewport was unchanged.</p>