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

Author Topic: [sfml2][linux] sf::Input::GetMouse* after creating window  (Read 1575 times)

0 Members and 1 Guest are viewing this topic.

etam

  • Newbie
  • *
  • Posts: 5
    • View Profile
[sfml2][linux] sf::Input::GetMouse* after creating window
« on: May 02, 2011, 10:12:55 pm »
After creating window I want to know where the mouse is, but my method doesn't seem to work.

minimal code:
Code: [Select]
#include <SFML/OpenGL.hpp>
#include <SFML/Window.hpp>
#include <iostream>

int main() {
    sf::Window window(sf::VideoMode(800, 600), "SFML window");
    window.Display();
    std::cout << "x:" << window.GetInput().GetMouseX() << " y:" << window.GetInput().GetMouseX() << std::endl;
    window.Close();
    return 0;
}

In this example window appears and disappears immediately, but wherever mouse is it always returns "x:0 y:0".

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[sfml2][linux] sf::Input::GetMouse* after creating window
« Reply #1 on: May 02, 2011, 10:15:55 pm »
sf::Input is not directly connected to the OS, it relies on the events processed when you call PollEvent. So basically you can't use sf::Input without an event loop.
Laurent Gomila - SFML developer

etam

  • Newbie
  • *
  • Posts: 5
    • View Profile
[sfml2][linux] sf::Input::GetMouse* after creating window
« Reply #2 on: May 02, 2011, 10:47:16 pm »
So as long as mouse is unmoved I can't get its position? Looks like a bug.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[sfml2][linux] sf::Input::GetMouse* after creating window
« Reply #3 on: May 02, 2011, 11:18:11 pm »
Quote
So as long as mouse is unmoved I can't get its position?

Correct.

Quote
Looks like a bug

But it's not.
I know that sf::Input has some limitations, but making it rely on the OS functions rather than sf::Event would bring new problems.
Laurent Gomila - SFML developer