SFML community forums
Help => Graphics => Topic started by: OniLinkPlus on October 09, 2011, 07:01:28 am
-
Quick question: how slow is the creation of a RenderTexture? How bad would it be to create one per frame?
-
It all resides in video memory so I wouldn't imagine it'd be much slower than normal rendering.
Only way to know for sure, though, would be to try it out.
-
Creating an OpenGL resource is always slow, and you should never do it every frame.
Why can't you reuse the same instance instead?
-
Ah I misunderstood his question. I thought he meant drawing to a RenderTexture, not creating it.
-
Creating an OpenGL resource is always slow, and you should never do it every frame.
Why can't you reuse the same instance instead?
Yes, that's what I thought. Huh, I'm going to have to rethink this... I'm probably just overcomplicating it.
-
Like Laurent said reuse the resources instead. You can apply that everywhere you just have to be smart about it. A central manager replacing new calls is a general way to apply it but most cases don't need that.
-
And having a rendering area with a different size every frame (I'm just guessing) doesn't mean that your render texture has to have the exact same size. It can stay larger -- just use the sprite's subrect to cut it where appropriate ;)
-
And having a rendering area with a different size every frame (I'm just guessing) doesn't mean that your render texture has to have the exact same size. It can stay larger -- just use the sprite's subrect to cut it where appropriate ;)
True... I could add that to my optimization I put in earlier (only recreate if size changes), and make it so that it only resizes if it gets larger, then use subrects... that might work! Thanks!