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

Author Topic: Question: Current State of Graphics API  (Read 1962 times)

0 Members and 1 Guest are viewing this topic.

RolandJMoritz

  • Newbie
  • *
  • Posts: 2
    • View Profile
Question: Current State of Graphics API
« on: February 24, 2012, 03:19:32 am »
Hello! I have a question regarding the current state of the Graphics API, and I apologize in advance in case this has already been answered, but I did not find anything really recent enough about this in the forums...

There has been lots of discussion about batching and how the amount of OpenGL draw calls is the real bottleneck. From what I have gathered, Laurent currently does not support batching but has found ways to internally optimize that API to make it nearly as fast as when using batched rendering...? Right now I am starting with a game that will be *very* particle intensive and needs lots of sprites drawn at the same time, definitely > 1000, more in the range of 10.000.

As far as I know, there is a limit of about 1000 sprites/frame at which the framerate drops severely due to the amount of drawing calls. I am currently still using SFML 1.6, because I always thought I'd wait for a final, stable version of 2.0...

So basically I just wanted to ask what the current state of affairs regarding sprite drawing performance is in SFML 2 and how long it will approximately still take till the new API is finished? I really want to avoid having to use pure OpenGL for performance reasons... :P

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Question: Current State of Graphics API
« Reply #1 on: February 24, 2012, 08:11:52 am »
The new API is already finished. Sprite rendering is more efficient than in 1.6 if they all use the same texture, but to get maximum performances for a particle system, you'll need to go to a lower level and use vertex arrays (SFML's ones, not OpenGL). I think there are already one or two examples of particles with vertex array on this forum.
Laurent Gomila - SFML developer

tobybear

  • Newbie
  • *
  • Posts: 27
    • View Profile
Question: Current State of Graphics API
« Reply #2 on: February 24, 2012, 09:27:04 am »
Yes, as Laurent recommended, for a particle system, you are better off using a vertex array (if all particles use the same texture, or rather use a part of the same texture, as of course texture coordinates are still possible).

On a side note, I wrote a very simple sprite batcher, which is nothing but an extended vertex array drawable class that has the option of adding a sprite's vertices (using pre-transformation, so including the sprite's scale and rotation) to its internal buffer and only drawing it once after all sprites have been added. It works something like this:

Code: [Select]

sf::Sprite s;

// normal method, 1000 OpenGL draw calls
for (int i=0;i<1000;i++)
{
 s.SetPosition(i,i);
 window.draw(s);
}

// using sprite buffer, 1 OpenGL draw call
SpriteBuffer sb;
for (int i=0;i<1000;i++)
{
 s.SetPosition(i,i);
 sb.addSprite(s);
}
window.draw(sb);


This can also be extended to use any drawables, not only sprites, but
a little bit of code modification is necessary as most SFML classes don't allow accessing their vertices for reading (private member).
I also wrote a sprite batcher as a class derived from sf::RenderTarget, but did not really need that in my projects right now.

RolandJMoritz

  • Newbie
  • *
  • Posts: 2
    • View Profile
Question: Current State of Graphics API
« Reply #3 on: February 27, 2012, 01:45:00 am »
Thanks for the fast reply :)

 

anything