Microsoft DirectX 8.1 (Visual Basic)

CONST_D3DRENDERSTATETYPE

Defines device render states

Enum CONST_D3DRENDERSTATETYPE
    D3DRS_ZENABLE                  =   7
    D3DRS_FILLMODE                 =   8
    D3DRS_SHADEMODE                =   9
    D3DRS_LINEPATTERN              =  10
    D3DRS_ZWRITEENABLE             =  14
    D3DRS_ALPHATESTENABLE          =  15
    D3DRS_LASTPIXEL                =  16 (&H10)
    D3DRS_SRCBLEND                 =  19 (&H13)
    D3DRS_DESTBLEND                =  20 (&H14)
    D3DRS_CULLMODE                 =  22 (&H16)
    D3DRS_ZFUNC                    =  23 (&H17)
    D3DRS_ALPHAREF                 =  24 (&H18)
    D3DRS_ALPHAFUNC                =  25 (&H19)
    D3DRS_DITHERENABLE             =  26 (&H1A)
    D3DRS_ALPHABLENDENABLE         =  27 (&H1B)
    D3DRS_FOGENABLE                =  28 (&H1C)
    D3DRS_SPECULARENABLE           =  29 (&H1D)
    D3DRS_ZVISIBLE                 =  30 (&H1E)
    D3DRS_FOGCOLOR                 =  34 (&H22)
    D3DRS_FOGTABLEMODE             =  35 (&H23)
    D3DRS_FOGSTART                 =  36 (&H24)
    D3DRS_FOGEND                   =  37 (&H25)
    D3DRS_FOGDENSITY               =  38 (&H26)
    D3DRS_EDGEANTIALIAS            =  40 (&H28)
    D3DRS_ZBIAS                    =  47 (&H2F)
    D3DRS_RANGEFOGENABLE           =  48 (&H30)
    D3DRS_STENCILENABLE            =  52 (&H34)
    D3DRS_STENCILFAIL              =  53 (&H35)
    D3DRS_STENCILZFAIL             =  54 (&H36)
    D3DRS_STENCILPASS              =  55 (&H37)
    D3DRS_STENCILFUNC              =  56 (&H38)
    D3DRS_STENCILREF               =  57 (&H39)
    D3DRS_STENCILMASK              =  58 (&H3A)
    D3DRS_STENCILWRITEMASK         =  59 (&H3B)
    D3DRS_TEXTUREFACTOR            =  60 (&H3C)
    D3DRS_WRAP0                    = 128 (&H80)
    D3DRS_WRAP1                    = 129 (&H81)
    D3DRS_WRAP2                    = 130 (&H82)
    D3DRS_WRAP3                    = 131 (&H83)
    D3DRS_WRAP4                    = 132 (&H84)
    D3DRS_WRAP5                    = 133 (&H85)
    D3DRS_WRAP6                    = 134 (&H86)
    D3DRS_WRAP7                    = 135 (&H87)
    D3DRS_CLIPPING                 = 136 (&H88)
    D3DRS_LIGHTING                 = 137 (&H89)
    D3DRS_AMBIENT                  = 139 (&H8B)
    D3DRS_FOGVERTEXMODE            = 140 (&H8C)
    D3DRS_COLORVERTEX              = 141 (&H8D)
    D3DRS_LOCALVIEWER              = 142 (&H8E)
    D3DRS_NORMALIZENORMALS         = 143 (&H8F)
    D3DRS_DIFFUSEMATERIALSOURCE    = 145 (&H91)
    D3DRS_SPECULARMATERIALSOURCE   = 146 (&H92)
    D3DRS_AMBIENTMATERIALSOURCE    = 147 (&H93)
    D3DRS_EMISSIVEMATERIALSOURCE   = 148 (&H94)
    D3DRS_VERTEXBLEND              = 151 (&H97)
    D3DRS_CLIPPLANEENABLE          = 152 (&H98)
    D3DRS_SOFTWAREVERTEXPROCESSING = 153 (&H99)
    D3DRS_POINTSIZE                = 154 (&H9A)
    D3DRS_POINTSIZE_MIN            = 155 (&H9B)
    D3DRS_POINTSPRITEENABLE        = 156 (&H9C)
    D3DRS_POINTSCALEENABLE         = 157 (&H9D)
    D3DRS_POINTSCALE_A             = 158 (&H9E)
    D3DRS_POINTSCALE_B             = 159 (&H9F)
    D3DRS_POINTSCALE_C             = 160 (&HA0)
    D3DRS_MULTISAMPLEANTIALIAS     = 161 (&HA1)
    D3DRS_MULTISAMPLEMASK          = 162 (&HA2)
    D3DRS_PATCHEDGESTYLE           = 163 (&HA3)
    D3DRS_PATCHSEGMENTS            = 164 (&HA4)
    D3DRS_DEBUGMONITORTOKEN        = 165 (&HA5)
    D3DRS_POINTSIZE_MAX            = 166 (&HA6)
    D3DRS_INDEXVERTEXBLENDENABLE   = 167 (&HA7)
    D3DRS_COLORWRITEENABLE         = 168 (&HA8)
    D3DRS_TWEENFACTOR              = 170 (&HAA)
    D3DRS_BLENDOP                  = 171 (&HAB)
End Enum

Constants

D3DRS_ZENABLE
Depth-buffering state as one member of the CONST_D3DZBUFFERTYPE enumeration. Set this state to D3DZB_TRUE to enable z-buffering, D3DZB_USEW to enable w-buffering, or D3DZB_FALSE to disable depth buffering.

The default value for this render state is D3DZB_TRUE if a depth stencil was created along with the swap chain by setting the EnableAutoDepthStencil member of the D3DPRESENT_PARAMETERS structure to 1, and D3DZB_FALSE otherwise.

D3DRS_FILLMODE
One or more members of the CONST_D3DFILLMODE enumeration. The default value is D3DFILL_SOLID.
D3DRS_SHADEMODE
One or more members of the CONST_D3DSHADEMODE enumeration. The default value is D3DSHADE_GOURAUD.
D3DRS_LINEPATTERN
D3DLINEPATTERN type. The default values are 0 for wRepeatPattern, and 0 for wLinePattern.
D3DRS_ZWRITEENABLE
1 to enable the application to write to the depth buffer. The default value is 1. This member enables an application to prevent the system from updating the depth buffer with new depth values. If 0, depth comparisons are still made according to the render state D3DRS_ZFUNC, assuming that depth buffering is taking place, but depth values are not written to the buffer.
D3DRS_ALPHATESTENABLE
1 to enable alpha tests. The default value is 0. This member enables applications to turn off the tests that accept or reject a pixel, based on its alpha value.

The incoming alpha value is compared with the reference alpha value, using the comparison function provided by the D3DRS_ALPHAFUNC render state. When this mode is enabled, alpha blending occurs only if the test succeeds.

D3DRS_LASTPIXEL
0 to enable drawing the last pixel in a line or triangle. The default value is 1.
D3DRS_SRCBLEND
One member of the CONST_D3DBLEND enumeration. The default value is D3DBLEND_ONE.
D3DRS_DESTBLEND
One member of the CONST_D3DBLEND enumeration. The default value is D3DBLEND_ZERO.
D3DRS_CULLMODE
Specifies how back-facing triangles are culled, if at all. This can be set to one member of the CONST_D3DCULL enumerated type. The default value is D3DCULL_CCW.
D3DRS_ZFUNC
One member of the CONST_D3DCMPFUNC enumeration. The default value is D3DCMP_LESSEQUAL. This member enables an application to accept or reject a pixel, based on its distance from the camera.

The depth value of the pixel is compared with the depth-buffer value. If the depth value of the pixel passes the comparison function, the pixel is written.

The depth value is written to the depth buffer only if the render state is 1.

Software rasterizers and many hardware accelerators work faster if the depth test fails, because there is no need to filter and modulate the texture if the pixel is not going to be rendered.

D3DRS_ALPHAREF
Value specifying a reference alpha value against which pixels are tested when alpha testing is enabled. This can be a 16:16 fixed point value (D3DFIXED) ranging from 0 to 1, inclusive, where 1.0 is represented as &H00010000. The default value is 0.0.
D3DRS_ALPHAFUNC
One member of the CONST_D3DCMPFUNC enumeration. The default value is D3DCMP_ALWAYS. This member enables an application to accept or reject a pixel, based on its alpha value.
D3DRS_DITHERENABLE
1 to enable dithering. The default value is 0.
D3DRS_ALPHABLENDENABLE
1 to enable alpha-blended transparency. The default value is 0.

The type of alpha blending is determined by the D3DRS_SRCBLEND and D3DRS_DESTBLEND render states.

D3DRS_FOGENABLE
1 to enable fog blending. The default value is 0.
D3DRS_SPECULARENABLE
1 to enable specular highlights. The default value is 0.

Specular highlights are calculated as though every vertex in the object being lit were at the object's origin. This gives the expected results as long as the object is modeled around the origin and the distance from the light to the object is relatively large.

When this member is set to 1, the specular color is added to the base color after the texture cascade but before alpha blending.

D3DRS_ZVISIBLE
Not supported.
D3DRS_FOGCOLOR
Value of type Long indicating RGB color. The default value is 0.
D3DRS_FOGTABLEMODE
The fog formula to be used for pixel fog. Set to one of the members of the CONST_D3DFOGMODE enumeration. The default value is D3DFOG_NONE.
D3DRS_FOGSTART
Depth at which pixel or vertex fog effects begin for linear fog mode. The default value is 0. Depth is specified in world space for vertex fog, and either device space [0.0, 1.0] or world space for pixel fog. For pixel fog, these values are in device space when the system uses z for fog calculations, and world space when the system is using eye-relative fog (w-fog).
D3DRS_FOGEND
Depth at which pixel or vertex fog effects end for linear fog mode. The default value is 1. Depth is specified in world space for vertex fog, and either device space [0.0, 1.0] or world space for pixel fog. For pixel fog, these values are in device space when the system uses z for fog calculations, and world space when the system is using eye-relative fog (w-fog).
D3DRS_FOGDENSITY
Fog density for pixel or vertex fog used in the exponential fog modes (D3DFOG_EXP and D3DFOG_EXP2). Valid density values range from 0.0 through 1.0. The default value is 1.0.
D3DRS_EDGEANTIALIAS
1 to antialias lines forming the convex outline of objects. The default value is 0. If 1, applications should render only lines, and only to the exterior edges of polygons in a scene. The behavior is undefined if triangles or points are drawn when this render state is set. Antialiasing is performed by averaging the values of neighboring pixels. Although this is not the best way to perform antialiasing, it can be very efficient; hardware that supports this kind of operation is becoming more common.

You can enable edge antialiasing only on devices that expose the D3DPRASTERCAPS_ANTIALIASEDGES capability.

D3DRS_ZBIAS
An integer value in the range 0 to 16 that causes polygons that are physically coplanar to appear separate. Polygons with a high z-bias value will appear in front of polygons with a low value, without requiring sorting for drawing order. Polygons with a value of 1 appear in front of polygons with a value of 0, and so on. The default value is zero.
D3DRS_RANGEFOGENABLE
1 to enable range-based vertex fog. The default value is 0, in which case the system uses depth-based fog. In range-based fog, the distance of an object from the viewer is used to compute fog effects, not the depth of the object (that is, the z-coordinate) in the scene. In range-based fog, all fog methods work as usual, except that they use range instead of depth in the computations.

Range is the correct factor to use for fog computations, but depth is commonly used instead because range is expensive to compute and depth is generally already available. Using depth to calculate fog has the undesirable effect of having the fogginess of peripheral objects change as the viewer's eye moves—in this case, the depth changes, and the range remains constant.

Because no hardware currently supports per-pixel range-based fog, range correction is offered only for vertex fog.

D3DRS_STENCILENABLE
1 to enable stenciling, or 0 to disable stenciling. The default value is 0.
D3DRS_STENCILFAIL
Stencil operation to perform if the stencil test fails. This can be one member of the CONST_D3DSTENCILOP enumeration. The default value is D3DSTENCILOP_KEEP.
D3DRS_STENCILZFAIL
Stencil operation to perform if the stencil test passes and the depth test (z-test) fails. This can be one of the members of the CONST_D3DSTENCILOP enumeration. The default value is D3DSTENCILOP_KEEP.
D3DRS_STENCILPASS
Stencil operation to perform if both the stencil and the depth (z) tests pass. This can be one member of the CONST_D3DSTENCILOP enumeration. The default value is D3DSTENCILOP_KEEP.
D3DRS_STENCILFUNC
Comparison function for the stencil test. This can be one member of the CONST_D3DCMPFUNC enumeration. The default value is D3DCMP_ALWAYS.

The comparison function is used to compare the reference value to a stencil buffer entry. This comparison applies only to the bits in the reference value and stencil buffer entry that are set in the stencil mask (set by the D3DRS_STENCILMASK render state). If 1, the stencil test passes.

D3DRS_STENCILREF
Integer reference value for the stencil test. The default value is 0.
D3DRS_STENCILMASK
Mask applied to the reference value and each stencil buffer entry to determine the significant bits for the stencil test. The default mask is &HFFFFFFFF.
D3DRS_STENCILWRITEMASK
Mask applied to the reference value and each stencil buffer entry to determine the significant bits for the stencil test. The default mask is &HFFFFFFFF.
D3DRS_TEXTUREFACTOR
Color used for multiple-texture blending with the D3DTA_TFACTOR texture-blending argument or the D3DTOP_BLENDFACTORALPHA texture-blending operation. The default value is opaque white (&HFF000000).
D3DRS_WRAP0 through D3DRS_WRAP7
Texture-wrapping behavior for multiple sets of texture coordinates. Valid values for these render states can be any combination of the D3DWRAPCOORD_0 (or D3DWRAP_U), D3DWRAPCOORD_1 (or D3DWRAP_V), D3DWRAPCOORD_2 (or D3DWRAP_W), and D3DWRAPCOORD_3 flags defined by the CONST_D3DWRAPFLAGS enumeration. These cause the system to wrap in the direction of the first, second, third, and fourth dimensions, sometimes referred to at the s, t, r, and q directions, for a given texture. The default value for these render states is 0 (wrapping disabled in all directions).
D3DRS_CLIPPING
1 to enable primitive clipping by Microsoft® Direct3D®, or 0 to disable it. The default value is 1.
D3DRS_LIGHTING
1 to enable Direct3D lighting, or 0 to disable it. The default value is 1. Only vertices that include a vertex normal are properly lit; vertices that do not contain a normal employ a dot product of 0 in all lighting calculations.
D3DRS_AMBIENT
Ambient light color. The default value is 0.
D3DRS_FOGVERTEXMODE
Fog formula to be used for vertex fog. Set to one member of the CONST_D3DFOGMODE enumeration. The default value is D3DFOG_NONE. This render state is analogous to the legacy D3DLIGHTSTATE_FOGVERTEXMODE lighting state.
D3DRS_COLORVERTEX
1 to enable per-vertex color, or 0 to disable it. The default value is 1. Enabling per-vertex color allows the system to include the color defined for individual vertices in its lighting calculations.

For more information, see the following render states.

D3DRS_LOCALVIEWER
1 to enable camera-relative specular highlights, or 0 to use orthogonal specular highlights. The default value is 1. Applications that use orthogonal projection should specify 0.
D3DRS_NORMALIZENORMALS
1 to enable automatic normalization of vertex normals, or 0 to disable it. The default value is 1. Enabling this feature causes the system to normalize the vertex normals for vertices after transforming them to camera space, which can be computationally expensive.
D3DRS_DIFFUSEMATERIALSOURCE
Diffuse color source for lighting calculations. Valid values are members of the CONST_D3DMATERIALCOLORSOURCE enumeration. The default value is D3DMCS_COLOR1. The value for this render state is used only if the D3DRS_COLORVERTEX render state is set to 1.
D3DRS_SPECULARMATERIALSOURCE
Specular color source for lighting calculations. Valid values are members of the CONST_D3DMATERIALCOLORSOURCE enumeration. The default value is D3DMCS_COLOR2.
D3DRS_AMBIENTMATERIALSOURCE
Ambient color source for lighting calculations. Valid values are members of the CONST_D3DMATERIALCOLORSOURCE enumeration. The default value is D3DMCS_COLOR2.
D3DRS_EMISSIVEMATERIALSOURCE
Emissive color source for lighting calculations. Valid values are members of the CONST_D3DMATERIALCOLORSOURCE enumeration. The default value is D3DMCS_MATERIAL.
D3DRS_VERTEXBLEND
Number of matrices to use to perform geometry blending, if any. Valid values are members of the CONST_D3DVERTEXBLENDFLAGS enumeration. The default value is D3DVBF_DISABLE.
D3DRS_CLIPPLANEENABLE
Enables or disables user-defined clipping planes. Valid values are combinations of values from the CONST_D3DCLIPPLANEFLAGS enumeration. If you include a value from the enumeration, the corresponding clipping plane is enabled; if a value is not included, the clipping plane is disabled. The default value is D3DCPF_DISABLEALL.
D3DRS_SOFTWAREVERTEXPROCESSING
Value that enables applications to query and select hardware or software vertex processing. For a D3DDEVTYPE_SW device type this value is fixed to 1. This value can be set by the application for a D3DDEVTYPE_REF device type. For a D3DDEVTYPE_HAL device type, this value can be set only by the application when D3DDEVCAPS_HWTRANSFORMANDLIGHT is set; otherwise this flag is fixed to 1. When variable, the default value is 0.

Changing the vertex processing render state in mixed vertex processing mode will reset the current stream, indices, and vertex shader to their default values of ByVal 0 or 0

D3DRS_POINTSIZE
Value that specifies the size to use for point size computation in cases where point size is not specified for each vertex. This value is not used when the vertex contains point size. This value is in screen space units if D3DRS_POINTSCALEENABLE is 0; otherwise this value is in world space units. The default value is 1.0. The range for this value is greater than or equal to 0.0.
D3DRS_POINTSIZE_MIN
Value that specifies the minimum size of point primitives. Point primitives are clamped to this size during rendering. Setting this to values smaller than 1.0 results in points dropping out when the point does not cover a pixel center and antialiasing is disabled or being rendered with reduced intensity when antialiasing is enabled. The default value is 0.0. The range for this value is greater than or equal to 0.0.
D3DRS_POINTSPRITEENABLE
When 1, texture coordinates of point primitives are set so that full textures are mapped on each point. When 0, the vertex texture coordinates are used for the entire point. The default value is 0. You can achieve DirectX 7 style single-pixel points by setting D3DRS_POINTSCALEENABLE to 0 and D3DRS_POINTSIZE to 1.0, which are the default values.
D3DRS_POINTSCALEENABLE
Value that controls computation of size for point primitives. When 1, the point size is interpreted as a camera space value and is scaled by the distance function and the frustum to viewport y axis scaling to compute the final screen space point size. When 0, the point size is interpreted as screen space and used directly. The default value is 0.
D3DRS_POINTSCALE_A
Value that controls for distance-based size attenuation for point primitives. Active only when D3DRS_POINTSCALEENABLE is 1. The default value is 1.0. The range for this value is greater than or equal to 0.0.
D3DRS_POINTSCALE_B
Value that controls for distance-based size attenuation for point primitives. Active only when D3DRS_POINTSCALEENABLE is 1. The default value is 0.0. The range for this value is greater than or equal to 0.0.
D3DRS_POINTSCALE_C
Value that controls for distance-based size attenuation for point primitives. Active only when D3DRS_POINTSCALEENABLE is 1. The default value is 0.0. The range for this value is greater than or equal to 0.0.
D3DRS_MULTISAMPLEANTIALIAS
Value that determines how individual samples are computed when using a multisample render target buffer. When set to 1, the multiple samples are computed so that full-scene antialiasing is performed by sampling at different sample positions for each multiple sample. When set to 0, the multiple samples are all written with the same sample value (sampled at the pixel center), which enables non-antialiased rendering to a multisample buffer. This render state has no effect when rendering to a single sample buffer. The default value is 1.

Toggling this render state on and off in the same scene is not supported if D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE is enabled.

D3DRS_MULTISAMPLEMASK
Each bit in this mask, starting at the LSB, controls modification of one of the samples in a multisample render target. Thus, for an 8 sample render target, the low byte contains the 8 write enables for each of the 8 samples. This render state has no effect when rendering to a single sample buffer. The default value is &HFFFFFFFF.

This render state enables use of a multisample buffer as an accumulation buffer, doing multipass rendering of geometry where each pass updates a subset of samples.

This render state is not supported if D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE is enabled.

D3DRS_PATCHEDGESTYLE
Sets whether patch edges will use float-style tessellation. The default value is D3DPATCHEDGE_DISCRETE. Possible values are defined by the CONST_D3DPATCHEDGESTYLE enumerated type.
D3DRS_PATCHSEGMENTS
Number of segments per edge when drawing high-order primitives. The default value is 1.
D3DRS_DEBUGMONITORTOKEN
Set only for debugging the monitor.
D3DRS_POINTSIZE_MAX
Value that specifies the maximum size to which point sprites will be clamped. The value must be less than or equal to the MaxPointSize member of D3DCAPS8 and greater than or equal to D3DRS_POINTSIZE_MIN. The default value is 64.
D3DRS_INDEXVERTEXBLENDENABLE
When 1, enables indexed vertex blending. When 0, disables indexed vertex blending. If this render state is enabled, the user must pass matrix indices as a packed LONG with every vertex. When the render state is disabled and vertex blending is enabled through the D3DRS_VERTEXBLEND state, it is equivalent to having matrix indices 0, 1, 2, 3 in every vertex.
D3DRS_COLORWRITEENABLE
Value that enables a per-channel write for the render target color buffer. A set bit results in the color channel being updated during 3-D rendering. A clear bit results in the color channel being unaffected. This functionality is available if the D3DPMISCCAPS_COLORWRITEENABLE capabilities bit is set in the PrimitiveMiscCaps member of the D3DCAPS8 type for the device. This render state does not affect the clear operation. The default value is &H0000000F.

Valid values for this render state can be any combination of values defined by the CONST_D3DCOLORWRITEENABLEFLAGS enumeration.

D3DRS_TWEENFACTOR
Value that controls the tween factor. The default value is 0.
D3DRS_BLENDOP
Value used to select the arithmetic operation applied when the alpha blending render state, D3DRS_ALPHABLENDENABLE, is set to 1. Valid values are defined by the CONST_D3DBLENDOP enumerated type. The default value is D3DBLENDOP_ADD.

If the D3DPMISCCAPS_BLENDOP device capability is not supported, then D3DBLENDOP_ADD is performed.

Remarks

Direct3D defines the D3DRENDERSTATE_WRAPBIAS constant defined by the CONST_D3DWRAPBIAS enumeration as a convenience for applications to enable or disable texture wrapping based on the zero-based integer of a texture coordinate set (rather than explicitly using one of the D3DRS_WRAPn state values). Add the D3DRENDERSTATE_WRAPBIAS value to the zero-based index of a texture coordinate set to calculate the D3DRS_WRAPn value that corresponds to that index, as shown in the following example:

    On Local Error Resume Next
 
    ' Enable U/V wrapping for textures that use the texture
    ' coordinate set at the index within the lIndex variable.
    Call d3dDevice8.SetRenderState( _
            lIndex + D3DRENDERSTATE_WRAPBIAS, _
            D3DWRAPCOORD_0 Or D3DWRAPCOORD_1)
 
    ' If lIndex is 3, the value that results from
    ' the addition equates to D3DRENDERSTATE_WRAP3 (131).
    If Err.Number <> DD_OK Then
       ' Code to handle error goes here.
    End If