Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Doing high resolution renderings with OpenGL is a bit tricky. One problem is, that pixel ownership tests get in the way. The other are the maximum size for a framebuffer (object). The first problem can be overcome by using a framebuffer object or a PBuffer.</p> <p>The second requires some trickery: Let's say we want to render an image of size W×H, where W and H exceed the maximum framebuffer size; <code>glGetInteger</code> of the tokens GL_MAX_VIEWPORT_SIZE, GL_MAX_TEXTURE_SIZE, GL_MAX_RENDERBUFFER_SIZE gives you those limits. So what you have to do is split up the target image into tiles smaller than those limits, render those tiles and then recombine them. Let's say W_t and H_t are the tile sizes, <code>W_t := W / N</code>, <code>H_t := H / M</code> and we have an accordingly sized PBuffer or Framebuffer object. Then we can render those tiles with a 2-loop:</p> <pre><code>for m in 0 to M: for n in 0 to N: render_tile(n, m) </code></pre> <p>So how does <code>render_tile(n,m)</code> look like?</p> <pre><code>render_tile(n,m): </code></pre> <p>Apparently we're using the whole tile as renderbuffer so</p> <pre><code> glViewport(0, 0, W_t, H_t) </code></pre> <p>so what changes is the projection. Somehow we've to shift the projection along with the tile in the projection plane. The projection plane is also known as the 'near' plane. The extents of the near plane are <code>right - left</code> and <code>top - bottom</code>, so we're splitting the near plane into tiles of size <code>(right - left) / N</code>×<code>(top - bottom) / M</code> so that's what we need to use as shift step size:</p> <pre><code> shift_X = (right - left) / N shift_Y = (top - bottom) / M glMatrixMode(GL_PROJECTION) glLoadIdentity() switch Projection: case Ortho: glOrtho( left + shift_X * n, left + shift_X * (n+1), bottom + shift_Y * m, bottom + shift_Y * (n+1), near, far) case Perspective: glFrustum( left + shift_X * n, left + shift_X * (n+1), bottom + shift_Y * m, bottom + shift_Y * (n+1), near, far) render_scene() </code></pre> <p>And just in case how we get <code>left, right, top, bottom</code> for perspective:</p> <pre><code>right = -0.5 * tan(fov) * near left = -right; top = aspect * right bottom = -top </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload