Getting texture dimensions



I’m using the example in the book to load a texture but I’m at a loss as how to get the dimensions of the texture. I can use it to create a SpriteRender by creating a generated SpriteSheet as shown in the book and all looks great.

Is it possible and I’m missing something blatantly obvious or does the texture get uploaded and hidden away? Should I be using something else to load the file and then hand that off to the Texture so I can get the dimensions?


(Chris Allison) #2

I had thr same issue for custom sprites and ended up just loading the image in GIMP and getting the dimensions from there.


Cheers for the reply @ToferC

So the work around I’m using is to use the image crate to load up the image and get the info, and then load up the Texture to create the SpriteSheet with the info and then create the SpriteRender.

This is for debug builds. For release I’ll generate texture sheets and us the TOML file format.


And there is a helper to just grab the dimensions without fully loading up the image.