SFML community forums

Help => Graphics => Topic started by: alex_aramian on October 27, 2019, 11:18:21 am

Title: Speed up SFML runing
Post by: alex_aramian on October 27, 2019, 11:18:21 am
I really like SFML, I use it very frequent. But today I wrote a code that generates a color gradient. Before that I had no idea how can I make so except drawing pixel by pixel on an sf::Image. Once I've finished I ran the code. It did run but first I saw a black window (not console) and after the gradient came up. I understood why do I see such an effect, the code running speed is kinda slow. But I think there's no way faster to do this task, so I think SFML should be speeded up (not only for this project). Please correct me if I'm wrong!
Title: Re: Speed up SFML runing
Post by: Laurent on October 27, 2019, 02:57:44 pm
Color gradient (interpolation) is one of the most basic task that OpenGL can do, and fortunately SFML provides a simple way to access this feature. Build a vertex array, assign a color to each vertex and that's it, you get a nice color gradient for free.

See https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#a-simple-vertex-array for an example.