Difference between revisions of "love.window.setFullscreen"

(Changed from love.window.toggleFullscreen to love.window.setFullscreen)
m (Examples: - Fix the second example.)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{newin|[[0.9.0]]|090|type=function}}
 
{{newin|[[0.9.0]]|090|type=function}}
Enters or exits fullscreen.
+
Enters or exits fullscreen. The display to use when entering fullscreen is chosen based on which display the window is currently in, if multiple monitors are connected.
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 9: Line 9:
 
{{param|boolean|fullscreen|Whether to enter or exit fullscreen mode.}}
 
{{param|boolean|fullscreen|Whether to enter or exit fullscreen mode.}}
 
=== Returns ===
 
=== Returns ===
{{param|boolean|success|True if successful, false otherwise.}}
+
{{param|boolean|success|True if an attempt to enter fullscreen was successful, false otherwise.}}
  
 
== Function ==
 
== Function ==
Line 20: Line 20:
 
{{param|FullscreenType|fstype|The type of fullscreen mode to use.}}
 
{{param|FullscreenType|fstype|The type of fullscreen mode to use.}}
 
=== Returns ===
 
=== Returns ===
{{param|boolean|success|True if successful, false otherwise.}}
+
{{param|boolean|success|True if an attempt to enter fullscreen was successful, false otherwise.}}
 +
 
 +
== Notes ==
 +
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.
 +
 
 +
== Examples ==
 +
Make the window fullscreen in desktop mode.
 +
<source lang="lua">
 +
function love.load()
 +
    love.window.setFullscreen(true, "desktop")
 +
end
 +
</source>
 +
 
 +
Make the window fullscreen in exclusive mode and back on F11:
 +
<source lang="lua">
 +
function love.keypressed(key, scancode, isrepeat)
 +
if key == "f11" then
 +
fullscreen = not fullscreen
 +
love.window.setFullscreen(fullscreen, "exclusive")
 +
end
 +
end
 +
</source>
  
 
== See Also ==
 
== See Also ==
 
* [[parent::love.window]]
 
* [[parent::love.window]]
 +
* [[love.window.getFullscreen]]
 
* [[love.window.setMode]]
 
* [[love.window.setMode]]
 +
* [[love.resize]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Enters or exits fullscreen.}}
 
{{#set:Description=Enters or exits fullscreen.}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.window.setFullscreen}}
 
{{i18n|love.window.setFullscreen}}

Latest revision as of 21:48, 17 July 2022

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

Enters or exits fullscreen. The display to use when entering fullscreen is chosen based on which display the window is currently in, if multiple monitors are connected.

Function

Synopsis

success = love.window.setFullscreen( fullscreen )

Arguments

boolean fullscreen
Whether to enter or exit fullscreen mode.

Returns

boolean success
True if an attempt to enter fullscreen was successful, false otherwise.

Function

Synopsis

success = love.window.setFullscreen( fullscreen, fstype )

Arguments

boolean fullscreen
Whether to enter or exit fullscreen mode.
FullscreenType fstype
The type of fullscreen mode to use.

Returns

boolean success
True if an attempt to enter fullscreen was successful, false otherwise.

Notes

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.

Examples

Make the window fullscreen in desktop mode.

function love.load()
    love.window.setFullscreen(true, "desktop")
end

Make the window fullscreen in exclusive mode and back on F11:

function love.keypressed(key, scancode, isrepeat)
	if key == "f11" then
		fullscreen = not fullscreen
		love.window.setFullscreen(fullscreen, "exclusive")
	end
end

See Also

Other Languages