Package arc.util.viewport
Class Viewport
java.lang.Object
arc.util.viewport.Viewport
- Direct Known Subclasses:
ExtendViewport
,ScalingViewport
,ScreenViewport
Manages a
Camera
and determines how world coordinates are mapped to and from the screen.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
apply()
Callsapply(boolean)
with false.void
apply
(boolean centerCamera) Applies the viewport to the camera and sets the glViewport.void
calculateScissors
(Mat batchTransform, Rect area, Rect scissor) int
Returns the bottom gutter (black bar) height in screen coordinates.int
Returns the left gutter (black bar) width in screen coordinates.int
Returns the right gutter (black bar) width in screen coordinates.int
Returns the right gutter (black bar) x in screen coordinates.int
int
int
int
int
Returns the top gutter (black bar) height in screen coordinates.int
Returns the top gutter (black bar) y in screen coordinates.float
float
Transforms the specified world coordinate to screen coordinates.void
void
setScreenBounds
(int screenX, int screenY, int screenWidth, int screenHeight) Sets the viewport's bounds in screen coordinates.void
setScreenHeight
(int screenHeight) Sets the viewport's height in screen coordinates.void
setScreenPosition
(int screenX, int screenY) Sets the viewport's position in screen coordinates.void
setScreenSize
(int screenWidth, int screenHeight) Sets the viewport's size in screen coordinates.void
setScreenWidth
(int screenWidth) Sets the viewport's width in screen coordinates.void
setScreenX
(int screenX) Sets the viewport's offset from the left edge of the screen.void
setScreenY
(int screenY) Sets the viewport's offset from the bottom edge of the screen.void
setWorldHeight
(float worldHeight) The virtual height of this viewport in world coordinates.void
setWorldSize
(float worldWidth, float worldHeight) void
setWorldWidth
(float worldWidth) The virtual width of this viewport in world coordinates.toScreenCoordinates
(Vec2 worldCoords, Mat transformMatrix) Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top left and the the y-axis is pointing downwards.Transforms the specified screen coordinate to world coordinates.final void
update
(int screenWidth, int screenHeight) Callsupdate(int, int, boolean)
with false.void
update
(int screenWidth, int screenHeight, boolean centerCamera) Configures this viewport's screen bounds using the specified screen size and callsapply(boolean)
.
-
Constructor Details
-
Viewport
public Viewport()
-
-
Method Details
-
apply
public void apply()Callsapply(boolean)
with false. -
apply
public void apply(boolean centerCamera) Applies the viewport to the camera and sets the glViewport.- Parameters:
centerCamera
- If true, the camera position is set to the center of the world.
-
update
public final void update(int screenWidth, int screenHeight) Callsupdate(int, int, boolean)
with false. -
update
public void update(int screenWidth, int screenHeight, boolean centerCamera) Configures this viewport's screen bounds using the specified screen size and callsapply(boolean)
. Typically called fromApplicationListener.resize(int, int)
The default implementation only calls
apply(boolean)
. -
unproject
Transforms the specified screen coordinate to world coordinates.- Returns:
- The vector that was passed in, transformed to world coordinates.
- See Also:
-
project
Transforms the specified world coordinate to screen coordinates.- Returns:
- The vector that was passed in, transformed to screen coordinates.
- See Also:
-
calculateScissors
-
toScreenCoordinates
Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top left and the the y-axis is pointing downwards. -
getCamera
-
setCamera
-
getWorldWidth
public float getWorldWidth() -
setWorldWidth
public void setWorldWidth(float worldWidth) The virtual width of this viewport in world coordinates. This width is scaled to the viewport's screen width. -
getWorldHeight
public float getWorldHeight() -
setWorldHeight
public void setWorldHeight(float worldHeight) The virtual height of this viewport in world coordinates. This height is scaled to the viewport's screen height. -
setWorldSize
public void setWorldSize(float worldWidth, float worldHeight) -
getScreenX
public int getScreenX() -
setScreenX
public void setScreenX(int screenX) Sets the viewport's offset from the left edge of the screen. This is typically set byupdate(int, int, boolean)
. -
getScreenY
public int getScreenY() -
setScreenY
public void setScreenY(int screenY) Sets the viewport's offset from the bottom edge of the screen. This is typically set byupdate(int, int, boolean)
. -
getScreenWidth
public int getScreenWidth() -
setScreenWidth
public void setScreenWidth(int screenWidth) Sets the viewport's width in screen coordinates. This is typically set byupdate(int, int, boolean)
. -
getScreenHeight
public int getScreenHeight() -
setScreenHeight
public void setScreenHeight(int screenHeight) Sets the viewport's height in screen coordinates. This is typically set byupdate(int, int, boolean)
. -
setScreenPosition
public void setScreenPosition(int screenX, int screenY) Sets the viewport's position in screen coordinates. This is typically set byupdate(int, int, boolean)
. -
setScreenSize
public void setScreenSize(int screenWidth, int screenHeight) Sets the viewport's size in screen coordinates. This is typically set byupdate(int, int, boolean)
. -
setScreenBounds
public void setScreenBounds(int screenX, int screenY, int screenWidth, int screenHeight) Sets the viewport's bounds in screen coordinates. This is typically set byupdate(int, int, boolean)
. -
getLeftGutterWidth
public int getLeftGutterWidth()Returns the left gutter (black bar) width in screen coordinates. -
getRightGutterX
public int getRightGutterX()Returns the right gutter (black bar) x in screen coordinates. -
getRightGutterWidth
public int getRightGutterWidth()Returns the right gutter (black bar) width in screen coordinates. -
getBottomGutterHeight
public int getBottomGutterHeight()Returns the bottom gutter (black bar) height in screen coordinates. -
getTopGutterY
public int getTopGutterY()Returns the top gutter (black bar) y in screen coordinates. -
getTopGutterHeight
public int getTopGutterHeight()Returns the top gutter (black bar) height in screen coordinates.
-