Blitz3D+ Command Reference

GfxModeExists ( width,height,depth )

Parameters

width - width of the display mode to check for
height - height of the display mode to check for
depth - colour depth of the display mode to check for

Description

Returns true if the specified fullscreen display mode is available on the player's machine.

A sadly under-used command: check a display mode exists before calling Graphics or Graphics3D with it, instead of hard-coding a resolution the player's system may not have. If it returns false, fall back to a different mode or list what is available with CountGfxModes and GfxModeWidth/GfxModeHeight/GfxModeDepth - exiting politely with a clear message beats crashing on a bad mode.

The check applies to fullscreen modes; windowed modes just need to fit on the desktop. To additionally check that a mode is 3D-capable, use GfxMode3DExists - though on the modern DirectX 12 runtime every available mode is 3D-capable anyway.

See also: CountGfxModes, GfxModeWidth, GfxMode3DExists, GfxMode3D, Graphics3D.

Example

; GfxModeExists Example
; ---------------------

; Check whether some common display modes exist before trying to use them.
; A game should test with GfxModeExists instead of hard-coding a resolution.
Print "Checking display modes with GfxModeExists(width,height,depth):"
Print ""

CheckMode 640,480,32
CheckMode 800,600,32
CheckMode 1024,768,32
CheckMode 1920,1080,32
CheckMode 2500,2500,64

Print ""
Print "Press any key to close the example"
WaitKey

End

Function CheckMode(width,height,depth)
    If GfxModeExists(width,height,depth) Then
        Print width+" x "+height+" x "+depth+"  - available"
    Else
        Print width+" x "+height+" x "+depth+"  - not available"
    EndIf
End Function

Index