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

Author Topic: Sprite batching  (Read 4694 times)

0 Members and 1 Guest are viewing this topic.

SwinkiTrzy

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Sprite batching
« 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.

Turbine

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: Sprite batching
« Reply #1 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.

SwinkiTrzy

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Sprite batching
« Reply #2 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?
« Last Edit: March 01, 2017, 10:46:11 pm by SwinkiTrzy »

Turbine

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: Sprite batching
« Reply #3 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.

JayhawkZombie

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Sprite batching
« Reply #4 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.

SwinkiTrzy

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Sprite batching
« Reply #5 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.

scellow

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Sprite batching
« Reply #6 on: March 03, 2017, 01:30:55 am »
+1 would love to see official spritebatch class like in libGDX or monogame

 

anything