SFML community forums

Help => Window => Topic started by: chrisciscoioio on October 31, 2012, 02:55:43 pm

Title: Mouse Get Position Issue
Post by: chrisciscoioio on October 31, 2012, 02:55:43 pm
I wasn't passing a window to be relative to, I assumed that passing a window was only used for multiple window setup, apparently it is not, my issue is resolved.
Title: Re: Mouse Get Position Issue
Post by: eXpl0it3r on October 31, 2012, 03:04:14 pm
Important to note is I did adjust the y coord because I am using openGL, but even still they are both messed up.
You're doing somewhere something wrong, most probably when you assume that you 'just' adjust the y coordinate with OpenGL directly, but without any code, we can't help you at all. I mean what do you expect us to do, when we have no clue at all what you're doing?
How do you check things at breakpoint? How do you ensure that the two checks happen at the same time?

Does this behave the same way?
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Resize");
    window.setFramerateLimit(60);

    sf::Vector2i mousePos;

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
                window.close();
        }

        mousePos = sf::Mouse::getPosition();
        // Set your break point to the next line and check mousePos there.
        std::cout << mousePos.x << "," << mousePos.y << std::endl;

        window.clear();
        window.display();
    }
}
 
Title: Re: Mouse Get Position Issue
Post by: chrisciscoioio on October 31, 2012, 03:11:50 pm
I wasn't passing a window to be relative to, I assumed that passing a window was only used for multiple window setup, apparently it is not, my issue is resolved.
Title: Re: Mouse Get Position Issue
Post by: Laurent on October 31, 2012, 03:37:48 pm
Quote
I assumed
Wrong. Just read the docs ;)