-
Notifications
You must be signed in to change notification settings - Fork 0
Screen & viewport
Every application or game that uses graphics, needs to work with the screen in a way. This page describes the different projections (for 2D and 3D) and how to set them up with libGDX.
For every application that uses graphics, a viewport needs to be defined. The viewport is a rectangular viewing region of the screen where the 3D scene is projected. It is nothing more than mapping the 3 dimensional objects to the 2 dimensional plane.
The following image shows a typical 3D scene with a perspective projection.
The eye is where the camera is and the viewport is the plane where all the objects found in the view frustum are projected to.
The view frustum is a pyramid with two clipping planes. Objects or parts of objects found outside the frustum, won't be rendered. It is not possible to define a near clipping plane closer to the observer than the viewport.
When the human eye looks at a scene, objects in the distance appear smaller than objects close by. This is called perspective and this is used for 3D games and applications. Perspective projection is the final image rendered onto the viewport with the objects scaled according to their distance from the observation point.
Orthogonal projection on the other hand, ignores the scaling effect and projects objects to the viewport maintaining their original size.
The following diagram shows the orthogonal projection.
For examples on how to work with the viewport, refer to this page where the notions are presented extensively with great examples.
To learn how to use the Orthographic Camera for simple 2D worlds.
-
Developer's Guide
- Introduction
- Goals & Features
- Community & Support
- Contributing
- Games Built with Libgdx
- Prerequisites
- Gradle Project Setup, Running, Debugging and Packaging
- Project Setup, Running & Debugging
- Third Party Services
- Working from Source
- Using libgdx with other JVM languages
- The Application Framework
- A Simple Game
- File Handling
- Networking
- Preferences
- Input Handling
- Memory Management
- Audio
-
Graphics
- Configuration & Querying Graphics ??
- Fullscreen & VSync
- Continuous & Non-Continuous Rendering
- Clearing the Screen
- Take a Screenshot
- OpenGL ES Support * Configuration & Querying OpenGL ?? * Direct Access ?? * Utility Classes * Rendering Shapes * Textures & TextureRegions * Meshes * Shaders * Frame Buffer Objects
- 2D Graphics * SpriteBatch, TextureRegions, and Sprite * 2D Animation * Clipping, with the use of ScissorStack * Orthographic camera * Mapping Touch Coordinates ?? * Viewports * NinePatches * Bitmap Fonts * Distance field fonts * Using TextureAtlases * Pixmaps * Packing Atlases Offline * Packing Atlases at Runtime * 2D Particle Effects * Tile Maps * scene2d * scene2d.ui * Skin
- 3D Graphics * Quick Start * Models * Material and environment * 3D animations and skinning * Importing Blender models in LibGDX * Perspective Camera ?? * Picking ??
- Managing Your Assets
- Utilities
-
Math Utilities
- Interpolation
- Vectors, Matrices, Quaternions
- Circles, Planes, Rays, etc.
- Path interface & Splines
- Bounding Volumes ??
- Intersection & Overlap Testing ??
- Physics
- Tools
- Extensions
- Deploying your Application
- Building Libgdx ??
- Known Issues
- Articles
- Deprecated (May be outdated)