SFML community forums
General => General discussions => Topic started by: slucis7593 on May 11, 2014, 10:40:48 am
-
Hello :) !
I built a game from book sfml game development and this is result:
(https://farm8.staticflickr.com/7392/14158209015_1f8dbb32f4_z.jpg)
Problem: FPS is so low, FPS < 10 when i shoot bullet.
So, is window 8.1 cause this or my computer's hardware is weak?
My computer:
- CPU: Core i3 - 2310M ~2.1GHz
- RAM: 4GB.
- VGA: Intel HD Graphics 3000
Sorry for my English is not good.
-
Long story short: You need to use a profiler. Anything else would be guessing, and humans are very bad at guessing the root causes of performance problems.
http://en.sfml-dev.org/forums/index.php?topic=15131.msg107126#msg107126 gives a list of profilers you might want to look into.
-
Make sure you run in Release mode and without debugger.
The collision detection algorithm we developed is not very efficient because we focused on simplicity; this is also mentioned in the book and several optimizations are proposed. This could have an impact on performance if a lot of objects are on the screen, but it seems strange to me that it's so massive. The computer on which I tested had quite similar specifications.
-
@Ixrec: 'profiler' word is seem new to me, so tks for your link :)
@Nexus:
- Oh, i didn't know that debug and release is diffirent :P
- I'll keep reading to 'optimizations' part.
- I think that performance is low because of i compiled in Visual Studio. Then, when i compiled in GCC 4.7.1 (CodeBlock), it's run better. Thanks for your reply :D
-
I think that performance is low because of i compiled in Visual Studio.
Hardly. As mentioned, you probably forgot to start without the debugger.
-
If there was no difference between Debug and Release why would they exist?
Unoptimized debug builds try to produce code that closely match what you wrote that is easy to debug - but it won't perform well.
Optimized release builds sacrifice debug ability for performance. They are hard to debug but run fast. The optimizer is crucial in making C++ code perform well.
-
I find it really strange that you get < 10 FPS on your computer. It only happens when you shoot bullets or you always get poor performance?
Besides what the guys already said about Debug mode, I would like to add two more possibilities:
- Something is very wrong with your code (like doing something unnecesary, like making a huge amount of collision checks per frame or something). You can either use a profiler or comment parts of the code out until you discover the source of the problem. Still, I find it very strange that you get such poor performance on a i3 processor, unless you are doing something really taxing like taking screenshots every frame without noticing.
- You don't have the drivers for your Intel graphics card installed. My computer also has an Intel and I remember that I got awful performance (like 5 FPS), which turned out it was because I installed the wrong drivers. Make sure you have something called Intel Graphics Controller on your system tray (the little icons next to the clock, bottom right corner). If you don't, install it.
-
You may want to reinstall your drivers before diving into finding code problems. It's what happened with me and it resulted into 3 pages of discussion.
-
Also the Intel 3000 HD Graphics is known to have a poor OpenGL Performance and SFML relies on OpenGL, therefore this also could be a problem.
I also build the game from the book, and on my gaming machine it runs with over 300fps, (Core 2 Duo E6850, 8 GB RAM, GeForce GTX 260, running on Ubuntu 14.04) even with the unoptimized collision detection algorithm.
Try (re)installing your graphics drivers.
After this use a profiler.
Good Luck ;)
-
:D Thank's everybody for helping!
I thought that the issue was solved. It's slow because i ran with debugger.
When i run in Release mode and without debugger, it's pretty good.
Thanks Nexus for your anwser.
I want to ask one more question:
When i run in Visual Studio, Although i copied Sansation.ttf file to Release/Media folder but it's still could not found, console print that: "Failed to load font "Media/Sansation.ttf" (failed to create the font face)".
How can i fix this? Thanks :)
-
I want to ask one more question:
When i run in Visual Studio, Although i copied Sansation.ttf file to Release/Media folder but it's still could not found, console print that: "Failed to load font "Media/Sansation.ttf" (failed to create the font face)".
How can i fix this? Thanks :)
If you run directly from VS, you need to put the Media folder where your "Projectname.vcxproj" file is (thats probably also where your source code is)
-
If you run directly from VS, you need to put the Media folder where your "Projectname.vcxproj" file is (thats probably also where your source code is)
@Geheim: Wow, it's work. Thank u very much! :D
-
A better solution to this, is to set the working directory correctly in the VS project properties to the output directory of the .exe file. Then starting debugging in VS works ;)
-
Yes it looks fine to me.