libgdx/libgdx — pull request #1467 by nooone (2014-03-12 22:55:28+00:00)
Title: Viewports for more comfortable handling of different aspect ratios

The previous pull request was this one: https://github.com/libgdx/libgdx/pull/1423

I have now tried to put a few more features into the Viewport. It is not as "deeply" integrated into the API as NateS described it, but it can handle a lot more cases now.

- It supports different scaling approaches, namely:
- 1. StretchingViewport: Has a fixed size which gets stretched to fit the screen. Does not keep the aspect ratio
- 2. FixedViewport: Has a fixed size which gets scaled appropriately while keeping the same aspect ratio. This may lead to bars at the border of the screen.
- 3. ScreenViewport: A viewport without a fixed size which gets always scaled up to the screen size.
- 4. Extendable: DoubleRatioViewport or MinMaxViewport which would scale between two viewports are possible, but I didn't have the time to implement those.
- The viewport can be "disabled" which allows to render stuff in the area of the black borders which might appear. I added a quick test for that as well.
- The utility methods for getPickRay, project and unproject now work with both Vector3 and Vector2
- I added some tests to demonstrate the different behaviours in different situations (Stage, Stage with Table, SpriteBatch with OrthographicCamera, Stage with Camera, ModelBatch with PerspectiveCamera), as well to show how the viewport can be used.

So far the viewports are completely additionally, which means they do not break the API anyhow. The viewports might be used, but it's not necessary. The genereal idea behind the viewports was to use them as some kind of "managers" where cameras and stages can be registered and automatically updated as soon as the viewport parameters change.
My next step would have been to integrate the viewport into stage and camera, but I didn't want to touch anything yet.

What do you guys think about it now? Especially Nathan to whom I have talked about the topic the most...