There are two method of SpriteBatch in LibGDX: setTransformMatrxi and setProjectionMatrix.

I know one can use batch.setProjectionMatrix(camera.combined) to define how/where an object should be rendered on the screen. But then what does setTransformMatrix do?

I googled "difference between transform matrix and projection matrix" but no luck.


1 Answer 1


Transformation matrix:

This matrix defines where to render your geometry.

Projection matrix:

Don't use this matrix to move stuff around, it's not meant to. This matrix defines how to render your geometry. For example, this can make the game render in a perspective projection (things farther away are smaller) or in an ortographic projection (everything is the same size). This is where camera.combined should go.

They aren't interchangeable, because they get multiplied in the shaders, and matrix multiplication is not cummulative.

  • \$\begingroup\$ Thank you, but I'm still a little battled. For example when I move my camera, doesn't it change where to render my geometry? Should this change be implemented via transformation matrix or projection matrix? \$\endgroup\$ Jan 19, 2017 at 8:56
  • \$\begingroup\$ @LaiYu-Hsuan ask the questions highlighted in my question. Does moving the camera change how the objects are rendered or where? Obviously the latter one. Moving a camera basically just moves everything else in the other direction. \$\endgroup\$
    – Bálint
    Jan 19, 2017 at 8:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .