The mouse point returned by getMouseY() does not appear to account for the title bar.
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "Test Window");
const sf::Input& wInput = window.GetInput();
window.ShowMouseCursor(true);
sf::Shape rec = sf::Shape::Rectangle(0,0,100,100, sf::Color(255,0,0));
while (window.IsOpened())
{
// Process events
sf::Event event;
while (window.GetEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
window.Close();
if (event.Type == sf::Event::KeyPressed) {
// Escape key : exit
if (event.Key.Code == sf::Key::Escape)
window.Close();
}
}
float mouseX = (float)wInput.GetMouseX();
float mouseY = (float)wInput.GetMouseY();
rec.SetPosition(mouseX, mouseY);
window.Clear(sf::Color::Green);
window.Draw(rec);
window.Display();
}
return EXIT_SUCCESS;
}