Hi Everyone This is for PGDK 1.11-4.31 I have yet to get it to work on PGDK 2.0b as dbsetdisplaymode is not there or maybe it was me
Any how I would like to get it working with PGDK 2.0b an upwards but without dbsetdisplaymode to set the Vsync and MultiSampling-AntiAliasing, if I am wrong Please Correct me on this
Declare dbSetResolution(Width, Height, Depth, Flag=#CDS_FULLSCREEN)
Declare dbCheckDisplayMode(Width, Height, Depth)
Global DesktopX.l=0, DesktopY.l=0, DesktopWidth.l=0, DesktopHeight.l=0, BDesktopWidth.l=0, BDesktopHeight.l=0
Global _RezWidth.l=1024, _RezHeight.l=768, _RefreshRate.l=60, _ColorDepth.l=32
Global _Antialias_Flag.l=#True, _Vsync_Flag.l=#True, MonitorFrequency.b=0
Global _Window=#True, Quit.l=#False, Version.s="Hello World!"
Global _Flags=#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
Macro Init_Anisotropic()
;{ ---> Initialise
CompilerIf #PB_Compiler_Debugger
CompilerElse
#D3DSAMP_MAGFILTER=5 ;/ D3DTEXTUREFILTER filter to use for magnification
#D3DSAMP_MINFILTER=6 ;/ D3DTEXTUREFILTER filter to use for minification
#D3DSAMP_MIPFILTER=7 ;/ D3DTEXTUREFILTER filter to use between mipmaps during minification
#D3DSAMP_MIPMAPLODBIAS=8 ;/ Float mipmap LOD bias
#D3DSAMP_MAXMIPLEVEL=9 ;/ DWORD 0..(n-1) LOD index of largest map to use (0==largest)
#D3DSAMP_MAXANISOTROPY=10;/ DWORD maximum anisotropy
#D3DTEXF_NONE=0 ;/ Filtering disabled (valid for mip filter only)
#D3DTEXF_POINT=1 ;/ Nearest
#D3DTEXF_LINEAR=2 ;/ Linear interpolation
#D3DTEXF_ANISOTROPIC=3 ;/ Anisotropic
#D3DTEXF_PYRAMIDALQUAD=6 ;/ 4-sample tent
#D3DTEXF_GAUSSIANQUAD=7 ;/ 4-sample gaussian
;}
;/ Get the D3D render device
Lib=OpenLibrary(#PB_Any,"DBProSetupDebug.dll")
Ptr=GetFunction(Lib,"?GetDirect3DDevice@@YAPAUIDirect3DDevice9@@XZ")
*IDirect3DDevice9.IDirect3DDevice9=CallFunctionFast(Ptr)
CompilerEndIf
EndMacro
Macro Anisotropic(Object, AnisoLevel)
CompilerIf #PB_Compiler_Debugger
If _Anisotropic_Flag=#True
dbSetObjectFilter(Object,2) ; 0=Point, 1=Linear Filtering, 2=Anisotropic <-- Adjust Filter Here
dbSetObjectTexture(Object,0,2,0) ; MipMap Mode --> 0=None, 1=Point, 2=Linear <-- Do Not Adjust This Lines Values...
EndIf
CompilerElse
If _Anisotropic_Flag=#True
dbSetObjectFilter(Object,2) ; 0=Point, 1=Linear Filtering, 2=Anisotropic <-- Adjust Filter Here
dbSetObjectTexture(Object,0,2,0) ; MipMap Mode --> 0=None, 1=Point, 2=Linear <-- Do Not Adjust This Lines Values...
*IDirect3DDevice9\SetSamplerState(Object,#D3DSAMP_MINFILTER,#D3DTEXF_ANISOTROPIC)
*IDirect3DDevice9\SetSamplerState(Object,#D3DSAMP_MAXANISOTROPY,AnisoLevel)
EndIf
CompilerEndIf
EndMacro
ExamineDesktops()
InitKeyboard()
Init_Anisotropic()
_RezWidth=1440
_RezHeight=900
_Window=#True
;{ <-- FullScreen Mode
If dbCheckDisplayMode(_RezWidth, _RezHeight, _ColorDepth)=#True And _Window=#False
;/ Show the PureGDK render window
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), Version.s, #PB_Window_BorderLess)
hDBWnd=OpenDBWnd(WindowID(0), 0, 0, _RezWidth, _RezHeight)
dbSetDisplayMode(_RezWidth, _RezHeight, _Vsync_Flag, _Antialias_Flag.l, 0) ; Reload all of your assets after this command...
MoveWindow_(hDBWnd, 0, 0, DesktopWidth(0), DesktopHeight(0), 1)
;/ Set the window to the to the top of the z-order
dbSetWindowSize(DesktopWidth(0), DesktopHeight(0))
EndIf
;}
;{ <-- Windowed Mode
If _Window=#True
;{ <-- Get The Window Area Size
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @DesktopRect.RECT, 0)
DesktopX = DesktopRect\left
DesktopY = DesktopRect\top
DesktopWidth = DesktopRect\right - DesktopRect\left
DesktopHeight = DesktopRect\bottom - DesktopRect\top
BDesktopWidth = DesktopWidth-GetSystemMetrics_(#SM_CXFIXEDFRAME)*2
BDesktopHeight = DesktopHeight-(GetSystemMetrics_(#SM_CYCAPTION)+GetSystemMetrics_(#SM_CYFIXEDFRAME)*2)
;}
OpenWindow(0, DesktopX, DesktopY, BDesktopWidth, BDesktopHeight-50,Version.s,_Flags)
;/ Initialize the PureGDK screen As a child of window ID 0
hDBWnd=OpenDBWnd(WindowID(0), DesktopX, DesktopY, DesktopWidth-1, DesktopHeight-1)
dbSetDisplayMode(_RezWidth, _RezHeight, _Vsync_Flag, _Antialias_Flag, 0) ; Reload all of your assets after this command...
SetWindowPos_(WindowID(0),#HWND_TOPMOST, DesktopX, DesktopY, DesktopWidth, DesktopHeight,#SWP_NOREPOSITION) ; Resize Main Window
MoveWindow_(hDBWnd, 0, 0, BDesktopWidth, BDesktopHeight,1) ; PGDK Render Window Size
EndIf
;}
; MonitorFrequency.b=DesktopFrequency(0)
; dbSyncRate(MonitorFrequency.b)
dbSyncRate(_RefreshRate)
Anisotropic(1,4)
dbMakeObjectCube(1,10)
;/ Rotate the cube and update the screen
Repeat
x.f+0.2: y.f+0.4: z.f+0.8
Anisotropic(1,4)
dbRotateObject(1,x.f,y.f,z.f)
dbText(10,10,"Width="+Str(_RezWidth)+" : Height="+Str(_RezHeight)+" : Color Depth="+Str(_ColorDepth))
dbText(10,30,"Frame Rate="+Str(dbScreenFPS()+1))
dbSync()
Repeat
ExamineKeyboard()
Event=WindowEvent()
If Event=#PB_Event_CloseWindow
End
EndIf
Until Event=0
If KeyboardPushed(#PB_Key_All)=#True
Quit=#True
EndIf
Until Quit=#True ;And KeyboardReleased(#PB_Key_All)=#True
End
; <--- Set Resolution(Width, Height, Depth, Flag)
Procedure dbSetResolution(Width, Height, Depth, Flag=#CDS_FULLSCREEN)
Protected Result,dmScreenSettings.DEVMODE
dmScreenSettings\dmSize=SizeOf(DEVMODE)
dmScreenSettings\dmPelsWidth=Width
dmScreenSettings\dmPelsHeight=Height
dmScreenSettings\dmBitsPerPel=Depth
dmScreenSettings\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT|#DM_BITSPERPEL
If ChangeDisplaySettings_(@dmScreenSettings, Flag)=#DISP_CHANGE_SUCCESSFUL
Result=#True
EndIf
ProcedureReturn Result
EndProcedure
Procedure dbCheckDisplayMode(Width, Height, Depth)
Protected i.w, Result.w
;/ Check if Display Mode Exists
While EnumDisplaySettings_(0,i.w,@DevMode.DEVMODE) And Result.w=0
If (DevMode\dmPelsWidth)=Width And (DevMode\dmPelsHeight)=Height And (DevMode\dmBitsPerPel)=Depth : Result=#True
Else
Result=#False
EndIf
i+1
Wend
ProcedureReturn Result
EndProcedure
Regards
Kevin