Class ScissorStack

java.lang.Object
arc.graphics.g2d.ScissorStack

public class ScissorStack extends Object
A stack of Rect objects to be used for clipping via GL20.glScissor(int, int, int, int). When a new Rectangle is pushed onto the stack, it will be merged with the current top of stack. The minimum area of overlap is then set as the real top of the stack.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    calculateScissors(Camera camera, float viewportX, float viewportY, float viewportWidth, float viewportHeight, Mat batchTransform, Rect area, Rect scissor)
    Calculates a scissor rectangle in OpenGL ES window coordinates from a Camera, a transformation Mat and an axis aligned Rect.
    static void
    calculateScissors(Camera camera, Mat batchTransform, Rect area, Rect scissor)
    Calculates a scissor rectangle using 0,0,Core.graphics.getWidth(),Core.graphics.getHeight() as the viewport.
    static Rect
     
    static Rect
     
    static Rect
    pop()
    Pops the current scissor rectangle from the stack and sets the new scissor area to the new top of stack rectangle.
    static boolean
    push(Rect scissor)
    Pushes a new scissor Rect onto the stack, merging it with the current top of the stack.
    static boolean
    pushWorld(Rect scissorWorld)
     

    Methods inherited from class java.lang.Object

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

    • ScissorStack

      public ScissorStack()
  • Method Details

    • push

      public static boolean push(Rect scissor)
      Pushes a new scissor Rect onto the stack, merging it with the current top of the stack. The minimal area of overlap between the top of stack rectangle and the provided rectangle is pushed onto the stack. This will invoke GL20.glScissor(int, int, int, int) with the final top of stack rectangle. In case no scissor is yet on the stack this will also enable GL20.GL_SCISSOR_TEST automatically.

      Any drawing should be flushed before pushing scissors.

      Returns:
      true if the scissors were pushed. false if the scissor area was zero, in this case the scissors were not pushed and no drawing should occur.
    • pop

      public static Rect pop()
      Pops the current scissor rectangle from the stack and sets the new scissor area to the new top of stack rectangle. In case no more rectangles are on the stack, GL20.GL_SCISSOR_TEST is disabled.

      Any drawing should be flushed before popping scissors.

    • pushWorld

      public static boolean pushWorld(Rect scissorWorld)
    • peek

      public static Rect peek()
    • calculateScissors

      public static void calculateScissors(Camera camera, Mat batchTransform, Rect area, Rect scissor)
      Calculates a scissor rectangle using 0,0,Core.graphics.getWidth(),Core.graphics.getHeight() as the viewport.
      See Also:
    • calculateScissors

      public static void calculateScissors(Camera camera, float viewportX, float viewportY, float viewportWidth, float viewportHeight, Mat batchTransform, Rect area, Rect scissor)
      Calculates a scissor rectangle in OpenGL ES window coordinates from a Camera, a transformation Mat and an axis aligned Rect. The rectangle will get transformed by the camera and transform matrices and is then projected to screen coordinates. Note that only axis aligned rectangles will work with this method. If either the Camera or the Matrix4 have rotational components, the output of this method will not be suitable for GL20.glScissor(int, int, int, int).
      Parameters:
      camera - the Camera
      batchTransform - the transformation Mat
      area - the Rect to transform to window coordinates
      scissor - the Rectangle to store the result in
    • getViewport

      public static Rect getViewport()
      Returns:
      the current viewport in OpenGL ES window coordinates based on the currently applied scissor