Difference between revisions of "love.window.getDesktopDimensions"

(Added example)
m (Explicitly specify which one is the first index)
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
width, height = love.window.getDesktopDimensions( display )
+
width, height = love.window.getDesktopDimensions( displayindex )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|number|display (1)|The index of the display, if multiple monitors are available.}}
+
{{param|number|displayindex (1)|The index of the display, if multiple monitors are available. First is 1.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|number|width|The width of the desktop.}}
 
{{param|number|width|The width of the desktop.}}
Line 18: Line 18:
  
 
     -- The window's flags contain the index of the monitor it's currently in.
 
     -- The window's flags contain the index of the monitor it's currently in.
     local desktop_w, desktop_h = love.window.getDesktopDimensions(flags.display)
+
     local width, height = love.window.getDesktopDimensions(flags.display)
  
     love.graphics.print(("display %d: %d x %d"):format(flags.display, desktop_w, desktop_h), 4, 10)
+
     love.graphics.print(("display %d: %d x %d"):format(flags.display, width, height), 4, 10)
 
end
 
end
 
</source>
 
</source>

Latest revision as of 17:46, 25 April 2023

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

Gets the width and height of the desktop.

Function

Synopsis

width, height = love.window.getDesktopDimensions( displayindex )

Arguments

number displayindex (1)
The index of the display, if multiple monitors are available. First is 1.

Returns

number width
The width of the desktop.
number height
The height of the desktop.

Examples

Show the resolution of the monitor the window is currently in

function love.draw()
    local _, _, flags = love.window.getMode()

    -- The window's flags contain the index of the monitor it's currently in.
    local width, height = love.window.getDesktopDimensions(flags.display)

    love.graphics.print(("display %d: %d x %d"):format(flags.display, width, height), 4, 10)
end

See Also

Other Languages