Class ScissorStack

java.lang.Object
lol.trq.helios.state.ScissorStack

public final class ScissorStack extends Object
Nested clipping rectangles in drawing units, each clipped to the one outside it.

Drawing units are screen space with the origin at the top left, and pixel is one framebuffer pixel in those units. The first push(float, float, float, float, float) saves the scissor state; the last pop() restores it. A clip covers every pixel the rectangle touches.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a stack.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns how many clips are pushed.
    void
    pop()
    Returns to the previous clip, or to the state before the first push.
    void
    push(float x, float y, float width, float height, float pixel)
    Clips further drawing to a rectangle, inside the current clip.
    static int[]
    toPixels(float x, float y, float width, float height, float pixel, int framebufferHeight)
    Converts a rectangle in drawing units to a scissor box, rounding outward.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ScissorStack

      public ScissorStack(GlBackend gl, GlStateCache cache, SurfaceSize surface)
      Creates a stack.
      Parameters:
      gl - the backend
      cache - the host's state cache
      surface - the window framebuffer size
  • Method Details

    • push

      public void push(float x, float y, float width, float height, float pixel)
      Clips further drawing to a rectangle, inside the current clip.
      Parameters:
      x - left
      y - top
      width - width
      height - height
      pixel - one framebuffer pixel in drawing units
    • pop

      public void pop()
      Returns to the previous clip, or to the state before the first push.
    • depth

      public int depth()
      Returns how many clips are pushed.
      Returns:
      the depth
    • toPixels

      public static int[] toPixels(float x, float y, float width, float height, float pixel, int framebufferHeight)
      Converts a rectangle in drawing units to a scissor box, rounding outward.
      Parameters:
      x - left
      y - top
      width - width
      height - height
      pixel - one framebuffer pixel in drawing units
      framebufferHeight - the framebuffer height in pixels
      Returns:
      {x, y, width, height} in pixels, y from the bottom, never negative in size