def render
      raise ArgumentError, "Block required" unless block_given?
      raise Error, "Can't nest rendering" if rendering?

      $window.flush # Ensure that any drawing _before_ the render block is drawn to screen, rather than into the buffer.

      render_

      @rendering = true

      # Project onto the texture itself, using Gosu (inverted) coordinates.
      Gl.glPushMatrix
      Gl.glMatrixMode Gl::GL_PROJECTION
      Gl.glLoadIdentity
      Gl.glViewport 0, 0, width, height
      Gl.glOrtho 0, width, height, 0, -1, 1

      begin
        yield self
      ensure
        $window.flush # Force all the drawing to draw now!
        Gl.glBindFramebufferEXT Gl::GL_FRAMEBUFFER_EXT, 0

        @rendering = false

        Gl.glPopMatrix

        cache.refresh # Force lazy reloading of the cache.
      end

      self
    end
def render
      raise ArgumentError, "Block required" unless block_given?
      raise Error, "Can't nest rendering" if rendering?

      $window.flush # Ensure that any drawing _before_ the render block is drawn to screen, rather than into the buffer.

      render_

      @rendering = true

      # Project onto the texture itself, using Gosu (inverted) coordinates.
      Gl.glPushMatrix
      Gl.glMatrixMode Gl::GL_PROJECTION
      Gl.glLoadIdentity
      Gl.glViewport 0, 0, width, height
      Gl.glOrtho 0, width, height, 0, -1, 1

      begin
        yield self
      ensure
        $window.flush # Force all the drawing to draw now!
        Gl.glBindFramebufferEXT Gl::GL_FRAMEBUFFER_EXT, 0

        @rendering = false

        Gl.glPopMatrix

        cache.refresh # Force lazy reloading of the cache.
      end

      self
    end
Enable the texture to use (e.g. to draw or convert it).