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

Author Topic: Deleting a dynamically allocated (large) array of sprites at shutdown?  (Read 15022 times)

0 Members and 1 Guest are viewing this topic.

jd.russell

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Deleting a dynamically allocated (large) array of sprites at shutdown?
« Reply #30 on: April 24, 2015, 04:13:15 pm »
Ah I see, sorry don't know much about Vsync that's the reason I asked (always wondered what that option was in games). So, one is a hardware solution framerate limit and the other is a software framerate limit. I should probably (in the final version make vsync enable an option). However for now I'm going to use the "window.setFramerateLimit(60);" shown in the documentation example. I tried it in my initialization method and the coil whine is gone completely so It was a framerate problem. I suspect this is not OS specific so probably would have occured in Windows as well.

I will do some more research on Vsync before implementing it.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Deleting a dynamically allocated (large) array of sprites at shutdown?
« Reply #31 on: April 24, 2015, 05:35:28 pm »
I tried it in my initialization method and the coil whine is gone completely so It was a framerate problem. I suspect this is not OS specific so probably would have occured in Windows as well.

What doesn't make sense when we tell you it is because you maxing out the GPU? This isn't related to framerates or what OS you are running. When you tell the GPU to work as much as possible that will cause stuff to max out and cause the whine. This would happen if you ran any game at max settings that loaded down your GPU.
« Last Edit: April 24, 2015, 05:40:59 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

jd.russell

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Deleting a dynamically allocated (large) array of sprites at shutdown?
« Reply #32 on: April 24, 2015, 08:09:36 pm »
@ zsbzsb : I'm not sure I understand what you mean... the GPU appears to have been maxing out because of the unlimited framerate. I mean otherwise why would limiting the framerate get rid of the problem? And no I have a GPU that can run most modern games at max settings without maxing out. So I don't know what you mean by that either.

jd.russell

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Deleting a dynamically allocated (large) array of sprites at shutdown?
« Reply #33 on: April 24, 2015, 08:13:35 pm »
Ok, I have another issue I'd like to ask about. How am I going to go about handling clipping for the sprites (movable characters)? My only thought on this is to also put the sprites into the vertex array and draw those to the screen at the same time so that hopefully the objects draw in the correct order and produce the clipping result that I want? Is there a better way to do this in sfml that doesn't involve meshing together all sprites in a single object? I already know based on what I've read here on the forums that sfml does not have z-depth for a variety of reasons so I need some other way to go about handling this.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Deleting a dynamically allocated (large) array of sprites at shutdown?
« Reply #34 on: April 24, 2015, 08:20:41 pm »
What do you exactly mean by "clipping"? It seems like you're using the term a bit differently.

Concerning Z order, the only thing you can do is sort the sprites or vertices, so that they are drawn in correct order. If your sprites have stable addresses, you can use a data structure that stores pointers to them.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

jd.russell

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Deleting a dynamically allocated (large) array of sprites at shutdown?
« Reply #35 on: April 24, 2015, 08:40:37 pm »
Yeah sorry, I don't know the exact term for what I'm looking for perhaps it would be better called "layering". Anyways as far as I can tell sfml doesnt have built in layering functionality (i.e. moving sprites behind other sprites). So it seems what you said (which is similar to what I thought) is that it would be best if I simply drew all the quads together in a single vertex array so I can get the order correct. I just needed confirmation of that thanks. So that is a bit of a problem because the type of game I'm building is going to be a "kingdom builder" type game where you can mine blocks and create structures from resources. So some of the indexed sprites might be removed or new ones added at any given moment right?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Deleting a dynamically allocated (large) array of sprites at shutdown?
« Reply #36 on: April 25, 2015, 12:34:35 am »
There are always multiple options.

The simplest regarding drawing logic would be to have one vertex array where the vertices have been ordered correctly.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything