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

Author Topic: Speed up SFML runing  (Read 1163 times)

0 Members and 1 Guest are viewing this topic.

alex_aramian

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Speed up SFML runing
« 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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Speed up SFML runing
« Reply #1 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.
Laurent Gomila - SFML developer