Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console mode time suspension results in incorrect FPS calculation #298

Open
TediusTimmy opened this issue Oct 9, 2022 · 10 comments
Open

Comments

@TediusTimmy
Copy link

TediusTimmy commented Oct 9, 2022

Greetings,
Whenever I use your new console, my program only reports 1 FPS. I expect that that's just an oversight that someone on the Discord, which I don't follow, has already reported. But, here it is on GitHub, in case other people, like me, don't follow Discord.
Current Embedded Language

@TediusTimmy
Copy link
Author

Thanks, man. I know that I probably come across as a very confrontational person, but no disrespect (or confrontation, for that matter) is intended. I'm just very blunt. Be blunt to me and I'll tell you if you've crossed a line.

@OneLoneCoder
Copy link
Owner

Can't say I've experienced this myself, I shall investigate.

@TediusTimmy
Copy link
Author

In this program, I start the console immediately and for it to be running constantly. Maybe that is my problem. Let me create a simple example for you and see if it displays the same properties.

@TediusTimmy
Copy link
Author

So, this could be a Cygwin/GCC issue: here is code

#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"

class Demo : public olc::PixelGameEngine
 {
public:
   Demo()
    {
      sAppName = "Console Test";
    }

private:

public:
   bool OnUserCreate() override
    {
      return true;
    }

   bool OnUserUpdate(float /*fElapsedTime*/) override
    {
      ConsoleShow(olc::Key::ESCAPE);
      return true;
    }

	bool OnConsoleCommand(const std::string& sCommand)
    {
      ConsoleOut() << "> " << sCommand << std::endl;
      return true;
    }
 };

int main()
{
   Demo demo;
   if (demo.Construct(640, 480, 2, 2))
      demo.Start();
   return 0;
}

With the Cygwin compile, I get 1 FPS. If you get a different result from MSC++, post a picture and I'll assume it's a Cygwin issue.

@sigonasr2
Copy link

ConsoleShow() by default pauses the timer (Function args are: ConsoleShow(const olc::Key &keyExit, bool bSuspendTime = true) .

Constantly calling it in OnUserUpdate will never allow the FPS timer to update, so it remains at 1. You can get a simpler isolated case of this by calling ConsoleShow(olc::ESCAPE) in OnUserCreate(). This makes the FPS 1 at the beginning of the application. Then, simply hitting Escape to see the FPS timer go back to normal.

Additionally if you set bSuspendTime to false, the timer will start updating again, resulting in normal FPS updating.

So for your example @TediusTimmy, doing ConsoleShow(olc::Key::ESCAPE,false); would result in an FPS counter updating once again.

@TediusTimmy
Copy link
Author

@sigonasr2 Something just feels off about this. Yes, the timer is suspended, but it is weird. In my heart of hearts, this is not a bug, but is solved by documentation.

@TediusTimmy
Copy link
Author

David, i hope the example works for you. Sorry about the Davey, my brother doesn't like being called it either.

@Moros1138
Copy link
Collaborator

So, this could be a Cygwin/GCC issue

With the Cygwin compile, I get 1 FPS. If you get a different result from MSC++, post a picture and I'll assume it's a Cygwin issue.

None of the active testing we do involves cygwin, the current recommendation for using GCC on windows has, and will remain for quite some time due to stability, is GCC provided by MSYS2. If it is an issue specific to cygwin, that's why nobody's run across it.

@Moros1138
Copy link
Collaborator

that said, I did give your code a quick try on my linux installation and experience a 1fps situation myself.
2022-10-09_11-46

@Moros1138
Copy link
Collaborator

Right, after doing a little more research into the console code, it seems there's a second argument for

ConsoleShow

void ConsoleShow(const olc::Key &keyExit, bool bSuspendTime = true);

which you can see here: https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L1103

it defaults to true which suspends fElapsedTime to 0 each frame... since fElapsedTime is used by the engine to calculate FPS it has the side affect of reporting the FPS inaccurately while time is supsended.

I'll kick this to Javid as I think he'll have a think about whether or not this is simply the intended behavior or if PGE should report FPS accurately whether engine time has halted or not...

@TediusTimmy TediusTimmy changed the title Console mode displays 1 FPS Console mode time suspension results in incorrect FPS display Oct 10, 2022
@TediusTimmy TediusTimmy changed the title Console mode time suspension results in incorrect FPS display Console mode time suspension results in incorrect FPS calculation Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants