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

Author Topic: Loading lots of images  (Read 2384 times)

0 Members and 1 Guest are viewing this topic.

CptZouglou

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Loading lots of images
« on: August 21, 2012, 11:07:07 pm »
Hi,

First of all, thanks for this wonderful library. It's very intuitive and efficient.

Here is my issue: I'm making a game in which I have many transparency png to load. I have something like 2800 different files. All those files combined weight ~40Mo on the HD, but I'm guessing that when they are loaded they take much more space in RAM (all the files have quite a lot of 100% transparent pixels). I found out that when loadad, all the files require ~6.4Go of RAM !

On a side note, I don't need to rotate or process these images in anyway, just the raw image to display... and only 50 sprites are displayed at the same time (I switch images for animations).
So, is there any way to use compressed textures, or any smarter way to handle this problem with sfml ? (or maybe I shouldn't use SFML ?)

Thanks for your insights !

Zouglou

Edit: I load from lots of files instead of from an atlas, can it be a source of problems too ?
« Last Edit: August 21, 2012, 11:12:14 pm by CptZouglou »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Loading lots of images
« Reply #1 on: August 21, 2012, 11:54:19 pm »
Well it doesn't really matter if you somehow could load them compressed into memory because at some point you'll have to decompress them to display all the pixels. SFML does not support this, although since you're only talking about images I guess you're using SFML 1.6. whereas SFML 2.0 uses a diffrent graphic system with sf::Textures maybe you want to give that a try but I don't see any luck in that direction.

I mean it's kind of the same problem with content richer games, you just can't load everything at once into memory, that's why you get loading screens in games etc. So you'll have to load the images when you need them. I've no idea what you're doing but I guess it should somehow be possible to estimate at which point you need it and then you could load the image in a seperate thread so you wouldn't affect the application, but loading in a second thread isn't the most trivial task.

What are you trying to do anyways?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CptZouglou

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Loading lots of images
« Reply #2 on: August 22, 2012, 12:10:16 am »
Thanks for the quick reply !

I'm doing a game in which there are many different animations. They are chosen at random anytime, so I should have all the images already loaded when I play one. All the images are photos of real objects, and the game is fully in stop motion :D That's why I don't want to reduce too much the size of the images, because they are quite beautiful!

Anyways, do you recommand switching to 2.0 ? Is it stable enough for releasing the game ?
« Last Edit: August 22, 2012, 12:11:59 am by CptZouglou »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Loading lots of images
« Reply #3 on: August 22, 2012, 12:21:17 am »
I'm doing a game in which there are many different animations. They are chosen at random anytime, so I should have all the images already loaded when I play one. All the images are photos of real objects, and the game is fully in stop motion :D That's why I don't want to reduce too much the size of the images, because they are quite beautiful!
Well if the image size is bigger as the biggest resolution you target for, then it's just waste of memory...
If you're working with fixed animations you could compile them into a video and take a look at the existing projects for playing video files (sfeMovies, FFMpeg wrapper, ...)

Anyways, do you recommand switching to 2.0 ? Is it stable enough for releasing the game ?
Yes definitely! There are already RC binaries, so you don't have to compile SFML newly and you it also means that SFML 2 will get released soon.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CptZouglou

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Loading lots of images
« Reply #4 on: August 22, 2012, 12:38:43 am »
Well if the image size is bigger as the biggest resolution you target for, then it's just waste of memory...
If you're working with fixed animations you could compile them into a video and take a look at the existing projects for playing video files (sfeMovies, FFMpeg wrapper, ...)

The image have the perfect size for the target resolutions. However as I said, there's a lot of transparent pixels, so I will try and reduce the image size by just cropping the images.
About the video, this is a very interesting idea, I never thought about it  ::) I have seen that some video codecs support alpha channels, so I will dig into this, thanks !