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

Author Topic: [OSX] Window.getPosition return wrong coords  (Read 2113 times)

0 Members and 1 Guest are viewing this topic.

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
[OSX] Window.getPosition return wrong coords
« on: November 16, 2012, 05:42:47 am »
In OSX, Window.getPosition() always return the coord (0, 900) despite manually setting or moving the window.

Here is a code example

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>

int main(int argc, char** argv)
{
    sf::ContextSettings context_settings(16, 0, 0, 3, 1);

    sf::Window window(sf::VideoMode(1024, 768),
        "SFML - OpenGL Test", sf::Style::Default, context_settings);

    window.setPosition(sf::Vector2i(50, 50));

    glClearColor(0.39f, 0.58f, 0.93f, 1.0f);

    bool running = true;

    while (running)
    {
        sf::Event event;

        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                glViewport(0, 0, event.size.width, event.size.height);
            }
            else if (event.type == sf::Event::KeyPressed)
            {
                if (event.key.code == sf::Keyboard::A)
                {
                    printf("Window Position - %i, %i\n",
                        window.getPosition().x, window.getPosition().y);
                }
            }
        }

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        window.display();
    }

    return EXIT_SUCCESS;
}
 

Pressing the key 'A' always prints the following output:
Window Position - 0, 900
Window Position - 0, 900
 

I am using the build from the source repository.

P.S another side question. I notice that setPosition takes a signed integer. Does it means it can accept negative coords. If it does, how does the negative coord affect window placement? In OSX, if i do setPosition({-50, -50}) the window wrap to the bottom right instead of the top left.
« Last Edit: November 16, 2012, 06:23:11 am by mercurio7891 »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: [OSX] Window.getPosition return wrong coords
« Reply #1 on: November 18, 2012, 03:45:21 pm »
Yes, getPosition is buggy, and so is probably setPosition.
SFML / OS X developer

 

anything