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

Author Topic: sf::texture questions  (Read 1473 times)

0 Members and 1 Guest are viewing this topic.

Naz

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf::texture questions
« on: November 19, 2014, 03:25:26 pm »
hi,

I am not sure about how a sf::Texture is saved. I read about the max size of a sf::texture, I could image this. but would it possible to have like 10000 sf::textures (just example) or would it better to safe them to a sf::image and then load them to a texture when you need them to draw.

Also for non static sf::textures, would it be usefull to load parts of images to a sf::texture you acutally use so the size becomes 1024x1024 ?

« Last Edit: November 19, 2014, 03:28:31 pm by Naz »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::texture questions
« Reply #1 on: November 19, 2014, 04:04:35 pm »
A texture "lives" on the GPU memory, thus its size is limited by your availalbe size, you can query the maximum size with the specific member function.

Since switching between textures has a small overhead, it's best to keep as much as possible on one texture, but keep in mind, that while your GPU might be able to handle big sizes, some older hardware might not.
If you have tons and tons of textures, it's better to load them when needed. Depending on how much RAM you want to use, you can pre-cache some of the images in memory with sf:Image instances, otherwise you can always read directly from the disc.

What do you mean with "non static sf::Textures"?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Naz

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: sf::texture questions
« Reply #2 on: November 19, 2014, 04:26:28 pm »
A texture "lives" on the GPU memory, thus its size is limited by your availalbe size, you can query the maximum size with the specific member function.

Since switching between textures has a small overhead, it's best to keep as much as possible on one texture, but keep in mind, that while your GPU might be able to handle big sizes, some older hardware might not.
If you have tons and tons of textures, it's better to load them when needed. Depending on how much RAM you want to use, you can pre-cache some of the images in memory with sf:Image instances, otherwise you can always read directly from the disc.

What do you mean with "non static sf::Textures"?

So if the maximum texture size is 1024x014, I can't have 2 sf::textures which bold hold a images from 1024x1024? What will happen when this occur?

My current game has this, a map with a character in it and monster are walking on the platforms. There could be a second player which has different armor than you. So the map tiles and the character items from yourself are static, but what the other guy has might be completly new.

So it could be that I eventually get more and more textures, would it be worth adding the multiple pictures to a texture, so make new images on runtime or would it be better to have more texture?