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

Author Topic: Window.SetPosition() not working properly (?)  (Read 6068 times)

0 Members and 1 Guest are viewing this topic.

seba174

  • Guest
Window.SetPosition() not working properly (?)
« on: June 11, 2017, 01:42:59 pm »
Hello everyone!
I have an issue while setting position of the Window. When i set it on (0,0) it actually isn't in the left corner of the screen. .
 I have to set it's position manually to (-8,0) to be in the left corner. It doesn't matter whether Window is created by the sf::VideoMode::getDesktopMode() or by manually setting its size and position.
What should i do to have it in the left corner (instead of setting position on (-8,0))?

Thanks in advance for all replies.
seba174

EDIT
It seems like it's not only about a Window position. When i create any object like RectangleShape (e.g 8x8 px) and set it's position on (0,0) it's invisible. On the other on the top of the Window i have same offset of 22 px. Did anyone had the same problem?
With sf::Style::None or Fullscreen everything works fine.
« Last Edit: June 11, 2017, 04:17:03 pm by seba174 »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Window.SetPosition() not working properly (?)
« Reply #1 on: June 11, 2017, 08:42:53 pm »
Windows 10?

Apparently, Windows 10's positioning is identical to previous versions but the borders are a lot smaller. Positioning at (0, 0) places the window when it would have fit into the corner if the older borders were present. Basically, the -8 is the amount needed if older borders would have been 8 thicker.

Not sure I understand your RectangleShape problem, though.

EDIT: Maybe this will help:
https://stackoverflow.com/questions/35259756/wpf-and-windows-10-invisible-border-around-windows
« Last Edit: June 11, 2017, 10:29:55 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

seba174

  • Guest
Re: Window.SetPosition() not working properly (?)
« Reply #2 on: June 12, 2017, 03:49:02 pm »
Thanks for the answer.
With this RectangleShape i meant situation like this:
Sample code:
(click to show/hide)


This picture shows results of this program:


Neither rect1 nor rect2 are drawn. Rect1 position is (0,0), rect2 is (8,0). Both of them have dimensions of (8,8).
Only rect3 with position on (8,30) is drawn. This point (8,30) is like point (0,0) should be, for me.
Why is that happening?
Shouldn't be that when positioning something on (0,0) we want to have it in the left corner?
« Last Edit: June 12, 2017, 03:52:52 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Window.SetPosition() not working properly (?)
« Reply #3 on: June 12, 2017, 03:54:48 pm »
What's your desktop resolution? If it's 1600x900 or lower (ie. your window is bigger than the desktop), this might explain your problem.
Laurent Gomila - SFML developer

seba174

  • Guest
Re: Window.SetPosition() not working properly (?)
« Reply #4 on: June 12, 2017, 03:57:44 pm »
The resolution of my desktop is 1920x1080.
On fullscreen or with sf::Style::None everything works fine.
« Last Edit: June 12, 2017, 04:00:49 pm by seba174 »

seba174

  • Guest
Re: Window.SetPosition() not working properly (?)
« Reply #5 on: June 12, 2017, 04:09:17 pm »
On Window resolution 160x90 it looks like these:
sf::Style::None

sf::Style::Default

same as above but resized a bit (manually)

Is that supposed to work like these?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Window.SetPosition() not working properly (?)
« Reply #6 on: June 12, 2017, 04:57:22 pm »
I tested your code with Windows 10 and the rectangles seem fine for me:


Which version of SFML are you using? Did you build it yourself?
I used SFML v2.4.1 (pre-built binary) for this screenshot.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

seba174

  • Guest
Re: Window.SetPosition() not working properly (?)
« Reply #7 on: June 12, 2017, 05:18:25 pm »
I am using SFML 2.4.2. I have Visual C++ 14 (2015) - 32-bit built from the website.

I tried to run this program on my mate's laptop (he has VS 2015), and it also works correctly.
It seems like it is some problem with the software on my computer.

In fact I use Visual Studio 2017, maybe that causes problems? On your website there isn't package for it, so i thought that (Visual C++ 14 (2015) - 32-bit built) would suit it well.
Do i have to install VS 2015 to run SFML correctly? Is there any method to avoid it?
« Last Edit: June 12, 2017, 06:01:24 pm by seba174 »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Window.SetPosition() not working properly (?)
« Reply #8 on: June 12, 2017, 06:11:05 pm »
It's said that the 2015 version should work with VS 2017 but there hasn't been much feedback apparently as to if that's fully accurate. This may be evidence that they aren't 100% compatible.

First, I would suggest to make sure you have the latest version (SFML) and also make sure that you don't have any other versions as mixing them causes problems.

If that still doesn't work, they may not be fully compatible with VS 2017. You would then have two options: change to VS 2015 and continue using prebuilt binaries or build SFML yourself from source using VS 2017.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

seba174

  • Guest
Re: Window.SetPosition() not working properly (?)
« Reply #9 on: June 12, 2017, 08:39:01 pm »
I spend the whole evening today to find a problem... i tried to:
1. Manually build SFML libraries - that didn't help,
2. Reinstall to VS 2015 - that didn't help,

Fortunately, my friend adviced me to uninstall graphics driver.. and that solved the problem. I don't know what is wrong with intel drivers (as for now, i use Intel HD 530), but they seem to mess something.
Now i'm going to install older drivers to check if they will work properly.
« Last Edit: June 12, 2017, 10:53:03 pm by seba174 »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Window.SetPosition() not working properly (?)
« Reply #10 on: June 12, 2017, 10:25:44 pm »
Sorry to hear that it was a simple graphics drivers problem. I often forget to consider this suggestion.
At least you now know the area that the problem originates.
Was your driver fully up-to-date? The very latest driver may have fixed this already. If not, it should be expected that an update to the driver would fix this.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

seba174

  • Guest
Re: Window.SetPosition() not working properly (?)
« Reply #11 on: June 12, 2017, 10:42:47 pm »
That was the newest non-beta driver possible. I have rolled back to a bit later version which works fine. Hopefully in the upcoming releases they will manage to fix it.
Anyway, thanks for all your involvement in my problem :).
Regards,
Sebastian