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

Author Topic: Multiple layers + multiple atlases  (Read 1449 times)

0 Members and 1 Guest are viewing this topic.

red1939

  • Newbie
  • *
  • Posts: 5
    • View Profile
Multiple layers + multiple atlases
« on: February 06, 2013, 10:07:20 pm »
Assumptions & requirements:
  • max texture size that can be expected (on most machines) is at least 1k * 1k (while my very old ATI Mobility Radeon HD 3400 can handle 8k * 8k...)
  • every sprite will be of 64 * 64 size
  • there will be more than 256 sprites
  • more than one texture might be required while rendering
  • sprites will be grouped logically (one texture for units, other for tiles, etc.)
  • large number of sprites will be rendered on the screen every frame
  • in order to run efficiently least number of context switches is required, thus least number of texture changes
  • isometric projection (or at least impression of it) will be used
  • iso. proj. (IP) requires to draw sprites in very ordered fashion (column-major-like order)

So the question is as follows:
How to efficiently render sprites which are on different textures?

The solution I would choose is:
  • Draw static backgrounds to off-screen texture (RenderTexture) and forget about them
  • Assign a Z-order to every sprite basing in what order the drawing has to be done
  • Group all vertices of all rendered sprites by their textures and push them to VBO (VertexArray?)
  • Issue draw calls for every VBO + Texture pair
  • Let the logical draw ordering be handled by Z buffer

It seems efficient and clean for me, but AFAIK there is no support for Z-order in sfml. Is there any other efficient way of rendering sprites in this scenario, or I am left with just iteratively drawing sprites basing on their draw order?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Multiple layers + multiple atlases
« Reply #1 on: February 07, 2013, 12:01:34 pm »
There's not z buffer yes, thus you'll simply have to decide on your own, which objects goes over the other and make sure you draw them in the correct order.
The most efficient way to draw in SFML, is by using a vertex arrays. You'll need to using one for each texture and maybe break them further down, as you want to clip the content, that is off screen.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/