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

Author Topic: My program freezing when framerate is to low.  (Read 1278 times)

0 Members and 1 Guest are viewing this topic.

wojtek

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
My program freezing when framerate is to low.
« on: March 11, 2023, 10:24:49 pm »
Hi, i wrote simple program in sfml to show how sorting algorithms works on rectangle objects. Now program is working too fast to see each move and the main reason for build this program is still missing. How can i slow displaying changes on the screen without freeze? I am working with bubble sort. Here is link to my github.

GraficznePrzedstawienieAlgorytm-wSortuj-cych -> bubbleSort.cpp

https://github.com/WojtekTomekCzubak/GraficznePrzedstawienieAlgorytm-wSortuj-cych

I also post this problem on StackOverflow: https://stackoverflow.com/questions/75705499/how-can-i-slow-displaying-changes-in-sfml-program
« Last Edit: March 11, 2023, 10:26:32 pm by wojtek »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: My program freezing when framerate is to low.
« Reply #1 on: March 14, 2023, 10:52:25 pm »
Briefly looking at your code it seems like you aren't doing any stepping in the normal game loop.

In order for the visualization to work, you don't just need to render it, but you need to execute the sorting step by step, every few hundred milliseconds or every few frames.
What I would expect is to see a call to the selected sorting algorithm in the update() function. And probably some sf::Clock instance that tracks the passed time, so the algorithm is only advanced every so often.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything