Any way to proper toggleFullscreen function

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
greycoder
Prole
Posts: 2
Joined: Sat Jul 14, 2018 7:20 pm

Any way to proper toggleFullscreen function

Post by greycoder »

Hellow everyone, I've tried coding like that

Code: Select all

love.window.setFullscreen(not love.window.getFullscreen())
But in case of 'fullscreen mode' > 'windowed mode' you get window adjusted to screen size
Then I coded

Code: Select all

local fsc_val = love.window.getFullscreen()
if fsc_val then
	love.window.updateMode(_config.window.width, _config.window.height, {fullscreen = false})
else
	love.window.setFullscreen(true)
end
where _config is some global to link to conf table. Is there better way to code toggleFullscreen function without making globals?
User avatar
Duck Duckinson
Prole
Posts: 6
Joined: Sun Jul 15, 2018 1:23 pm

Re: Any way to proper toggleFullscreen function

Post by Duck Duckinson »

https://love2d.org/wiki/Config_Files

Create a file in the same directory as your main.lua named "conf.lua"
Inside you put:

function love.conf(t)
t.window.fullscreen = true
end
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Any way to proper toggleFullscreen function

Post by Nixola »

First of all: default fullscreen is evil.
Second, the question was about toggling it, not setting it.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Any way to proper toggleFullscreen function

Post by zorg »

From the wiki: love.window.setFullscreen
If fullscreen mode is entered and the window size doesn't match one of the monitor's display modes (in normal fullscreen mode) or the window size doesn't match the desktop size (in 'desktop' fullscreen mode), the window will be resized appropriately. The window will revert back to its original size again when fullscreen mode is exited using this function.
Basically, it should go back to the size the window had before going to fullscreen.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests