APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.utils

public Class ScissorStack

extends Object
Class Inheritance
Imports
com.badlogic.gdx.Gdx, com.badlogic.gdx.graphics.Camera, .GL20, com.badlogic.gdx.graphics.glutils.HdpiUtils, com.badlogic.gdx.math.Matrix4, .Rectangle, .Vector3, com.badlogic.gdx.utils.Array, .Null

A stack of Rectangle 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.
Author
mzechner

Field Summary

Modifier and TypeField and Description
private static Array<Rectangle>
pack-priv static Vector3
pack-priv static final Rectangle

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
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.

public static void
calculateScissors(Camera
the Camera
camera
,
float viewportX, float viewportY, float viewportWidth, float viewportHeight, Matrix4
the transformation Matrix4
batchTransform
,
Rectangle
the Rectangle to transform to window coordinates
area
,
Rectangle
the Rectangle to store the result in
scissor
)

Calculates a scissor rectangle in OpenGL ES window coordinates from a Camera, a transformation Matrix4 and an axis aligned Rectangle.

private static void
fix(Rectangle rect)

public static Rectangle
getViewport()

Returns: the current viewport in OpenGL ES window coordinates based on the currently applied scissor

public static Rectangle
peekScissors()

Returns: null if there are no scissors.

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.

public static boolean

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.
pushScissors
(Rectangle scissor)

Pushes a new scissor Rectangle onto the stack, merging it with the current top of the stack.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

scissorsback to summary
private static Array<Rectangle> scissors
tmpback to summary
pack-priv static Vector3 tmp
viewportback to summary
pack-priv static final Rectangle viewport

Constructor Detail

ScissorStackback to summary
public ScissorStack()

Method Detail

calculateScissorsback to summary
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.

See Also
calculateScissors(Camera, float, float, float, float, Matrix4, Rectangle, Rectangle)
calculateScissorsback to summary
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 a Camera, a transformation Matrix4 and an axis aligned Rectangle. 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:Camera

the Camera

batchTransform:Matrix4

the transformation Matrix4

area:Rectangle

the Rectangle to transform to window coordinates

scissor:Rectangle

the Rectangle to store the result in

fixback to summary
private static void fix(Rectangle rect)
getViewportback to summary
public static Rectangle getViewport()
Returns:Rectangle

the current viewport in OpenGL ES window coordinates based on the currently applied scissor

peekScissorsback to summary
public static Rectangle peekScissors()
Returns:Rectangle

null if there are no scissors.

Annotations
@Null
popScissorsback to summary
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_TEST is disabled.

Any drawing should be flushed before popping scissors.

pushScissorsback to summary
public static boolean pushScissors(Rectangle scissor)

Pushes a new scissor Rectangle 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:boolean

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.