java.lang.Object
technology.sola.engine.graphics.screen.Viewport
Viewport contains various information about the current viewport used. This is primarily used to keep track of the
correct
AspectRatioSizing
based on the current AspectMode
and screen width and height.-
Constructor Summary
ConstructorsConstructorDescriptionViewport
(int canvasWidth, int canvasHeight) Creates an instance of the viewport given the canvas's width and height. -
Method Summary
Modifier and TypeMethodDescriptionfloat
float
void
resize
(int screenWidth, int screenHeight) Recalculates theAspectRatioSizing
using the currentAspectMode
and the new screen width and height.void
setAspectMode
(AspectMode aspectMode) Updates theAspectMode
used and recalculatesAspectRatioSizing
.
-
Constructor Details
-
Viewport
public Viewport(int canvasWidth, int canvasHeight) Creates an instance of the viewport given the canvas's width and height.- Parameters:
canvasWidth
- the width of the canvas (renderer)canvasHeight
- the height of the canvas (renderer)
-
-
Method Details
-
getAspectMode
- Returns:
- the current
AspectMode
-
setAspectMode
Updates theAspectMode
used and recalculatesAspectRatioSizing
.- Parameters:
aspectMode
- the newAspectMode
-
getAspectRatioSizing
- Returns:
- the current
AspectRatioSizing
-
getRendererToAspectRatioX
public float getRendererToAspectRatioX()- Returns:
- the ratio of
canvasWidth
toAspectRatioSizing.width()
-
getRendererToAspectRatioY
public float getRendererToAspectRatioY()- Returns:
- the ratio of
canvasHeight
toAspectRatioSizing.height()
-
resize
public void resize(int screenWidth, int screenHeight) Recalculates theAspectRatioSizing
using the currentAspectMode
and the new screen width and height.- Parameters:
screenWidth
- the width of the screenscreenHeight
- the height of the screen
-