0
\$\begingroup\$

In a lot of the libgdx tutorials that I have took until now, I am told to resize the screen of the game using the SetToOrtho() of the orthographic camera. However, I don't get this part. Why do I have to resize the screen and make the sprites look bigger when I can just make the sprites themselves big at the first place?

| improve this question | | | | |
\$\endgroup\$
  • \$\begingroup\$ Just a ballpark guess: it is more efficient then having the user manually resize the sprites. \$\endgroup\$ – JDSweetBeat Feb 7 '17 at 16:17
0
\$\begingroup\$

You're not actually "resizing the screen" with setToOrtho. You're building an orthographic projection matrix that takes into account the size of the screen (note the source).

By doing this, you effectively map the world coordinates of your sprites to pixel coordinates on the screen, which lets you work more naturally in terms of pixel positioning and pixel sizes.

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ Oh ok thank you for the answer. That makes sense!But this makes me ask another question... An orthographic projection matrix is basically a means of representing a three-dimensional object in two dimensions right? Then why did the tutorial use orthographic projection at the first place when the sprites are already in 2D. (The sprites were flat images) \$\endgroup\$ – chanu19 Feb 7 '17 at 16:38
  • \$\begingroup\$ All projections (we use in computer graphics) are ways of transforming and representing 3D geometry in 2D. An orthographic projection is a parallel projection where all projected lines are orthogonal to the plane of projection; in particular it is not a perspective projection and doesn't have that perspective effect of things getting smaller as they are "further" from you. This makes it useful for 2D work. \$\endgroup\$ – user1430 Feb 7 '17 at 17:06
  • \$\begingroup\$ Your sprite textures are 2D, but the geometry you draw those textures with is 3D; the underlying graphics API used by libgdx (OpenGL, etc) is a 3D graphics API. \$\endgroup\$ – user1430 Feb 7 '17 at 17:07
  • \$\begingroup\$ Ohhh, I never knew that the underlying graphics used by libgdx is 3D and that we change it 2D to render it to the screen. Now it is so clear, Why couldn't the tutorials tell me that :( \$\endgroup\$ – chanu19 Feb 8 '17 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.