What is my complete thinking algorithm to understand all possible width/height transformations on the path PixMap -> (physical) Screen/monitor
?
Sorry for the stupid question, but how do these sizes corellate / scale / interact?
What size do I actually see on the screen and what scaling effects happen?
I need a quick-start, but googling does not yield direct and systematic answers.
PixMap
is a picture/image (from a file or some programmatically drawn primitive) with its width/height in pixels.
Later on this PixMap will be shown on the physical Screen of some physical device. As I understand, actually it will be shown only in the part of the physical device screen - only within my game's application window (config.width / config.height
in LwjglApplicationConfiguration
) - I guess it is in pixels...
PixMap
is wrapped into Texture
(I don't fully understand why - OpenGL says Texture is a container for one or more images, but new Texture(PixMap)
takes only a single PixMap). Texture
does not have any sizes (OK, it is just a container for PixMap(s).
Now Texture
is wrapped into Sprite
(new Sprite(Texture)
). Sprite has its own width/height. Sprite is some visible part of my game (moving robot, ball, tank, missile, etc). So Sprite size overrides PixMap size and therefore shall cause scaling somehow?
But is Sprite size what I actually see on the screen (if I never called sprite.scale()
)? sprite.setSize(float, float)
- means height/width in pixels??? Can Sprite automatically set size exactly to be the same as the underlying PixMap?
Now Camera
size - Camera is what the user actually sees on screen (part of the Game World which might be larger than screen), right? So I can set Camera size equal to Gdx Application Window (config.width / config.height in Launcher class)? Or Camera size defines visible (displayed to the user) part of the physical screen? If my game fits the whole of the screen, I can set Camera size to be equal to screen size and that's all. Why do I need Camera? I think I fail to understand Camera completely.
And ViewPort
- it is "same" as Camera (it manages Camera). But I see that ExtendViewPort and ScalingViewPort "tamper" with scaling, so they resize my Sprite/PixMap/Camera sizes?
Besides, all ViewPort
classes have minHeight/minWidth
in their constructors - another size transformation / scaling?
P.S. Another issue is coordinates in all those cases. What relative to what?
This answer is also partially related and helpful.