SFML community forums
Help => General => Topic started by: Xp on February 09, 2011, 04:16:57 pm
-
Hello, I'm new here and I need to know whats wrong with code blocks.
I first made a simple 2D game that had a background and 1 image that will move if i press some of the arrows key. the problem is that it gets slow if there is a background. if i take it off, the moving image works well.
with this problem I downloaded this really nice snake game with source http://www.sfml-dev.org/forum/viewtopic.php?t=1047 to see whats wrong. I first ran the .exe and it runs well (no fps drop) then I created an empty project and build the snake source. When I launch it the same fps drop happend. I compare the .exe from the source and the .exe from code block, the source had 1,53 mb and from code block was 1,72 mb.
Can it be the compiler (GNU GCC Compiler)? or a different project settings?
Thanks
-
Did you compile in debug or in release mode? Debug is slower and has a bigger executable because it has all the debug informations in it.
-
release and debug gives the same problem
is it becuase SFML is v 1.6?
-
My bet is that your graphic driver has poor acceleration. Are you using ATI or Intel's free driver?
Sadly, software solutions like SDL seem much faster than OpenGL with these drivers.
Edit: it's still strange that such a simple program is slow. Maybe there's something wrong in it, but the snake program is probably slow just because of drivers.
-
geforce 6200
well, the exe I build has slow down and the exe I got from the source is normal =/
-
Are you on Windows actually? :? Just make sure your drivers are up to date then, but it shouldn't be a problem.
-
yes, win xp
the weird thing is that devC++ with SDL is also normal (no fps drop)
-
It slows when I add picture =/. the 3d square in open gl tutorial site (without picture) runs perfectly. when I use the SFML-1.6 sample folder of opengl that has picture in it, it lags =/
-
Define lag. What kind of FPS drop?
Some numbers would be helpful.
-
sorry for you time guys, going to try allegro for 2d graphics and use SFML for easy sound/sockets/threads functions
-
hahahah dam it. found out the solution.
my card was set to 16 bits and the .exe I build was set to 32 bits and that made the fps drop...
if thats the case, why the .exe that came with the source didnt had slow down with 16 or 32 bits?
and also, is this the correct way to move a sprite?
#include <SFML/Graphics.hpp>
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
App.SetFramerateLimit(60);
sf::Image Image;
Image.LoadFromFile("Xis.png");
sf::Sprite Sprite(Image);
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Move the sprite
if (App.GetInput().IsKeyDown(sf::Key::Left)) Sprite.Move(-4, 0);
if (App.GetInput().IsKeyDown(sf::Key::Right)) Sprite.Move( 4, 0);
if (App.GetInput().IsKeyDown(sf::Key::Up)) Sprite.Move(0, -4);
if (App.GetInput().IsKeyDown(sf::Key::Down)) Sprite.Move(0, 4);
// Clear screen
App.Clear();
// Display sprite in our window
App.Draw(Sprite);
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
becuase in Allegro it seems that moving a sprite is better