SFML community forums

Help => Window => Topic started by: colask8 on July 12, 2013, 10:18:21 pm

Title: How to get position of screen
Post by: colask8 on July 12, 2013, 10:18:21 pm
Dear community,
I have problem with getting the information from getPosition().
window.setPosition(1000,300);
 
output of getPosition()

Here is screen shoot with code, simple sfml application.

http://s22.postimg.org/iqeqa6uz5/getposition.png

How to get true position of window?

~Cola
Title: Re: How to get position of screen
Post by: Nexus on July 12, 2013, 10:22:55 pm
Are you sure your console I/O is not broken? It may sound silly, but I have already encountered IDEs (XCode) that omit characters written in the console. That would at least explain the coincidence of (10,30) and (1000,300).

Maybe test with the debugger or when executing directly in the operating system's terminal.
Title: Re: How to get position of screen
Post by: colask8 on July 12, 2013, 10:45:51 pm
Here is new code and output from system terminal:

http://s21.postimg.org/8pgs324ef/new_get_position.png

here is code:
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace std;
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(400, 400), "SFML window");
    window.setFramerateLimit(60);
    window.setPosition(sf::Vector2i(700, 400));
    int curPositionX = window.getPosition().x;
    int curPositionY = window.getPosition().y;
    cout << "X: " << curPositionX << endl;
    cout << "Y: " << curPositionY << endl;

    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // Clear screen
        window.clear();

        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}
 

There is no coincidence between 700x400 and 640x325 or there is ? Ide terminal is still 10 and 30.

~Cola