Class ScissorStack
- java.lang.Object
-
- com.badlogic.gdx.scenes.scene2d.utils.ScissorStack
-
public class ScissorStack extends java.lang.ObjectA stack ofRectangleobjects to be used for clipping viaGL20.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 ScissorStack()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcalculateScissors(Camera camera, float viewportX, float viewportY, float viewportWidth, float viewportHeight, Matrix4 batchTransform, Rectangle area, Rectangle scissor)static voidcalculateScissors(Camera camera, Matrix4 batchTransform, Rectangle area, Rectangle scissor)Calculates a scissor rectangle using 0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight() as the viewport.static RectanglegetViewport()static RectanglepeekScissors()static RectanglepopScissors()Pops the current scissor rectangle from the stack and sets the new scissor area to the new top of stack rectangle.static booleanpushScissors(Rectangle scissor)Pushes a new scissorRectangleonto the stack, merging it with the current top of the stack.
-
-
-
Method Detail
-
pushScissors
public static boolean pushScissors(Rectangle scissor)
Pushes a new scissorRectangleonto 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 invokeGL20.glScissor(int, int, int, int)with the final top of stack rectangle. In case no scissor is yet on the stack this will also enableGL20.GL_SCISSOR_TESTautomatically.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.
-
popScissors
public static Rectangle popScissors()
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_TESTis disabled.Any drawing should be flushed before popping scissors.
-
calculateScissors
public static void calculateScissors(Camera camera, Matrix4 batchTransform, Rectangle area, Rectangle scissor)
Calculates a scissor rectangle using 0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight() as the viewport.
-
calculateScissors
public static void calculateScissors(Camera camera, float viewportX, float viewportY, float viewportWidth, float viewportHeight, Matrix4 batchTransform, Rectangle area, Rectangle scissor)
Calculates a scissor rectangle in OpenGL ES window coordinates from aCamera, a transformationMatrix4and an axis alignedRectangle. 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 forGL20.glScissor(int, int, int, int).
-
getViewport
public static Rectangle getViewport()
- Returns:
- the current viewport in OpenGL ES window coordinates based on the currently applied scissor
-
-