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

Author Topic: Rendering to outside of a window possible?  (Read 1431 times)

0 Members and 1 Guest are viewing this topic.

rjack

  • Newbie
  • *
  • Posts: 3
    • View Profile
Rendering to outside of a window possible?
« on: April 15, 2025, 05:36:46 pm »
hello,
I am a beginner so appologies for, maybe trival, question.

Does SFML, by default, render an object to a window whereby an object is positioned outside of the window's frame?

I mean, lets have a tiny sprite at position Vector2f(-1000.f,-1000.f) and my window is atVec2(0,0).
If I say, (sf::RenderWindow) window.draw (sprite) in my game loop, is it going to be still "rendered"? Obviously I am not gonna see it anyway but would the CPU/GraphicsCard procesing power still be used for this task?

If positive, than I guess I ll have to make sure first, whether the sprite intersects with the window rect, and only if positive, let it draw, right?

Hapax

  • Hero Member
  • *****
  • Posts: 3422
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Rendering to outside of a window possible?
« Reply #1 on: April 16, 2025, 10:49:21 am »
If you have a lot of things drawn - or are otherwise having performance issues - you may need to consider optimising what is drawn by "culling" things that are not in the range of the window as this is not done automatically. You can do this simply by using the method you described. More complicated methods exist including using "chunks" that can in turn reduce the number of intersecting tests but, again, this is much more complicated.

As an answer to the question, yes, things outside of the window will still be processed by the rendering process. Note, though, that this is basically all of the shaders up to the fragment shader; this shader only applies to actual pixels that are visible. So, the fragment shader will not be run on the things outside of the window but the vertex shader - for example - will still be run on every vertex (that you draw).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

rjack

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Rendering to outside of a window possible?
« Reply #2 on: May 10, 2025, 08:40:13 am »
thank you for the clear answer!