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

Author Topic: Wrong mouse coordinates  (Read 1362 times)

0 Members and 1 Guest are viewing this topic.

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Wrong mouse coordinates
« on: January 21, 2012, 03:41:43 pm »
I've discovered that Mouse.GetPosition() return mouse position on desktop and not take care of REnderWindow i made... this code:
#include <SFML/Graphics.hpp>
#include <iostream>

Code: [Select]
int main()
{
sf::RenderWindow App(sf::VideoMode(800,600,32),"SFML AnimTest",sf::Style::Titlebar | sf::Style::Close);
sf::Event _event;

while(App.IsOpen()){

std::cout << sf::Mouse::GetPosition().x << "  "<< sf::Mouse::GetPosition().y<<std::endl;

if (App.PollEvent(_event))
{
if (_event.Type == sf::Event::Closed || (_event.Type == sf::Event::KeyPressed && _event.Key.Code == sf::Keyboard::Escape))
App.Close();
}
App.Clear(sf::Color::White);
App.Display();
}
return EXIT_SUCCESS;
}


And here the screens:
http://img220.imageshack.us/img220/4075/76593094.jpg
http://img220.imageshack.us/img220/4075/76593094.jpg

The red arrows point to mouse when i made the print, first on top-left of my desktop, then on bottom-right. As you can see on console my desktop top-left coordinates are 0,0 and not my SFML window. Why? Is it a bug or not?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Wrong mouse coordinates
« Reply #2 on: January 21, 2012, 03:55:08 pm »
Quote from: "Laurent"
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Mouse.php#ac48d527ca5b712252d80a9a991f5a582


I'm stupid :(
So the problem was that i forget to give App in GetPosition() :D

 

anything