1

I've searched but couldn't find a result for this that didn't involve XNA.

Basically, I'm making a map editor using a C# binding of SFML attached to a panel's handle in my form. It runs at 550 FPS, which results in my main loop being called way too much, using too much resources (10% CPU for a small map editor).

I only really need 60 fps for this, and I know that will result in the cpu usage going down a lot.

Does anyone know how to do this? I've heard that it's impossible because WinForms s no function to access the graphic drivers VSync setting; but there must be a way, right?

Thanks.

Anteara
  • 729
  • 3
  • 14
  • 33
  • I assume your percentage is a typo? 10% is nothing for constantly drawing a map.. – Simon Whitehead Jul 17 '13 at 05:23
  • The thing is though, I don't need 500 FPS, and it's putting unnecessary stress where it's not needed. It's only a 2D Tile Engine / Editor, so it shouldn't really need any more than 60 fps, or even 30 fps. I think 10% CPU is a lot for rendering a map 550 times per second; I don't need it rendered that much. – Anteara Jul 17 '13 at 05:30
  • What about sf::Window::setFramerateLimit? Did you try it? – Hiura Jul 17 '13 at 08:08
  • @Hiura Yep, I also tried SetVerticalSyncEnabled. I think they didn't work because I've put my SFML window inside a WinForms window, and hence I need to change the WinForms window FPS instead. – Anteara Jul 17 '13 at 10:21

1 Answers1

2

I ended up using a WinForms timer to do my game loop processing. I get an effective 60 FPS by setting the interval of the ticks.

This reduces the CPU usage to 0.1% while still having the same functionality.

Anteara
  • 729
  • 3
  • 14
  • 33