SFML community forums

Help => General => Topic started by: nickkorta on August 12, 2013, 11:33:49 pm

Title: SFML2.1 No Window.PollEvent
Post by: nickkorta on August 12, 2013, 11:33:49 pm
I don't have a pollEvent function under Window or RenderWindow.
I'm using Ubuntu and my IDE is Qt.

I linked SFML in the project File(.pro) that is made when using Qt
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp \
    game.cpp

INCLUDEPATH += \Media\nickkorta\Shared\SFML-2.1\Linux\include
LIBS += -lsfml-system -lsfml-window -lsfml-graphics -lsfml-audio

HEADERS += \
    game.hpp

 

Here is my Game.h
#include "SFML/System.hpp"
#include"SFML/Graphics.hpp"
#include "SFML/Window.hpp"
#include "SFML/Audio.hpp"
#include "SFML/Network.hpp"


#ifndef GAME_HPP
#define GAME_HPP

class Game
{
public:
    Game();
private:
    void Initialize();
    void LoadContent();
    void Update();
    void Draw();
    bool running;
    sf::RenderWindow window;
    sf::Event event;
};

#endif // GAME_HPP
 

Game.cpp
#include "game.hpp"

Game::Game()
{
    Initialize();
    LoadContent();
    while(running)
    {
        Update();
        Draw();
    }
    window.Close();
}

void Game::Initialize()
{
    window.Create(sf::VideoMode(1080,720,32),"Game");
}

void Game::LoadContent()
{
}

void Game::Update()
{
    while (window.pollEvent(event))
    {
    }
}

void Game::Draw()
{
    window.Display();
    window.Clear();
}
 

Everything runs fine. I also noticed that I can move the window around and can use the maximize and minimize buttons. I have done this in windows and I cant do that without using Window.PollEvent(event).

Thanks
Title: Re: SFML2.1 No Window.PollEvent
Post by: Aster on August 13, 2013, 12:01:42 am
What do you mean by "You don't have"?
Could you provide an error?
Title: Re: SFML2.1 No Window.PollEvent
Post by: nickkorta on August 13, 2013, 12:07:55 am
error: 'class sf::RenderWindow' has no member named 'PollEvent'

I does not show up under other members when typing window.
Title: Re: SFML2.1 No Window.PollEvent
Post by: AlejandroCoria on August 13, 2013, 12:14:49 am
you're using SFML 1.6, because the function names like Clear or Display in SFML 2.0 and later are in lowercase
Title: Re: SFML2.1 No Window.PollEvent
Post by: Nexus on August 13, 2013, 12:15:29 am
You're using an old version. Install SFML 2.1.

Furthermore, auto-completion tools are not reliable, they often contain bugs.
Title: Re: SFML2.1 No Window.PollEvent
Post by: nickkorta on August 13, 2013, 12:29:32 am
I download GCC-2 under Linux here. http://www.sfml-dev.org/download/sfml/2.1/
I'm pretty sure i'm using 2.1. I just re downloaded it and linked it up and everything is the same.

Edit: I went to windows and that is using SFML 2.1(Visual Studio) witch was downloaded at the same page.
Title: Re: SFML2.1 No Window.PollEvent
Post by: eXpl0it3r on August 13, 2013, 03:14:57 am
I download GCC-2 under Linux here. http://www.sfml-dev.org/download/sfml/2.1/
Just because you download it, it doesn't mean that you're using it. ;)

If you've ever installed SFML from the package manager, which is most likely still version 1.6, then the compiler will probably use SFML 1.6 over the downloaded version. At best you just uninstall SFML 1.6, since it's rather old.