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

Author Topic: SFML 2.1 doesn't receive events  (Read 2944 times)

0 Members and 1 Guest are viewing this topic.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
SFML 2.1 doesn't receive events
« 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...
« Last Edit: November 20, 2014, 03:21:27 pm by JunkerKun »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #2 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.

Rhimlock

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #3 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.

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #4 on: November 20, 2014, 05:51:48 pm »
You arent passing anything to the inputManager, how can it know what event happened?

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #5 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.

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #6 on: November 20, 2014, 06:56:31 pm »
Can you actually post a complete and minimal code sample so we can test it ourselves?

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #7 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

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #8 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.

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: SFML 2.1 doesn't receive events
« Reply #9 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?