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

Author Topic: Mouse Get Position Issue  (Read 2420 times)

0 Members and 1 Guest are viewing this topic.

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Mouse Get Position Issue
« 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.
« Last Edit: October 31, 2012, 03:12:29 pm by chrisciscoioio »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Mouse Get Position Issue
« Reply #1 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();
    }
}
 
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Mouse Get Position Issue
« Reply #2 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Mouse Get Position Issue
« Reply #3 on: October 31, 2012, 03:37:48 pm »
Quote
I assumed
Wrong. Just read the docs ;)
Laurent Gomila - SFML developer