I'm making a game with LWJGL (and Slick-util) and I was going to use the Texture.getWidth()
and Texture.getHeight()
to get the width and height of a Texure
object, instead of typing in the width and height manually, but I found out that those functions returns a float
. I want to get the width of the Texture
in pixels, but the function returns a float, so I'm unsure what "unit" the function actually returns, because pixels must be int
(not floats, because you cant render the half of a pixel with one color and the other half of it with another color).
Can I just cast them to int
and it's fine?
Sorry for the quick asking, I found the answer by looking in the javadocs for Slick-util.
To get the size of the original image, use Texture.getImageWidth()
and Texture.getImageHeight()
.