SFML community forums

Help => General => Topic started by: JunkerKun on November 20, 2014, 03:07:23 pm

Title: SFML 2.1 doesn't receive events
Post by: JunkerKun on November 20, 2014, 03:07:23 pm
This is strange since it's been working before. Suddenly it stopped receiving events when FPS is above 120 or so. And even when it's below it stopps doing it sometimes, completely random. The fun thing is that mouse position is still updated...
Title: Re: SFML 2.1 doesn't receive events
Post by: Laurent on November 20, 2014, 03:32:37 pm
http://en.sfml-dev.org/forums/index.php?topic=5559.0
Title: Re: SFML 2.1 doesn't receive events
Post by: JunkerKun on November 20, 2014, 04:09:27 pm
Oh yeah, forgot I need to at least provide a piece of code. Sorry >__>

Ahem.
This piece of code is where the problem occurs:
char CoreManager::Update() {
        while (renderWindow.isOpen()) {
                CalculateDeltaTime();
                while (renderWindow.pollEvent(inputEvent)) {
                inputManager->Update();
};
                if (inputManager->GetKeyPressed(sf::Keyboard::Escape)) GameEnd();
                if (gameIsEnded || ManagerClass::Update()==3) {
                        renderWindow.close();
                        return true;
                };
                Render();
        };
        return true;
};

The problem is that whenever I check if the program even gets to the "inputManager->Update()" line, it shows that it doesn't. Obviously because the condition returns "false" in the loop.

The OS I use is Windws 8.1, I use VS 2010 Pro and SFML 2.1.
Title: Re: SFML 2.1 doesn't receive events
Post by: Rhimlock on November 20, 2014, 04:14:21 pm
How do you check, if the program even gets to the "inputManager->Update()" line?

AFAIK yor renderWindows needs the Focus the get your Events.
So if you are debugging in your IDE, your renderWindow won't get any events.
Title: Re: SFML 2.1 doesn't receive events
Post by: Gambit on November 20, 2014, 05:51:48 pm
You arent passing anything to the inputManager, how can it know what event happened?
Title: Re: SFML 2.1 doesn't receive events
Post by: JunkerKun on November 20, 2014, 06:43:33 pm
Quote
How do you check
I set a breakpoint and se if it ever breaks. I doesn't. Ever.

Quote
How do you check, if the program even gets to the "inputManager->Update()" line?
This is my own input manager, it doesn't need a parameter. Event pointer is given to it when it's being created.

Quote
So if you are debugging in your IDE, your renderWindow won't get any events.
I tried it in release build as well.
Title: Re: SFML 2.1 doesn't receive events
Post by: Gambit on November 20, 2014, 06:56:31 pm
Can you actually post a complete and minimal code sample so we can test it ourselves?
Title: Re: SFML 2.1 doesn't receive events
Post by: JunkerKun on November 20, 2014, 07:47:32 pm
Can you actually post a complete and minimal code sample so we can test it ourselves?
Sure. But not today, unfortunately :c
Title: Re: SFML 2.1 doesn't receive events
Post by: JunkerKun on November 21, 2014, 10:42:05 am
Seems like it would take quite a lot of restructuring the source to make it minimal.
Anyways, theproblem was solved by not adding a loop and instead polling events every tick. I'm still interested in what actually happens but alas no problems now.
Thanks to everyone who replied.
Title: Re: SFML 2.1 doesn't receive events
Post by: Gambit on November 21, 2014, 11:49:07 am
Complete and minimal code does not mean to make your application code as small as possible. If you read the link that Laurent provided, it means to supply a small piece of code that replicates the problem.

Also why does you update method have a return type of char but you are returning a bool? And why are you only returning true, why not make it void?