SFML community forums

Help => Graphics => Topic started by: oomek on November 13, 2018, 02:21:49 pm

Title: Rendering n frames ahead
Post by: oomek on November 13, 2018, 02:21:49 pm
Is it possible in SFML to create an array of  n rendertextures and draw to them sequentially untill all are filled in one thread and in another thread draw those framebuffers sequentially to the window without blocking the first thread? The reason for that is that the rendering thread sometimes pauses for 50-100ms when reloading textures from disk. I do not care much about the latency as it's not a game. An example using pseudo code would be handy.
Title: Re: Rendering n frames ahead
Post by: NGM88 on November 21, 2018, 04:32:23 pm
If this were StackOverflow someone would have probably asked "show us what you have so far". It helps if you post what you have tried.
Title: Re: Rendering n frames ahead
Post by: ZeroZ30o on November 24, 2018, 07:50:13 pm
Yes, it's possible.

See https://www.sfml-dev.org/tutorials/2.5/window-opengl.php#rendering-from-threads

And with mutexes on top.
I think this is a pretty silly solution though -one separate thread should load the data for sure, but:

If the problem is the loading, why buffer the textures as well? I'm assuming it takes almost no time for you to draw those files into the window (once they are loaded).

And now I speculate (might be 100% wrong):
Additionally, I suspect you may run into video ram issues with several render textures, where those too would be stored in memory if you run out of memory in your gpu (thus taking time to load back as well).