So now here is an update as requested
The short overview of the new functions.
EnumDesktopModes()
Before the other DesktopModes commands can be executed,
EnumDesktopModes must be done at least once.
This lists all resolution modes internally.
However, this is limited to 32 bit colour depth.
These can be retrieved with the commands GetDesktopModeWidth,GetDesktopModeHeight,GetDesktopModeFrequency and GetDesktopModeJSON.
The return value is the number of modes that were found.
All following commands can only be called if
EnumDesktopModes has been called at least once before.
GetDesktopModeWidth(Integer mode)
Returns the width in pixels of the resolution from the specified mode.
GetDesktopModeHeight(Integer mode)
Returns the height in pixels of the resolution of the specified mode.
GetDesktopModeFrequency(Integer mode)
Returns the screen refresh rate of the resolution from the specified mode.
GetDesktopModeJSON(Integer mode)
Returns the width, height, bits per pixel and screen refresh rate in the form of a JSON string.
GetDesktopMode(Integer width, Integer height)
This command is used to find out which mode is best suited to the specified resolution.
GetDesktopMode()
Returns the mode that matches the current resolution set.
SetDesktopMode(Integer mode)
Sets the specified mode. The desktop resolution is set according to the mode.
RestoreDesktopMode()
Restores the desktop resolution according to the registry.
I hope this is what was wanted.
Here is a small example with which I have tested it.
// Project: DesktopModes
// Created: 2023-04-25
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "DesktopModes" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
#import_plugin FileExplore as fe
count = fe.EnumDesktopModes()
mode = fe.GetDesktopMode(1920,1080)
fe.SetDesktopMode(mode)
SetWindowSize(fe.GetDesktopModeWidth(mode),fe.GetDesktopModeHeight(mode),1)
SetVirtualResolution( fe.GetDesktopModeWidth(mode),fe.GetDesktopModeHeight(mode) )
do
if GetRawKeyState(27) > 0 then exit
print(count)
for i=0 to count
if(fe.GetDesktopModeWidth(i) = 1366)
print(fe.GetDesktopModeJSON(i))
endif
next i
print("")
Print(fe.getDesktopModeJSON(mode))
Print( ScreenFPS() )
Sync()
loop
fe.RestoreDesktopMode()
See first post for download.