SFML community forums
Help => Window => Topic started by: etam 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:#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".
-
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.
-
So as long as mouse is unmoved I can't get its position? Looks like a bug.
-
So as long as mouse is unmoved I can't get its position?
Correct.
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.