Microsoft DirectX 8.0 (Visual Basic) |
Use the following steps to enable pixel fog in your application.
To enable pixel fog in a Visual Basic application
The following example shows what these steps might look like in code.
' For brevity, error values in this example are not checked ' after each call. A real-world application should check ' these values appropriately. ' ' For the purposes of this example, d3dDevice is a valid ' reference to a Direct3DDevice8 object. Sub SetupPixelFog(Color As Long, Mode As CONST_D3DFOGMODE) Dim StartFog As Single, _ EndFog As Single, _ Density As Single ' For linear mode StartFog = 0.5: EndFog = 0.8 ' For exponential mode Density = 0.66 ' Enable fog blending. Call d3dDevice.SetRenderState(D3DRS_FOGENABLE, True) ' Set the fog color. Call d3dDevice.SetRenderState(D3DRS_FOGCOLOR, Color) ' Set fog parameters. If Mode = D3DFOG_LINEAR Then Call d3dDevice.SetRenderState(D3DRS_FOGTABLEMODE, Mode) Call d3dDevice.SetRenderState(D3DRS_FOGSTART, StartFog) Call d3dDevice.SetRenderState(D3DRS_FOGEND, EndFog) Else Call d3dDevice.SetRenderState(D3DRS_FOGTABLEMODE, Mode) Call d3dDevice.SetRenderState(D3DRS_FOGDENSITY, Density) End If End Sub