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

Author Topic: Scaling and performance, rectangles and performance  (Read 1262 times)

0 Members and 1 Guest are viewing this topic.

enterthekiwi

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Scaling and performance, rectangles and performance
« on: February 23, 2015, 05:04:45 pm »
Hi SFML community! I have few questions. Since they are somewhat elementary, I am extremely sorry if they have been covered but I just spent a good chunk of time on Google and here searching for answers and didn't find one. If this has been covered in many past topics, I would be grateful for perhaps the right keywords so I can conduct better searching and not bug you all.  ;D

I have a 16x16 source image that I want to appear as 32x32 in my game. Which will yield better performance: letting SFML scale a 16x16 image or scaling up the image beforehand to 32x32? A few words on "why" would be appreciated in the extreme.

I want to have "special effects" graphics in my game that basically use single-colored filled rectangles to make simple "explosions". For an example of what I'm going for, here are two frames from Yoshi's Island: 1 and 2. My question is, what yields better performance: using images as textures for this effect or doing it using SFML's fillrect functionality?

I know people here fiercely pounce on "unanswerable questions" but I am also wondering in general how many SFML rectangles and sprites (let's say 16x16, 8 colors) I can draw on screen per frame before slowdown, assuming I limit to 60 fps? I know it depends on the computer, so if you don't want to give me a common sense ballpark answer just tell me what specs I should know about before asking the question so I can try to research for myself. I don't need to know "1347 sprites" or "6548.3 rectangles", just ballparks so I can keep that in mind when designing my games. Eventually I will obviously run my own performance tests for my specific applications.

Last thing: I posted these as one topic but should I separate these into multiple threads? I included both in the topic name so that they can be found by search easily, I don't want to clutter the boards, but I am happy to edit and repost as multiple threads if that is better for everyone. I want to be a good poster here and not earn some of the rather sharp answers I see silly questions get. Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Scaling and performance, rectangles and performance
« Reply #1 on: February 23, 2015, 06:35:31 pm »
Quote
I have a 16x16 source image that I want to appear as 32x32 in my game. Which will yield better performance: letting SFML scale a 16x16 image or scaling up the image beforehand to 32x32? A few words on "why" would be appreciated in the extreme.
None. Why: the impact on performances is so tiny in both cases that nobody will ever notice a difference. Just take the simplest solution for you.

Quote
I want to have "special effects" graphics in my game that basically use single-colored filled rectangles to make simple "explosions". For an example of what I'm going for, here are two frames from Yoshi's Island: 1 and 2. My question is, what yields better performance: using images as textures for this effect or doing it using SFML's fillrect functionality?
Same answer. Unless you plan to draw thousands of these rectangles at the same time, you will hardly notice the difference.

Quote
Last thing: I posted these as one topic but should I separate these into multiple threads?
I think both questions are close enough to remain in the same thread.
Laurent Gomila - SFML developer

enterthekiwi

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Scaling and performance, rectangles and performance
« Reply #2 on: February 23, 2015, 07:10:07 pm »
Thanks for the answer Laurent! Keep up the great work on SFML. Needless to say the fact that your second answer also covers my third question is impressively efficient.  ;D

 

anything