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

Author Topic: does window.pollEvent() remove the first item or remove the last item?  (Read 2856 times)

0 Members and 1 Guest are viewing this topic.

dilipisharaSFML

  • Guest
is window.pollEvent() method follow the stack or queue when polling events? I read the sfml repositry and I could find this,

 
bool WindowBase::pollEvent(Event& event)
{
    if (m_impl && m_impl->popEvent(event, false))
    {
        filterEvent(event);
        return true;
    }
    else
    {
        return false;
    }
}
 

but I still cannot figure out that removal process of the pollEvent is happenning at the begining or the ending.
I looking for a quick answer since I have a another question depending on your answer!  :)
« Last Edit: January 20, 2024, 10:24:28 am by dilipisharasfml »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: does window.pollEvent() remove the first item or remove the last item?
« Reply #1 on: January 21, 2024, 05:02:20 pm »
It should be noted that events are usually treated as independent effects so shouldn't necessarily rely on order.
With that said, you should expect that the events given by SFML are in the order that they happened.



DETAILED INFO:
If you look at the popEvent call in your quoted code, you can see that it's called on m_impl so that's where you would have found it. Here it is (popEvent):
https://github.com/SFML/SFML/blob/master/src/SFML/Window/WindowImpl.cpp#L178

Note that it removes the first one so it's a queue:
https://github.com/SFML/SFML/blob/master/src/SFML/Window/WindowImpl.cpp#L204
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

dilipisharaSFML

  • Guest
Re: does window.pollEvent() remove the first item or remove the last item?
« Reply #2 on: February 10, 2024, 07:06:41 am »
Thanks for the clarification