Page 1 of 1

Is there a way to get the current monitor resolution?

Posted: Sat Feb 23, 2013 9:48 am
by O/m
I want to be able to change to fullscreen mode while not defaulting to some random resolution.
More specificly, I don't want the screen to change resolution when I switch to fullscreen.
So if I'm using this,

Code: Select all

local w, h, fullscreen, v, f = love.graphics.getMode()
love.graphics.setMode(x, y, true, v, f)
to go fullscreen. I need to know what is the current resolution to set x and y.

Re: Is there a way to get the current monitor resolution?

Posted: Sat Feb 23, 2013 2:59 pm
by Automatik
You can use:

Code: Select all

love.graphics.setMode(0, 0, true, v, f)
Then, it will default to the current resolution.
Also, if it do a black screen for you, use:

Code: Select all

love.graphics.setMode(0, 0, true, v, f)
love.graphics.setMode(love.graphics.getWidth(),love.graphics.getHeight(), true, v, f)

Re: Is there a way to get the current monitor resolution?

Posted: Sat Feb 23, 2013 3:20 pm
by O/m
yep, it works like you said.
can you explain why we need the second line there?
it would be better not to have to set the mode twice.

Re: Is there a way to get the current monitor resolution?

Posted: Sat Feb 23, 2013 4:56 pm
by Boolsheet
O/m wrote:can you explain why we need the second line there?
it would be better not to have to set the mode twice.
It's a bug in LÖVE 0.8.0. The OpenGL viewport doesn't get set properly if the zeros are used. It will be fixed in the next version.

Re: Is there a way to get the current monitor resolution?

Posted: Sat Feb 23, 2013 5:55 pm
by O/m
OK, thanks for the help!

Re: Is there a way to get the current monitor resolution?

Posted: Thu Oct 31, 2013 2:02 am
by Daniel Eakins
Is there a way to get the current monitor resolution without visibly changing the window size? (For example, if my game window is 320x200 and I want to get the monitor resolution, the code above will visibly change the window size.)

Re: Is there a way to get the current monitor resolution?

Posted: Thu Oct 31, 2013 2:06 am
by slime
In 0.9.0 you can use [wiki]love.window.getDesktopDimensions[/wiki].

The current resolution will also often be the largest width and height in the table returned by [wiki]love.graphics.getModes[/wiki] ([wiki]love.window.getFullscreenModes[/wiki] in 0.9.0), although it likely will not be the case if the user is in OS X with a retina display.

Re: Is there a way to get the current monitor resolution?

Posted: Thu Oct 31, 2013 2:12 am
by Daniel Eakins
Thanks! I'll check this out :D