Here you go:
rem constants
#constant FullScreenID 0
#constant WindowScreenID 1
#constant ChangeResolution 1
#constant KeepResolution 0
#constant DefaultWidth 1024
#constant DefaultHeight 768
rem set window mode
SetWindowMode( FullScreenID , ChangeResolution )
rem setup screen
sync on
sync rate 60
backdrop on
rem make a 3D cube
make object cube 1,10
rem make texture
create bitmap 1,64,64
for t=0 to 1000
ink rgb(rnd(255),rnd(255),rnd(255)),0
dot rnd(63),rnd(63)
next t
get image 1,0,0,64,64
delete bitmap 1
texture object 1,1
ink 0xFFFFFFFF,0
rem main loop
do
rem text
set cursor 0,0
print "Default Width : "+str$(DefaultWidth)
print "Default Height : "+str$(DefaultHeight)
print "Current Resolution : "+str$(screen width())+"x"+str$(screen height())+"x"+str$(screen depth())
print "press space to toggle between fullscreen and window"
rem rotate cube
rotate object 1 , wrapvalue( object angle x(1) + 1) , wrapvalue( object angle y(1) + 1.5) , 0
rem toggle
if spacekey()
if toggle = 0
toggle = 1
mode = 1 - mode
if mode = 0 then SetWindowMode( FullScreenID , KeepResolution )
if mode = 1 then SetWindowMode( WindowScreenID , KeepResolution )
endif
else
toggle = 0
endif
rem refresh screen
sync
rem end of main loop
loop
rem end
end
rem da functions ----------------------------------------------------------------------------------------
function SetWindowMode( ID , resmode)
rem fullscreen
if ID = FullScreenID
set window on
set window position 0 , 0
maximize window
if resmode = ChangeResolution then SetDisplaySizeToDesktop()
set window layout 0 , 0 , 0
endif
rem window
if ID = WindowScreenID
set window on
set window position 100 , 100
set window size DefaultWidth , DefaultHeight
if resmode = ChangeResolution then set display mode DefaultWidth , DefaultHeight , 32
set window layout 1 , 1 , 1
endif
endfunction
function SetDisplaySizeToDesktop()
rem locals
local User32 as integer
local wd as integer
local ht as integer
rem load user32 dll
User32 = find free dll()
load dll "user32.dll" , User32
rem set window
wd = call dll( User32 , "GetSystemMetrics" , 0 )
ht = call dll( User32 , "GetSystemMetrics" , 1 )
wait 0
set display mode wd , ht , 32
rem clean up
if dll exist( User32 ) then delete dll User32
endfunction
Make sure to pass the
KeepResolution when using it a second time, otherwise it flushes the memory and all of your textures and images will be gone. The first time you set up the screen you are allowed to pass
ChangeResolution. What I noticed is that text gets a lot smaller when you switch from fullscreen to window... This might be interesting to try out as well:
rem constants
#constant FullScreenID 0
#constant WindowScreenID 1
#constant ChangeResolution 1
#constant KeepResolution 0
#constant DefaultWidth 1024
#constant DefaultHeight 768
rem set window mode
SetWindowMode( FullScreenID , KeepResolution )
rem setup screen
sync on
sync rate 60
backdrop on
rem make a 3D cube
make object cube 1,10
rem make texture
create bitmap 1,64,64
for t=0 to 1000
ink rgb(rnd(255),rnd(255),rnd(255)),0
dot rnd(63),rnd(63)
next t
get image 1,0,0,64,64
delete bitmap 1
texture object 1,1
ink 0xFFFFFFFF,0
rem main loop
do
rem text
set cursor 0,0
print "Default Width : "+str$(DefaultWidth)
print "Default Height : "+str$(DefaultHeight)
print "Current Resolution : "+str$(screen width())+"x"+str$(screen height())+"x"+str$(screen depth())
print "press space to toggle between fullscreen and window"
rem rotate cube
rotate object 1 , wrapvalue( object angle x(1) + 1) , wrapvalue( object angle y(1) + 1.5) , 0
rem toggle
if spacekey()
if toggle = 0
toggle = 1
mode = 1 - mode
if mode = 0 then SetWindowMode( FullScreenID , KeepResolution )
if mode = 1 then SetWindowMode( WindowScreenID , KeepResolution )
endif
else
toggle = 0
endif
rem refresh screen
sync
rem end of main loop
loop
rem end
end
rem da functions ----------------------------------------------------------------------------------------
function SetWindowMode( ID , resmode)
rem fullscreen
if ID = FullScreenID
set window on
set window position 0 , 0
maximize window
if resmode = ChangeResolution then SetDisplaySizeToDesktop()
set window layout 0 , 0 , 0
endif
rem window
if ID = WindowScreenID
set window on
set window position 100 , 100
set window size DefaultWidth , DefaultHeight
if resmode = ChangeResolution then set display mode DefaultWidth , DefaultHeight , 32
set window layout 1 , 1 , 1
endif
endfunction
function SetDisplaySizeToDesktop()
rem locals
local User32 as integer
local wd as integer
local ht as integer
rem load user32 dll
User32 = find free dll()
load dll "user32.dll" , User32
rem set window
wd = call dll( User32 , "GetSystemMetrics" , 0 )
ht = call dll( User32 , "GetSystemMetrics" , 1 )
wait 0
set display mode wd , ht , 32
rem clean up
if dll exist( User32 ) then delete dll User32
endfunction
TheComet