GetDisplayResolution
Get width and height of specified resolution index for display mode. See the options.display.resolution
registry node docs for details.
Like all UI functions, this function will only exist if draw
is defined before init
is called.
This function is not officially documented.
Arguments
- integer (number): Display mode. 0 is exclusive fullscreen, 1 is windowed, 2 is borderless windowed. Truncated if has fractional component.
- integer (number): Which resolution to use. Zero indexed. Use
GetDisplayResolutionCount
to know how many options there are. Truncated if has fractional component. Clamped if out of bounds.
Return values
- integer (number): Width in pixels.
- integer (number): Height in pixels.
Example usage
function init()
mode = 0
resolution = 0
end
local function button(label)
UiPush()
UiColor(0.75, 0.875, 1)
local pressed = UiTextButton(label)
UiPop()
UiTranslate(0, UiFontHeight())
return pressed
end
function draw()
UiFont("regular.ttf", 32)
UiTranslate(0, UiFontHeight())
if button("0 (Exclusive fullscreen)") then
mode = 0
end
if button("1 (Windowed)") then
mode = 1
end
if button("2 (Borderless windowed)") then
mode = 2
end
UiText(string.format("Mode: %d", mode), true)
for i=0, GetDisplayResolutionCount(mode)-1 do
local w, h = GetDisplayResolution(mode, i)
if button(string.format("%d (%dx%d)", i, w, h)) then
resolution = i
end
end
UiText(string.format("Resolution: %d (%dx%d)", resolution, GetDisplayResolution(mode, resolution)), true)
end