Skip to content

Several problems with fullscreen handling #1066

@64kramsystem

Description

@64kramsystem

Describe the bug

I'm having several problems with fullscreen handling. I'm not sure whether I'm using the APIs the intended way, but I couldn't find clear indications about what do. If any of the problem mentioned is a misinterpretation of mine, I'm ok to be redirected to the relevant documentation 😄

I'm adding each of the problems in a section at the bottom.

Hardware and Software:

ggez version: 0.7.0
OS: Linux (Ubuntu 20.04)
Graphics card: Should be (not 100% sure, though) UHD Graphics 620 (Whiskey Lake)
Graphics card drivers: Open source

Problem 1: FullscreenType::Desktop drawable size is less than expected

I'm trying to find the drawable size of the screen, in FullscreenType::Desktop mode + borderless, however, I don't get the full screen size; it seems that borderless has no effect. Snippet:

    let mut context_builder = ggez::ContextBuilder::new(GAME_ID, AUTHOR)
        .window_setup(ggez::conf::WindowSetup::default().title(WINDOW_TITLE))
        .window_mode(
            ggez::conf::WindowMode::default()
                .borderless(true)
                .fullscreen_type(ggez::conf::FullscreenType::Desktop),
        );
    let (mut context, event_loop) = context_builder.build()?;

    let (screen_width, screen_height) = ggez::graphics::drawable_size(context);

The last statement returns 1920x1052, while my screen is 1920x1080.

Problem 2: drawable size is either not set, or not returned correctly

Based on my understanding of the documentaiton, drawable size is the physical screen size, valid only on true fullscreen. This matches my experience; if I set an invalid value, the library panics.

However, after I set the drawable size, the API ggez::graphics::drawable_size, still returns the pre-change size. Snippet:

    let mut context_builder = ggez::ContextBuilder::new(GAME_ID, AUTHOR)
        .window_setup(ggez::conf::WindowSetup::default().title(WINDOW_TITLE))
        .window_mode(
            ggez::conf::WindowMode::default().fullscreen_type(ggez::conf::FullscreenType::True),
        );
    let (mut context, event_loop) = context_builder.build()?;

    ggez::graphics::set_drawable_size(context, 1920., 1080.)?;
    println!("DS: {:?}", ggez::graphics::drawable_size(context));

The last statement prints DS: (800.0, 600.0).

Problem 3: display corruption

Ignoring the issues above, when I try to actually display the game fullscreen, the screen is corrupted (the viewport is displayed multiple times, in different sizes and locations)

This is the snippet:

    let mut context_builder = ggez::ContextBuilder::new(GAME_ID, AUTHOR)
        .window_setup(ggez::conf::WindowSetup::default().title(WINDOW_TITLE))
        .window_mode(
            ggez::conf::WindowMode::default().fullscreen_type(ggez::conf::FullscreenType::True),
        );

    let (mut context, event_loop) = context_builder.build()?;

    ggez::graphics::set_drawable_size(context, 1920., 1080.)?;

    ggez::graphics::set_screen_coordinates(
        context,
        Rect::new(
            -60.,
            -0.,
            1800.,
            1080.,
        ),
    )

The values come from some calculations that I have omitted here; they just adjust the proportions to the game area.

In order to reproduce this:

git clone git@github.com:64kramsystem/rust-game-ports
cd rust-game-ports
git checkout fullscreen_true_attempt
cd boing-ggez
cargo run

The file with the screen setup logic is in main.rs.

Sample corruption: corruption

Follow-up

I've done other attempts, and there may be other problems, but at this stage I'm extremely confused, so if the points above are clear, I'll know how to tackle them.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions