Thank you, it works.
I "merged" your suggestion with the trick to get a window borderless, so now I can get a real fullscreen, non-exclusive, with the requested REAL RESOLUTION. Furthermore in this way, even if I change Window resolution, the desktop icons are not moved.
I wish to share my final function with the community:
;========================================================================================================================
;========================================================================================================================
Procedure setResolution(argWidth, argHeight, argDepth, argFlag=#CDS_FULLSCREEN)
Protected result.b
Protected ScreenSettings.DEVMODE
;.......................................................................................
; Set Screen resolution
;
ScreenSettings\dmSize = SizeOf(DEVMODE)
ScreenSettings\dmPelsWidth = argWidth
ScreenSettings\dmPelsHeight = argHeight
ScreenSettings\dmBitsPerPel = argDepth
ScreenSettings\dmFields = #DM_PELSWIDTH|#DM_PELSHEIGHT|#DM_BITSPERPEL
If ChangeDisplaySettings_(@ScreenSettings, argFlag) = #DISP_CHANGE_SUCCESSFUL
result = #True
EndIf
;.......................................................................................
; Initialize PureBasic desktop library
;
; Set the main window as borderless
Protected win.i = OpenWindow(#PB_Any, 0, 0, argWidth, argHeight, "PureGDK", #PB_Window_BorderLess)
; Attach the PureGDK screen to the window
dbOpenScreen(WindowID(win), 0, 0, argWidth, argHeight)
; Set the display Mode
dbSetDisplayMode(argWidth, argHeight, argDepth, 0)
; Set the window to the to the top of the z-order
SetWindowPos_(WindowID(win), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOREPOSITION|#SWP_NOSIZE)
ProcedureReturn result
EndProcedure
This is a complete example you can use to test performances based on the screen resolution:
XIncludeFile "..\..\include\h.InitPureGDK.pb"
XIncludeFile "..\..\include\puregdk\core\h.PureGDK.pb"
EnableExplicit
;========================================================================================================================
;========================================================================================================================
Procedure setResolution(argWidth, argHeight, argDepth, argFlag=#CDS_FULLSCREEN)
Protected result.b
Protected ScreenSettings.DEVMODE
;.......................................................................................
; Set Screen resolution
;
ScreenSettings\dmSize = SizeOf(DEVMODE)
ScreenSettings\dmPelsWidth = argWidth
ScreenSettings\dmPelsHeight = argHeight
ScreenSettings\dmBitsPerPel = argDepth
ScreenSettings\dmFields = #DM_PELSWIDTH|#DM_PELSHEIGHT|#DM_BITSPERPEL
If ChangeDisplaySettings_(@ScreenSettings, argFlag) = #DISP_CHANGE_SUCCESSFUL
result = #True
EndIf
;.......................................................................................
; Initialize PureBasic desktop library
;
; Set the main window as borderless
Protected win.i = OpenWindow(#PB_Any, 0, 0, argWidth, argHeight, "PureGDK", #PB_Window_BorderLess)
; Attach the PureGDK screen to the window
dbOpenScreen(WindowID(win), 0, 0, argWidth, argHeight)
; Set the display Mode
dbSetDisplayMode(argWidth, argHeight, argDepth, 0)
; Set the window to the to the top of the z-order
SetWindowPos_(WindowID(win), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOREPOSITION|#SWP_NOSIZE)
ProcedureReturn result
EndProcedure
;========================================================================================================================
;========================================================================================================================
If Not InitPureGDK("gdkengine.dll", "..\..\..\..\")
Debug "Error: cannot initialize PureGDK."
End
EndIf
If setResolution(1680, 1050, 32) = #False
Debug "Error: cannot set requested resolution."
End
EndIf
;/ No FPS limit, so you can test the real FPS!
dbSyncRate(0)
;/ Create a cube
Define CubeObject.i = dbCreateObjectCube(3)
;/ Variables definitions
Define x.f
Define y.f
Define z.f
Define currentFps.s
Repeat
;/ Increment the x, y, and z variables during each loop
x.f+0.02
y.f+0.04
z.f+0.08
dbRotateObject(CubeObject, x.f, y.f, z.f)
currentFps = Str(dbScreenFps())
dbText(10, 10, currentFps)
;/ Update the screen
dbSync()
Until (WindowEvent()=#PB_Event_CloseWindow)
dbCloseScreen()
Thank you!
--Alessandro