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

Author Topic: Help - lag  (Read 6529 times)

0 Members and 1 Guest are viewing this topic.

Xp

  • Newbie
  • *
  • Posts: 13
    • View Profile
Help - lag
« 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

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Help - lag
« Reply #1 on: February 09, 2011, 05:16:32 pm »
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.

Xp

  • Newbie
  • *
  • Posts: 13
    • View Profile
Help - lag
« Reply #2 on: February 09, 2011, 05:29:21 pm »
release and debug gives the same problem

is it becuase SFML is v 1.6?

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Help - lag
« Reply #3 on: February 09, 2011, 06:14:49 pm »
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.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

Xp

  • Newbie
  • *
  • Posts: 13
    • View Profile
Help - lag
« Reply #4 on: February 09, 2011, 06:25:15 pm »
geforce 6200

well, the exe I build has slow down and the exe I got from the source is normal =/

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Help - lag
« Reply #5 on: February 09, 2011, 06:47:37 pm »
Are you on Windows actually? :? Just make sure your drivers are up to date then, but it shouldn't be a problem.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

Xp

  • Newbie
  • *
  • Posts: 13
    • View Profile
Help - lag
« Reply #6 on: February 09, 2011, 07:18:14 pm »
yes, win xp

the weird thing is that devC++ with SDL is also normal (no fps drop)

Xp

  • Newbie
  • *
  • Posts: 13
    • View Profile
Help - lag
« Reply #7 on: February 09, 2011, 08:08:38 pm »
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 =/

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Help - lag
« Reply #8 on: February 10, 2011, 08:47:16 am »
Define lag. What kind of FPS drop?

Some numbers would be helpful.

Xp

  • Newbie
  • *
  • Posts: 13
    • View Profile
Help - lag
« Reply #9 on: February 10, 2011, 04:30:07 pm »
sorry for you time guys, going to try allegro for 2d graphics and use SFML for easy sound/sockets/threads functions

Xp

  • Newbie
  • *
  • Posts: 13
    • View Profile
Help - lag
« Reply #10 on: February 12, 2011, 04:45:29 pm »
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?

Code: [Select]
#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