SFML community forums

General => Feature requests => Topic started by: SwinkiTrzy on March 01, 2017, 12:28:46 am

Title: Sprite batching
Post by: SwinkiTrzy on March 01, 2017, 12:28:46 am
As a most of SFML applications are 2d games and efficiency could be (and is) a bottleneck, could you implement batch sprite (or texture) rendering functionality like OpenGL with VBOs/VAOs.
Title: Re: Sprite batching
Post by: Turbine on March 01, 2017, 01:29:48 am
SFML supports VertexArrays, but you need to understand the bottleneck comes from context switching, the limitation of VertexArrays are that you can only use one texture - but you may draw any portion of it. This is very efficient.
Title: Re: Sprite batching
Post by: SwinkiTrzy on March 01, 2017, 10:24:30 pm
So, as I can understand, using sprite sheet as a single texture, the sprite batching could improve efficiency? Please describe where I get wrong.
Developers, what do you think, regarding portability?
Title: Re: Sprite batching
Post by: Turbine on March 02, 2017, 02:53:54 am
Exactly, portability wise - every GPU may have a different max texture size. Some of the older Intel machines could only handle 512px, some relatively modern could go as high as 4096px, perhaps even beyond.
Title: Re: Sprite batching
Post by: JayhawkZombie on March 02, 2017, 04:53:30 am
You can query the max texture size yourself if you want to check:

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGet.xhtml

eg
GLint mxSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mxSize);

Current OpenGL specification indicates this must be at least 1024, but older versions will specify a different size.  For example, a 2.1 compatibility context specifies this must be at least 64 (yeesh).
If you have even a halfway decent GPU, you should be able to load large textures.
My NVidia 980M, for example, gives 16384.
Title: Re: Sprite batching
Post by: SwinkiTrzy on March 02, 2017, 09:16:29 pm
Exactly, portability wise - every GPU may have a different max texture size. Some of the older Intel machines could only handle 512px, some relatively modern could go as high as 4096px, perhaps even beyond.
OK, some GPUs would be too limited to handle my game spritesheet. But this is the same with memory, CPU and other scarce resources. I still don't understand why sprite batching functionality embedded in the next version of SFML could be a problem? I know, I can implement it by myself as everything (moreover, there is an example of such implementation in wiki), but if one asks about future improvements, so this is my proposal.
Title: Re: Sprite batching
Post by: scellow on March 03, 2017, 01:30:55 am
+1 would love to see official spritebatch class like in libGDX or monogame