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

Author Topic: SpriteBatch  (Read 6331 times)

0 Members and 1 Guest are viewing this topic.

floAr

  • Newbie
  • *
  • Posts: 9
    • View Profile
SpriteBatch
« on: July 26, 2012, 02:58:04 pm »
Hey folks!
I would like to give you a sneak peak at my new blog at https://BeyondTheBlur.wordpress.com.
I will post some tutorials on SFML.Net there and there is also a SFML (C++ this time) world generator in the making. We are producing articles right now and scheduling them for the beginning of August. I will build a framework on top of SFML for rapid prototyping and building a bunch of useful snippets as we advance in the series.
At the moment I am working on batched drawing with a spritebatch and got some impressive results.
I am rendering 32x32 px objects, all with a single colored texture and monitoring the time from starting to draw until drawing is finished (no event polling ecetera pp). The time is milliseconds per frame. Here is what I got:
  • 100 objects: Normal: <0.1 ms/f | Spritebatch: <0.1 ms/f
  • 1000 objects: Normal: ~7 ms/f | Spritebatch: <0.1 ms/f
  • 10000 objects: Normal: ~90 ms/f | Spritebatch: ~9 ms/f
  • 100000 objects: Normal: >1100 ms/f | Spritebatch: ~100 ms/f

Basically I´m writing every texture I load into a texture atlas and use vertex quads to draw them. As my graphic objects just need to save a texture position they are really lightweight.
I think I will cover this at the end of August, as I need to add some features and polish the whole thing. Feedback and feature suggestions are highly welcome :)

Regards floAr

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 190
    • View Profile
Re: SpriteBatch
« Reply #1 on: July 26, 2012, 10:10:08 pm »
Hey folks!
I would like to give you a sneak peak at my new blog at https://BeyondTheBlur.wordpress.com.
I will post some tutorials on SFML.Net there and there is also a SFML (C++ this time) world generator in the making. We are producing articles right now and scheduling them for the beginning of August. I will build a framework on top of SFML for rapid prototyping and building a bunch of useful snippets as we advance in the series.
At the moment I am working on batched drawing with a spritebatch and got some impressive results.
I am rendering 32x32 px objects, all with a single colored texture and monitoring the time from starting to draw until drawing is finished (no event polling ecetera pp). The time is milliseconds per frame. Here is what I got:
  • 100 objects: Normal: <0.1 ms/f | Spritebatch: <0.1 ms/f
  • 1000 objects: Normal: ~7 ms/f | Spritebatch: <0.1 ms/f
  • 10000 objects: Normal: ~90 ms/f | Spritebatch: ~9 ms/f
  • 100000 objects: Normal: >1100 ms/f | Spritebatch: ~100 ms/f

Basically I´m writing every texture I load into a texture atlas and use vertex quads to draw them. As my graphic objects just need to save a texture position they are really lightweight.
I think I will cover this at the end of August, as I need to add some features and polish the whole thing. Feedback and feature suggestions are highly welcome :)

Regards floAr

Hey floAr, your SpriteBatch seems amazing! I've been building a fast-prototyping library for SFML.Net for quite a while, and I would like to open-source it. I would love to give you an hand.

The library features:
* Fixed or dynamic frametime
* Easy asset loading and usage
* Tilesets
* Animations
* Basic game / game window objects
* Component-based entity system for real-time games (separate assembly)
* Component-based entity system for tile-based games (separate assembly)
* Utils class with loads of vector and angle operations

I'm not the best programmer, but I have some experience and since I've already worked on my library for quite a while I would like to collaborate on a similar project. Let me know if you're interested :)

floAr

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: SpriteBatch
« Reply #2 on: July 27, 2012, 09:15:27 am »
Hey SuperV1234!
I would gladly like to share my approach, at the moment I have a simple state system, content management, physics and the batched drawing in place. My goal is not to provide an engine or framework as is, but to build some prototypes and extract components, which are helping me :)
On the long term there might be something like a framework or an engine but it is definitely not my short term goal. But feel free to extract whatever you need and add it to your framework ;)
The source code will be mirrored in a git repo on github (the link is on the blog too). At the moment it is not up to date, but I will commit today and you can skim the source if you want. Please note that the code is still work in progress and will most likely change until I publish the corresponding article ;)

Regards
floAr

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 190
    • View Profile
Re: SpriteBatch
« Reply #3 on: July 27, 2012, 02:17:30 pm »
Hey SuperV1234!
I would gladly like to share my approach, at the moment I have a simple state system, content management, physics and the batched drawing in place. My goal is not to provide an engine or framework as is, but to build some prototypes and extract components, which are helping me :)
On the long term there might be something like a framework or an engine but it is definitely not my short term goal. But feel free to extract whatever you need and add it to your framework ;)
The source code will be mirrored in a git repo on github (the link is on the blog too). At the moment it is not up to date, but I will commit today and you can skim the source if you want. Please note that the code is still work in progress and will most likely change until I publish the corresponding article ;)

Regards
floAr

Sounds great! All of my code is on GitHub if you want to take a look. I will be sure to include SpriteBatches in my next version :)

https://github.com/SuperV1234/SFMLStart

NightCabbage

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Email
Re: SpriteBatch
« Reply #4 on: December 04, 2012, 05:30:16 am »
Hey floAr

I'm quite interested in your SpriteBatch!

How are you going with it?

Any word on when it will be available? :)

(I'm rendering large numbers of sprites, so it would be handy for me!)

Also I could lend a hand. Either way, I'm sure it'd save me a lot of time - I wouldn't have to make one myself from scratch!
(I'm used to a SpriteBatch, as I'm from XNA land)

krzat

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: SpriteBatch
« Reply #5 on: December 08, 2012, 06:03:41 pm »
I just wrote a simple one. I got 100% performance increase (no idea how OP got 1000%):

Class code: http://pastebin.com/7GBBfjFp
Test project (press any key to toggle between modes): https://docs.google.com/open?id=0B74Xwz4um7akSDgzQXgyNkxYLXc

EDIT: It's better on my laptop. It's 600% faster there.
« Last Edit: December 09, 2012, 12:34:34 am by krzat »
SFML.Utils - useful extensions for SFML.Net

 

anything