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

Author Topic: Would smaller sized images (in terms of memory) make the game run faster?  (Read 2721 times)

0 Members and 1 Guest are viewing this topic.

dixondean25

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
For example: a 500 x 500 image saved as .png will require more memory than if it was a .jpg.

So do images that require less space (in terms of memory) make the game
1. run faster? (as in draw faster, or just anything related to fps)
2. load faster?
3. or nothing at all?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
You should choose a file format depending on its use case. If you have pixel-like images or images with sharp edges use a PNG (lossless). If you have something more photo realistic pick a JPG (lossy).

The image data itself will be converted to RBGA values in memory anyways, so the only difference the format will make is the loading/reading time from the hard drive. With an 500x500 image you might not even be able to measure a difference in loading time. So yeah it really doesn't matter.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

dixondean25

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
I actually have images bigger than that (4000 x 2000 )~ish that can be many Mb difference in terms of memory. But I load them with an sf::Image then break that up into four textures and four sprites. If i broke it up into more and smaller textures and sprites would that make a difference?

Also, thank you for helping me  :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Also, the loading/saving time is not only dependent on the image size, but also on the format. JPEG is a relatively complex format with various stages of transforms and compressions, which also takes time to decode/encode. Furthermore, the JPEG file size depends on the "quality" (the quantisation factor), so a general statement like "JPEGs are smaller than PNGs" is useless, especially considering the loss of information in one but not the other. As eXpl0it3r says, JPEG is a good format for photographs, while PNG is better for graphics or images that need to be pixel-perfect.

If i broke it up into more and smaller textures and sprites would that make a difference?
Yes, there would be more textures :P

Difference with respect to what? If you really care about performance, measure it. The graphics card and driver as well as other factors may also have an influence. But in general, don't make your life complicated if you don't need to. There is also a hardware-dependent limit to the texture size.

By the way, the class thor::BigTexture I wrote automates the splitting into smaller textures for you and is used very similarly to sf::Texture.
« Last Edit: July 03, 2014, 04:32:17 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

dixondean25

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
If i broke it up into more and smaller textures and sprites would that make a difference?
Yes, there would be more textures :P

Difference with respect to what? If you really care about performance, measure it. The graphics card and driver as well as other factors may also have an influence. But in general, don't make your life complicated if you don't need to. There is also a hardware-dependent limit to the texture size.

By the way, the class thor::BigTexture I wrote automates the splitting into smaller textures for you and is used very similarly to sf::Texture.

In terms of speed and raising fps is what i was asking about with more textures/sprites. I will check out thor::BigTexture. Does it help with fps?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Do you have an actual performance issue or are you just prematurely optimizing things?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

dixondean25

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
I'm really sorry it was my laptop. It was using the built in graphics card instead of the NVIDIA GeForce.
I'm sorry for wasting all of y'alls time, thank you for replying though i appreciate it.

 

anything