Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphics not properly scaled on high dpi screen on Mac #62

Open
shg opened this issue Sep 18, 2022 · 3 comments
Open

Graphics not properly scaled on high dpi screen on Mac #62

shg opened this issue Sep 18, 2022 · 3 comments

Comments

@shg
Copy link

shg commented Sep 18, 2022

I tested basic.jl and found that the graphics are only shown in the top-left quadrant of the window on my Mac. I guess high DPI (retina) screen is not supported. The background image is shown correctly maybe because it is a texture that fills the whole surface.

I see some code which may be related to high DPI screen in window.jl but I have no idea how to fix it...

The same issue exists in all the other examples (basic2.jl and ones in GZExamples).

basic_mac.mov
@rekabrnalla
Copy link

rekabrnalla commented Jan 30, 2023

I also see this problem on Mac OS. I have an M1 Mac Mini with macOS Ventura. 13.1. 32-inch (3840 × 2160)
Version 0.3.1 of game zero.jl

I have to add the *2 to the mouse position to make the cursor properly track. The window is drawn twice as big as it should be. The lines are only in the 1st quadrant and do not fill the window.

Also I cannot close the window by x-ing out of it. It hangs around even though the prompt comes back in Julia.

Example code below that can be put into a file and run with gamezero.

# initialize screen

WIDTH = 600
HEIGHT = 600
BACKGROUND = colorant"antiquewhite"

# define initial state of actors

hline = Line(0, 300, 600, 300)
vline = Line(300, 0, 300, 600)
mouse = Circle(300,300,50)


function draw(g::Game)
    draw(hline, colorant"black")
    draw(vline, colorant"black")
    draw(mouse, colorant"blue", fill=true)
end


#define mouse inputs
 function on_mouse_move(g::Game, pos)
    mouse.x = pos[1]*2
    mouse.y = pos[2]*2
 end

@aviks
Copy link
Owner

aviks commented Jan 30, 2023

Yes, unfortunately I haven't been able to find a fix for this yet.

I use GameZero/SDL2 on Windows with a HiDPI display, and it works correctly. It even works with fractional scaling (my monitors are set to 175% and 150% scaling).

SO suggests the corrent way to handle this in SDL is to set SDL_WINDOW_ALLOW_HIGHDPI when creating windows, which we do use here , and that seems to work correctly on windows.

Would appreciate any ideas or investigations.

@shg shg changed the title Graphics not properly scaled on high dpi screen Graphics not properly scaled on high dpi screen on Mac Feb 1, 2023
@rekabrnalla
Copy link

So is there a change to the code above that I need to make to resolve it or is it just unusable on MAC.

We just need to pass this issue to the SimpleDirectMediaLayer people? Or is there a different combination of switches that MACOS need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants