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

Author Topic: [Rendering] Create sprite each frame?  (Read 484 times)

0 Members and 1 Guest are viewing this topic.

toocrazy

  • Newbie
  • *
  • Posts: 1
    • View Profile
[Rendering] Create sprite each frame?
« on: December 16, 2023, 10:56:57 pm »
Hello,

im aware that loading a texture is a really resource-expensive operation, but creating a sprite for each Frame seems to not affect my framerate as of right now.
The question is: Is it good practice in SFML to create the sprites each frame, or should you create them once and just draw them each frame?

Thanks in advance :)
« Last Edit: December 17, 2023, 12:19:27 am by toocrazy »

Garwin

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: [Rendering] Create sprite each frame?
« Reply #1 on: December 17, 2023, 08:38:52 am »
It is better to store sprites in some container, vector is an obvious option.
Then you can change sprite properties if needed. If you need a link to the exact sprite, you can store ID of sprite as it is not invalidated if the reallocation of the vector occurs.

If your number of sprites is not big, you will not mention the difference.