Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Spritesheets or individual images?  (Read 3059 times)

0 Members and 1 Guest are viewing this topic.

TheGuerilla

  • Newbie
  • *
  • Posts: 27
  • Cynical Prick.exe
    • View Profile
    • Email
Spritesheets or individual images?
« on: July 12, 2016, 01:07:30 am »
Kind of a random question out of the blue, but would it be faster to load in one "master" spritesheet with all your game images then create the sprites off of rectangles of that texture, or individually load each image as a texture and bind the sprites?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Spritesheets or individual images?
« Reply #1 on: July 12, 2016, 03:12:43 am »
Use spritesheets when possible, but keep in mind that there are texture size limits, so huge textures should be split into multiple ones.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DragonDePlatino

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Spritesheets or individual images?
« Reply #2 on: July 12, 2016, 06:47:57 am »
Like eXpl0it3r said, big textures with many sprites are your best bet. As an artist, I also find them easier to maintain instead of having many smaller images. If you're curious to see the largest texture size your computer supports, try running this:

Code: [Select]
void getMaxTextureSize()
{
int size = 1;
sf::Texture testtexture;
while(testtexture.create(size, size))
{
size *= 2;
std::cout << "Created texture of size " << testtexture.getSize().x << ", " << testtexture.getSize().y << std::endl;
}
system("pause");
}

On me and my brother's computer, the max is a surprising 16384. I imagine mobile devices have a much smaller limit. If anyone knows, what's the expected texture size limit of a lower-end smartphone?
« Last Edit: July 12, 2016, 06:50:22 am by DragonDePlatino »

TheGuerilla

  • Newbie
  • *
  • Posts: 27
  • Cynical Prick.exe
    • View Profile
    • Email
Re: Spritesheets or individual images?
« Reply #3 on: July 12, 2016, 07:29:47 am »
I managed to clock in at 8192, considering my graphics is very low end. So realistically if I keep my spritesheets 4096 or below, very few people would be unable to run it.

Thank you to both of you!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Spritesheets or individual images?
« Reply #4 on: July 12, 2016, 02:06:19 pm »
Like eXpl0it3r said, big textures with many sprites are your best bet.
Just to be clear here, this is a large texture that contains many separate images where, realistically, you would use a single sf::Sprite per texture section shown. (it sounded like you meant multiple sf::Sprites :P )

If you're curious to see the largest texture size your computer supports, try running this:
[some code]
I would actually suggest this:
std::cout << sf::Texture::getMaximumSize() << " x " << sf::Texture::getMaximumSize() << std::cout;
;)
Documentation.

I think it's the measurement of a single dimension (that makes much more sense) rather the total number of pixels allowed in the texture. The documentation should be more clear.
*cough, cough, nudge, nudge*

realistically if I keep my spritesheets 4096 or below, very few people would be unable to run it
Reliably, they should be kept to 1024x1024 although 2048x2048 is an almost acceptable enough minimum.
« Last Edit: July 12, 2016, 02:07:52 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything