SFML community forums

Help => Graphics => Topic started by: OniLinkPlus on October 09, 2011, 07:01:28 am

Title: RenderTexture Speed
Post 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?
Title: RenderTexture Speed
Post by: Disch on October 09, 2011, 08:44:54 am
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.
Title: RenderTexture Speed
Post by: Laurent on October 09, 2011, 09:04:47 am
Creating an OpenGL resource is always slow, and you should never do it every frame.

Why can't you reuse the same instance instead?
Title: RenderTexture Speed
Post by: Disch on October 09, 2011, 04:49:34 pm
Ah I misunderstood his question.  I thought he meant drawing to a RenderTexture, not creating it.
Title: RenderTexture Speed
Post by: OniLinkPlus on October 09, 2011, 07:51:11 pm
Quote from: "Laurent"
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.
Title: RenderTexture Speed
Post by: Groogy on October 09, 2011, 08:53:04 pm
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.
Title: RenderTexture Speed
Post by: Laurent on October 09, 2011, 10:52:03 pm
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 ;)
Title: RenderTexture Speed
Post by: OniLinkPlus on October 10, 2011, 12:55:59 am
Quote from: "Laurent"
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!