Class Viewport

    • Constructor Summary

      Constructors 
      Constructor Description
      Viewport()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void apply()
      Calls apply(boolean) with false.
      void apply​(boolean centerCamera)
      Applies the viewport to the camera and sets the glViewport.
      void calculateScissors​(Matrix4 batchTransform, Rectangle area, Rectangle scissor)  
      int getBottomGutterHeight()
      Returns the bottom gutter (black bar) height in screen coordinates.
      Camera getCamera()  
      int getLeftGutterWidth()
      Returns the left gutter (black bar) width in screen coordinates.
      Ray getPickRay​(float screenX, float screenY)  
      int getRightGutterWidth()
      Returns the right gutter (black bar) width in screen coordinates.
      int getRightGutterX()
      Returns the right gutter (black bar) x in screen coordinates.
      int getScreenHeight()  
      int getScreenWidth()  
      int getScreenX()  
      int getScreenY()  
      int getTopGutterHeight()
      Returns the top gutter (black bar) height in screen coordinates.
      int getTopGutterY()
      Returns the top gutter (black bar) y in screen coordinates.
      float getWorldHeight()  
      float getWorldWidth()  
      Vector2 project​(Vector2 worldCoords)
      Transforms the specified world coordinate to screen coordinates.
      Vector3 project​(Vector3 worldCoords)
      Transforms the specified world coordinate to screen coordinates.
      void setCamera​(Camera camera)  
      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.
      Vector2 toScreenCoordinates​(Vector2 worldCoords, Matrix4 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.
      Vector2 unproject​(Vector2 screenCoords)
      Transforms the specified screen coordinate to world coordinates.
      Vector3 unproject​(Vector3 screenCoords)
      Transforms the specified screen coordinate to world coordinates.
      void update​(int screenWidth, int screenHeight)
      Calls update(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 calls apply(boolean).
      • Methods inherited from class java.lang.Object

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

      • Viewport

        public Viewport()
    • Method Detail

      • 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.
      • unproject

        public Vector2 unproject​(Vector2 screenCoords)
        Transforms the specified screen coordinate to world coordinates.
        Returns:
        The vector that was passed in, transformed to world coordinates.
        See Also:
        Camera.unproject(Vector3)
      • project

        public Vector2 project​(Vector2 worldCoords)
        Transforms the specified world coordinate to screen coordinates.
        Returns:
        The vector that was passed in, transformed to screen coordinates.
        See Also:
        Camera.project(Vector3)
      • unproject

        public Vector3 unproject​(Vector3 screenCoords)
        Transforms the specified screen coordinate to world coordinates.
        Returns:
        The vector that was passed in, transformed to world coordinates.
        See Also:
        Camera.unproject(Vector3)
      • project

        public Vector3 project​(Vector3 worldCoords)
        Transforms the specified world coordinate to screen coordinates.
        Returns:
        The vector that was passed in, transformed to screen coordinates.
        See Also:
        Camera.project(Vector3)
      • toScreenCoordinates

        public Vector2 toScreenCoordinates​(Vector2 worldCoords,
                                           Matrix4 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.
      • getCamera

        public Camera getCamera()
      • setCamera

        public void setCamera​(Camera camera)
      • 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 by update(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 by update(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 by update(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 by update(int, int, boolean).
      • setScreenPosition

        public void setScreenPosition​(int screenX,
                                      int screenY)
        Sets the viewport's position in screen coordinates. This is typically set by update(int, int, boolean).
      • setScreenSize

        public void setScreenSize​(int screenWidth,
                                  int screenHeight)
        Sets the viewport's size in screen coordinates. This is typically set by update(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 by update(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.