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

Author Topic: Drawing thousands of sprites  (Read 20094 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Drawing thousands of sprites
« Reply #15 on: March 06, 2011, 07:04:39 pm »
You should test in C or C++ the same program that you wrote in Ruby, just to make sure that the problem is not your hardware/drivers configuration.
Honestly, I don't think that loops in Ruby (or anything else of the language) can be the bottleneck in a graphical application.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Drawing thousands of sprites
« Reply #16 on: March 06, 2011, 08:03:07 pm »
Pheeeew that scared the crap out of me.

I got the same frame rate in C++ with equivalent code.
Though it's kind of weird that I only have ~40 FPS with 1 000 sprites. Must have an old driver or something.

You guys who get a decent frame rate for 10 000+ sprites, do you do anything special to get that or you just loop trough them and render?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Drawing thousands of sprites
« Reply #17 on: March 06, 2011, 08:48:49 pm »
There's nothing special to do in SFML, really. Looping and rendering each sprite one by one is the only way to go.

Do you have bad performances on other (non-SFML) graphics applications?
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Drawing thousands of sprites
« Reply #18 on: March 06, 2011, 09:16:41 pm »
Quote from: "Laurent"
There's nothing special to do in SFML, really. Looping and rendering each sprite one by one is the only way to go.

Do you have bad performances on other (non-SFML) graphics applications?


Nope, I play most games on a +40 frame rate I think. I'll have a look after I've updated my drivers.

Update: I've updated my drivers and still low frame-rate on 1000 sprites. To have something to reference with I'll check how it looks in Oblivion. Though if it lags there I'll create a new topic since it feels this has strayed away from the original.

Might be my computer. Oblivion worked fine but the FPS wasn't what I hoped for. I'll test at the university too the same code, same game and see what I get. It's a similar card just not the mobile version.

GPU: GeForce 9700M GT 32 @ 625MHz
CPU: Intel Core 2 Duo CPU @ ~2.2Ghz

Could just be me having a crappy card.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Drawing thousands of sprites
« Reply #19 on: March 07, 2011, 12:19:31 am »
You could analyze the application with a profiler and see what consumes most of the time.

Are the applications that run well based on DirectX? Do you have OpenGL code which behaves fast?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Drawing thousands of sprites
« Reply #20 on: March 07, 2011, 01:15:51 am »
Well my profiler don't seem to function that well.. It tells me I'm spending 100% of my time in std::vector operator[].

Anyway I couldn't see Oblivions frame-rate directly. Though it felt okay at normal detail. If I guessed I would say it is the same. League Of Legends sit around 30-40 FPS actually now when I looked while I was playing. I think both of them are DirectX apps.

Though I think it's weird that my card would be able to display a 3D world but have a hard time displaying 1000+ sprites.

Is there something on my end I might have missed that I could do to improve it?

Sorry Original Poster, this might not even have anything to do with your problem. But it might just be that you can't show more than 10k because of the card. If you move the application to another computer with a better card/drivers then you should see improvement if this is in fact the problem.(I'll do it myself when I get to the university.)
Aight sorry again for hijacking.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Drawing thousands of sprites
« Reply #21 on: March 07, 2011, 01:48:45 am »
Are you sure that you compile in release mode with enabled optimizations and any security features (such as checked iterators/indices) as well as the debug runtime environment are disabled?

What if you use a raw array instead of std::vector?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Relic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Drawing thousands of sprites
« Reply #22 on: March 07, 2011, 06:13:35 am »
@ SuperV1234:
Quote
How do I look at the MSIL code? And what should I look for?

To get MSIL code out of a built managed assembly you may use MS utility IL DASM (IL disassembler).
An example of what ILDASM gives:
Code: [Select]

.....
IL_000c: ldloc.0
IL_000d: box [mscorlib]System.Int32
IL_0012: ldstr ", "
IL_0017: ldloc.1
IL_0018: unbox.any [mscorlib]System.In32
.....

You can see box and unbox operations. They are performed when value types are converted to reference types (to place objects in the managed heap) and vice versa. Depending on your code there may be lots of these operations. They may be rather time-consuming and make your loops heavy. I'm afraid I can't give you detailed explanation as English is not my native language. You may use googling to find relevant info on this topic.  :wink:

Gibgezr

  • Newbie
  • *
  • Posts: 33
    • View Profile
Drawing thousands of sprites
« Reply #23 on: March 07, 2011, 07:58:42 pm »
See this thread:
http://www.sfml-dev.org/forum/viewtopic.php?t=3173

My answer at the bottom is the way to draw thousands of tiles at high frame rates.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Drawing thousands of sprites
« Reply #24 on: March 07, 2011, 08:05:24 pm »
Hopefully this won't be necessary anymore in SFML 2.
Laurent Gomila - SFML developer

.teri

  • Newbie
  • *
  • Posts: 28
    • View Profile
Draw the necessary tiles
« Reply #25 on: June 02, 2011, 08:39:09 pm »
Just render the tiles that you are watching on screen. No try render the whole map.
With this the performance will increase.