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

Author Topic: SFML-2.1 VS2013 Release build slow/not working outside VS.  (Read 6759 times)

0 Members and 1 Guest are viewing this topic.

Pallevante

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
SFML-2.1 VS2013 Release build slow/not working outside VS.
« on: January 09, 2014, 10:11:25 pm »
I made a game with SFML and when I debug it, it works perfectly and when I launch the debug exe outside Visual Studio it also works.

When I build for release and test it it works but not outside Visual Studio. 1/6 times I can move around like I should but not shoot as I should.

Worth mentioning is that visual studio builds it and posts 6 errors  but I can run it anyway.

The errors I'm getting are these:

   1   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   89
   2   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   105
   3   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   128
   4   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   141
   5   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Graphics\RenderWindow.hpp   76
   6   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Graphics\RenderWindow.hpp   93

Would that explain it? I need some help with this because it's getting on my nerves and I can't find help anywhere.

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #1 on: January 10, 2014, 04:31:25 am »
this is because, you haven't pass the arguments of ContextSettings in the correct order
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #2 on: January 10, 2014, 09:21:54 am »
Worth mentioning is that visual studio builds it and posts 6 errors  but I can run it anyway.
   1   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   89
   2   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   105
   3   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   128
   4   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Window\Window.hpp   141
   5   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Graphics\RenderWindow.hpp   76
   6   IntelliSense: no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list   f:\Program\Dropbox\Programmering\Biblotek\SFML\SFML-2.1\include\SFML\Graphics\RenderWindow.hpp   93
This is just IntelliSense being stupid once more, nothing you have to really worry about. If there's a compiler error, you'd know, because the application wouldn't build. ;)

this is because, you haven't pass the arguments of ContextSettings in the correct order
No.

When I build for release and test it it works but not outside Visual Studio. 1/6 times I can move around like I should but not shoot as I should.
Sounds to me like you're doing something wrong in your movement code. Could you post a minimal and complete example that reproduces the issue? :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Pallevante

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #3 on: January 10, 2014, 09:42:22 am »
Ok good think the errors weren't important! :)

I have 3 movement codes. One for player, one for enemy and one for bullets.
All of them are subclasses to Entity which controls the move functions.


void Player::move(){

         if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
                 mCircleShape.move(mSpeed, 0);           
         }
     if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)){
                 mCircleShape.move(-mSpeed, 0);

         }
     if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)){    
                 mCircleShape.move(0, mSpeed);

         }
     if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)){
                 mCircleShape.move(0, -mSpeed);

         }

}


void Enemy::move(entityVector &mEnteties){
        sf::Time checkUpdateDir = updateDir.getElapsedTime();

        if (checkUpdateDir.asMilliseconds() > 350){

                for (entityVector::iterator i = mEnteties.begin(); i != mEnteties.end(); i++){
                        Entity* enteties = *i;
                        if (enteties->isPlayer()){

                                float x = enteties->getX() - getX();
                                float y = enteties->getY() - getY();

                                mXDir = x / sqrt(powf(x, 2) + powf(y, 2)) * mSpeed;
                                mYDir = y / sqrt(powf(x, 2) + powf(y, 2)) * mSpeed;
                               
                        }
                }
                updateDir.restart();
        }
        mCircleShape.move(mXDir, mYDir);
}


void Bullet::move(){
        mCircleShape.move(mXDir, mYDir);
}


 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #4 on: January 10, 2014, 09:49:50 am »
So I don't see any calculations to take the framerate into account. Are you just assuming that the application runs with a certain FPS? Because that's not a good idea.
You could work with a simple delta time or implement a fixed time step.

If your application would run at 3000fps the "isKeyPressed" function might get called 3000 times in a second, thus making you move too fast.

Can you provide the your general update loop?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Pallevante

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #5 on: January 10, 2014, 09:57:41 am »
So I don't see any calculations to take the framerate into account. Are you just assuming that the application runs with a certain FPS? Because that's not a good idea.
You could work with a simple delta time or implement a fixed time step.

I actually lock the game to 60 fps when main calls the constructor for game shown here:

Game::Game() :
mPlayer(new Player(400, 300)),
mEnteties(), //Initiate the vector.
mScore(0)
{
        window.setFramerateLimit(60);
        mEnteties.push_back(mPlayer);  
}

Can you provide the your general update loop?

void Game::run(){
       
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {              
                         if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)
                                 || event.type == sf::Event::Closed)
                    window.close();                      
                         
                }
       
                window.clear();
                spawnEnemies();        
                tick();
                detectCollisions();
                killEnteties();
                renderImages();
                renderScore();
                window.display();
        }
}
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #6 on: January 10, 2014, 10:04:53 am »
I actually lock the game to 60 fps when main calls the constructor for game shown here:
As I said, it's not a good practice to set a framerate and build the game on top of that, especially with the "busy-sleep" solution, since it can't generate a consistent framerate, due to the inaccuracy of sleep().
Instead you should track the frametime and passe it to the update processes and base your calculation off that value.

Could you implement a FPS counter (there's a nice one in the wiki), so see whether your FPS is at 60 in release mode as well.

Hmm well it's hard to judge, I suggest to create a new project, use one main.cpp file and add bits from your code in there, till you end up with a minimal example code that reproduces the error.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Pallevante

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #7 on: January 10, 2014, 10:41:46 am »
I've made the fps counter and it says about 57-60 fps at all times.
I've yet to encounter the blackscreen glitch and just the one with me being able to move as usual but not fire.

Barlog

  • Guest
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #8 on: January 10, 2014, 07:28:29 pm »
I've made the fps counter and it says about 57-60 fps at all times.
That's correct and will be correct only on your pc with your hardware/software configuration.

Please do read this article http://gafferongames.com/game-physics/fix-your-timestep/

Pallevante

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #9 on: January 11, 2014, 09:11:50 am »
I've tested to send the program to my friends and they same it's about the same fps one however said it was on 64 once.

But why would a locked fps make so much issues like sometimes everything goes in slow motion or other times it works fine just that you can't shoot as fast as you should.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
AW: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #10 on: January 11, 2014, 09:17:05 am »
You still haven't show use a minimal and complete (fully compilable) example. Chances are high the something in your code is wrong, but it's impossible to tell with just a few pieces here and there.

At best you create a new project, add some game loop and some simple movement code, if it also shows issues post it here.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #11 on: January 11, 2014, 10:05:09 am »
firstly, create a new project, write some minimal code, and compile it
if it compiled and worked fine, you must change your code like that
and as eXpl0it3r mentioned, don't change the framerate
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

Pallevante

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML-2.1 VS2013 Release build slow/not working outside VS.
« Reply #12 on: January 14, 2014, 10:28:22 pm »
Yeah I'm trying to get a good minimal compilable example up. The game is already minimal as is.

 

anything