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

Author Topic: How to get position of screen  (Read 3042 times)

0 Members and 1 Guest are viewing this topic.

colask8

  • Newbie
  • *
  • Posts: 4
    • View Profile
How to get position of screen
« 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

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: How to get position of screen
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

colask8

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to get position of screen
« Reply #2 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

 

anything