Skip to content

BRL.DXGraphics Tweak

Kevin Primm edited this page Jun 22, 2015 · 4 revisions

In order for the Direct3D9 driver to properly work, the following code needs to be added into "OpenD3DDevice" function of brl.mod/dxgraphics.mod/d3d9graphics.bmx after pp:D3DPRESENT_PARAMETERS is defined.

Function CheckDepthFormat(format)
    Return _d3d.CheckDeviceFormat(0,D3DDEVTYPE_HAL,D3DFMT_X8R8G8B8,D3DUSAGE_DEPTHSTENCIL,D3DRTYPE_SURFACE,format)=D3D_OK
End Function

If flags&GRAPHICS_DEPTHBUFFER Or flags&GRAPHICS_STENCILBUFFER 
    pp.EnableAutoDepthStencil = True
    If flags&GRAPHICS_STENCILBUFFER 
        If Not CheckDepthFormat( D3DFMT_D24S8 )
            If Not CheckDepthFormat( D3DFMT_D24FS8 )
                If Not CheckDepthFormat( D3DFMT_D24X4S4 )
                    If Not CheckDepthFormat( D3DFMT_D15S1 )
                        Return False
                    Else
                        pp.AutoDepthStencilFormat = D3DFMT_D15S1
                    EndIf
                Else
                    pp.AutoDepthStencilFormat = D3DFMT_D24X4S4
                EndIf
            Else
                pp.AutoDepthStencilFormat = D3DFMT_D24FS8
            EndIf
        Else
            pp.AutoDepthStencilFormat = D3DFMT_D24S8
        EndIf
    Else
        If Not CheckDepthFormat( D3DFMT_D32 )
            If Not CheckDepthFormat( D3DFMT_D24X8 )
                If Not CheckDepthFormat( D3DFMT_D16 )
                    Return False
                Else
                    pp.AutoDepthStencilFormat = D3DFMT_D16
                EndIf
            Else
                pp.AutoDepthStencilFormat = D3DFMT_D24X8
            EndIf
        Else
            pp.AutoDepthStencilFormat = D3DFMT_D32
        EndIf
    EndIf
EndIf

Clone this wiki locally