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

Author Topic: gl Viewport oddly translated downwards when using fullscreen  (Read 3333 times)

0 Members and 1 Guest are viewing this topic.

pvallet

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • github
    • Email
gl Viewport oddly translated downwards when using fullscreen
« on: November 15, 2016, 06:07:19 pm »
Hello everybody,

I came across an odd problem while using fullscreen with the SFML:

Sometimes when launching my program, the gl viewport turns out translated downwards, leaving a black strip on the top. (about 50% of the time everything works fine). Here is a picture attached to illustrate it.

I create my window using
sf::ContextSettings context(24, 8, 4, 3, 0);
sf::RenderWindow window(sf::VideoMode::getFullscreenModes().front(), "OpenGL", sf::Style::Fullscreen, context);

The fullscreen mode is always 1366x768x32. When the problem appears, the size of the sf::View associated with the sf::RenderWindow is cropped to 1366x715, which translates the FPS counter but keeps the minimap whole (not cropped on the bottom).

When I click, OpenGL handles my click as if it was translated downwards, too, even on the minimap.

Changing the view or the size of the window only changes how the 2D elements are draw, the black strip on the top stays unchanged.


Would you have any idea on how to fix this ?


Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
gl Viewport oddly translated downwards when using fullscreen
« Reply #1 on: November 15, 2016, 06:44:49 pm »
What OS? What WM? Are you using custom OpenGL code?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

pvallet

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • github
    • Email
Re: gl Viewport oddly translated downwards when using fullscreen
« Reply #2 on: November 15, 2016, 07:03:52 pm »
I'm on ubuntu 16.04 right now but if I remember well the problem also appears on windows.

I am using custom OpenGL indeed, but when I turn it off to leave only the minimap and the FPS counter, everything remains the same.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
gl Viewport oddly translated downwards when using fullscreen
« Reply #3 on: November 15, 2016, 08:53:03 pm »
Can you provide a complete but minimal example that reproduces the issue?

What's your window manager? What SFML version are you using?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

pvallet

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • github
    • Email
Re: gl Viewport oddly translated downwards when using fullscreen
« Reply #4 on: November 16, 2016, 01:50:07 am »
I am using SFML 2.3.2 (the one from the repository of Ubuntu 16.04). As for my window manager, the file /etc/X11/default-display-manager contains /usr/sbin/gdm3

The code that I was explaining was minimal in the sense that when testing the size of the window right after generating it, I got a height of 715 instead of 766.

Here is a simple code reproducing the bug. The bug does not occur every time. I have two kind of displays, as shown in the attachment, one with a translated rectangle and the other with the normal white rectangle (there seems to be some kind of other bug but this is not the point here).
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>

int main() {
  sf::ContextSettings context(24, 8, 4, 3, 0);
  sf::RenderWindow window(sf::VideoMode::getFullscreenModes().front(), "OpenGL", sf::Style::Fullscreen, context);

  sf::RectangleShape test(sf::Vector2f(200, 20));
  test.setFillColor(sf::Color::White);
  test.setPosition(sf::Vector2f(0,0));

  while (true) {
    window.draw(test);
    window.display();
  }

  return 0;
}

I am now using some kind of workaround: as my problem only appears sometimes, I just have to recreate the window until it is as I want it to be. This does not really solve the problem though.

sf::RenderWindow window;
for (size_t i = 0; i < 20; i++) {
  window.create(sf::VideoMode::getFullscreenModes().front(), "OpenGL", sf::Style::Fullscreen, context);
  if (window.getSize().y == sf::VideoMode::getFullscreenModes().front().height)
    break;
}



eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
gl Viewport oddly translated downwards when using fullscreen
« Reply #5 on: November 16, 2016, 07:41:36 am »
This should already be fixed in SFML 2.4.1. Try building SFML on your own.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

pvallet

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • github
    • Email
Re: gl Viewport oddly translated downwards when using fullscreen
« Reply #6 on: November 18, 2016, 01:19:42 am »
Yes, the problem is indeed solved with the version 2.4.1

Note that with the version 2.4.0, there is no black strip on the top, but when clicking, the position of the mouse is also translated downwards.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: gl Viewport oddly translated downwards when using fullscreen
« Reply #7 on: November 18, 2016, 01:31:02 am »
2.4.0 still uses XCB which had quite a few issues due to missing documentations or window managers not following the standard, which is why we switch back to Xlib-only in 2.4.1.

Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/