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

Author Topic: What happens with Sprites that are not in a Window?  (Read 2097 times)

0 Members and 1 Guest are viewing this topic.

Mazzelfassel

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
What happens with Sprites that are not in a Window?
« on: July 28, 2015, 01:16:46 am »
Currently I'm making a 2D simulation game, during the process I asked myself what happens with a sprite that is drawn but isnt visible in a window. Is SFML smart enough to just skip the drawing process or does it take the same Time then drawing in a window? So if I draw like 2000 sprites in my game but only 50 are currently visible in the window, would it be more effective to check if they are visible or just draw them?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: What happens with Sprites that are not in a Window?
« Reply #1 on: July 28, 2015, 02:04:31 am »
It is more efficient to check if a sprite is inside the visible area and draw it (or not) accordingly than to draw everything.
« Last Edit: July 28, 2015, 02:12:44 am by G. »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: What happens with Sprites that are not in a Window?
« Reply #2 on: July 28, 2015, 07:21:02 am »
Please use the Help -> Graphics subforum, this is not a general discussion about the library :)

(Also, this specific question has been answered a lot in the past...)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: What happens with Sprites that are not in a Window?
« Reply #3 on: July 28, 2015, 10:04:53 am »
SFML will still try to draw the sprite, since the C++ code doesn't know about what happens during drawing. For example, a vertex shader could move the sprite back into view.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: What happens with Sprites that are not in a Window?
« Reply #4 on: July 28, 2015, 12:25:14 pm »
No i think that it won't draw because as i remember the OpenGL uses Culling planes so it will cut the full sprite from FrameBuffer maybe...
« Last Edit: July 28, 2015, 12:27:01 pm by Mr_Blame »

Mazzelfassel

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: What happens with Sprites that are not in a Window?
« Reply #5 on: July 28, 2015, 05:14:12 pm »
It is more efficient to check if a sprite is inside the visible area and draw it (or not) accordingly than to draw everything.

Thx for the quick answer I'll keep this in mind when I completed the drawing function.

 

anything