| Platform SDK: DirectX |
The D3DRENDERSTATETYPE enumerated type defines device render states that are set and retrieved through the IDirect3DDevice7::SetRenderState and IDirect3DDevice7::GetRenderState methods.
typedef enum _D3DRENDERSTATETYPE {
D3DRENDERSTATE_ANTIALIAS = 2, //Antialiasing mode
D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, //Perspective correction
D3DRENDERSTATE_ZENABLE = 7, //Enable z test
D3DRENDERSTATE_FILLMODE = 8, //Fill mode
D3DRENDERSTATE_SHADEMODE = 9, //Shade mode
D3DRENDERSTATE_LINEPATTERN = 10, //Line pattern
D3DRENDERSTATE_ZWRITEENABLE = 14, //Enable z writes
D3DRENDERSTATE_ALPHATESTENABLE = 15, //Enable alpha tests
D3DRENDERSTATE_LASTPIXEL = 16, //Draw last pixel in a line
D3DRENDERSTATE_SRCBLEND = 19, //Blend factor for source
D3DRENDERSTATE_DESTBLEND = 20, //Blend factor for destination
D3DRENDERSTATE_CULLMODE = 22, //Back-face culling mode
D3DRENDERSTATE_ZFUNC = 23, //Z-comparison function
D3DRENDERSTATE_ALPHAREF = 24, //Reference alpha value
D3DRENDERSTATE_ALPHAFUNC = 25, //Alpha-comparison function
D3DRENDERSTATE_DITHERENABLE = 26, //Enable dithering
D3DRENDERSTATE_ALPHABLENDENABLE = 27, //Enable alpha blending
D3DRENDERSTATE_FOGENABLE = 28, //Enable fog
D3DRENDERSTATE_SPECULARENABLE = 29, //Enable specular highlights
D3DRENDERSTATE_ZVISIBLE = 30, //Enable z-checking
D3DRENDERSTATE_STIPPLEDALPHA = 33, //Enable stippled alpha
D3DRENDERSTATE_FOGCOLOR = 34, //Fog color
D3DRENDERSTATE_FOGTABLEMODE = 35, //Fog mode
D3DRENDERSTATE_FOGTABLESTART = 36, //Fog table start (same as D3DRENDERSTATE_FOGSTART)
D3DRENDERSTATE_FOGTABLEEND = 37, //Fog table end (same as D3DRENDERSTATE_FOGEND)
D3DRENDERSTATE_FOGTABLEDENSITY = 38, //Fog table density (same as D3DRENDERSTATE_FOGDENSITY)
D3DRENDERSTATE_FOGSTART = 36, //Fog start (for both vertex and pixel fog)
D3DRENDERSTATE_FOGEND = 37, //Fog end (for both vertex and pixel fog)
D3DRENDERSTATE_FOGDENSITY = 38, //Fog density (for both vertex and pixel fog)
D3DRENDERSTATE_EDGEANTIALIAS = 40, //Antialias edges
D3DRENDERSTATE_COLORKEYENABLE = 41, //Enable color-key transparency
D3DRENDERSTATE_ZBIAS = 47, //Z-bias
D3DRENDERSTATE_RANGEFOGENABLE = 48, //Enables range-based fog
D3DRENDERSTATE_STENCILENABLE = 52, //Enable or disable stenciling
D3DRENDERSTATE_STENCILFAIL = 53, //Stencil operation
D3DRENDERSTATE_STENCILZFAIL = 54, //Stencil operation
D3DRENDERSTATE_STENCILPASS = 55, //Stencil operation
D3DRENDERSTATE_STENCILFUNC = 56, //Stencil comparison function
D3DRENDERSTATE_STENCILREF = 57, //Reference value for stencil test
D3DRENDERSTATE_STENCILMASK = 58, //Mask value used in stencil test
D3DRENDERSTATE_STENCILWRITEMASK = 59, //Stencil buffer write mask
D3DRENDERSTATE_TEXTUREFACTOR = 60, //Texture factor
D3DRENDERSTATE_WRAP0 = 128, //Wrap flags for 1st texture coord set
// Wrap render states 1 through 6 omitted here.
D3DRENDERSTATE_WRAP7 = 135, //Wrap flags for last texture coord set
D3DRENDERSTATE_CLIPPING = 136, //Enable or disable primitive clipping
D3DRENDERSTATE_LIGHTING = 137, //Enable or disable lighting
D3DRENDERSTATE_EXTENTS = 138, //Enable or disable updating screen extents
D3DRENDERSTATE_AMBIENT = 139, //Ambient color for scene
D3DRENDERSTATE_FOGVERTEXMODE = 140, //Fog mode for vertex fog
D3DRENDERSTATE_COLORVERTEX = 141, //Enable or disable per-vertex color
D3DRENDERSTATE_LOCALVIEWER = 142, //Enable or disable perspective specular highlights
D3DRENDERSTATE_NORMALIZENORMALS = 143, //Enable automatic normalization of vertex normals
D3DRENDERSTATE_COLORKEYBLENDENABLE = 144, //Enable or disable alpha-blended color keying
D3DRENDERSTATE_DIFFUSEMATERIALSOURCE = 145, //Location for per-vertex diffuse color
D3DRENDERSTATE_SPECULARMATERIALSOURCE = 146, //Location for per-vertex specular color
D3DRENDERSTATE_AMBIENTMATERIALSOURCE = 147, //Location for per-vertex ambient color
D3DRENDERSTATE_EMISSIVEMATERIALSOURCE = 148, //Location for per-vertex emissive color
D3DRENDERSTATE_VERTEXBLEND = 151, //Multi-matrix vertex blending mode
D3DRENDERSTATE_CLIPPLANEENABLE = 152, //Enable one or more user-defined clipping planes
D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff,
} D3DRENDERSTATETYPE;
You can only enable full-scene antialiasing on devices that expose the D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT or D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT capabilities.
The default value for this render state is D3DZB_TRUE if a depth buffer is attached to the render-target surface, and D3DZB_FALSE otherwise.
The incoming alpha value is compared with the reference alpha value, using the comparison function provided by the D3DRENDERSTATE_ALPHAFUNC render state. When this mode is enabled, alpha blending occurs only if the test succeeds.
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 TRUE.
Software rasterizers and many hardware accelerators work faster if the depth test fails, since there is no need to filter and modulate the texture if the pixel is not going to be rendered.
Prior to DirectX 5.0, the software rasterizers used this render state to toggle both color keying and alpha blending. Currently, use the D3DRENDERSTATE_COLORKEYENABLE render state to toggle color keying. (Hardware rasterizers have always used the D3DRENDERSTATE_BLENDENABLE render state only for toggling alpha blending.)
The type of alpha blending is determined by the D3DRENDERSTATE_SRCBLEND and D3DRENDERSTATE_DESTBLEND render states. D3DRENDERSTATE_ALPHABLENDENABLE, with D3DRENDERSTATE_COLORKEYENABLE, allows fine blending control.
D3DRENDERSTATE_ALPHABLENDENABLE does not affect the texture-blending modes specified by the D3DTEXTUREBLEND enumerated type. Texture blending is logically done well before the D3DRENDERSTATE_ALPHABLENDENABLE part of the pixel pipeline. The only interaction between the two is that the alpha portions remaining in the polygon after the D3DTEXTUREBLEND phase can be used in the D3DRENDERSTATE_ALPHABLENDENABLE phase to govern interaction with the content in the frame buffer.
Applications should check the D3DDEVCAPS_DRAWPRIMTLVERTEX flag in the D3DDEVICEDESC7 structure to find out whether this render state is supported.
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 TRUE, the specular color is added to the base color after the texture cascade but before alpha blending.
Current software rasterizers ignore this render state. Use the D3DPSHADECAPS_ALPHAFLATSTIPPLED flag in the D3DPRIMCAPS structure to discover whether the current hardware supports this render state.
Values for this render state are floating-point values. Because the IDirect3DDevice7::SetRenderState and IDirect3DDevice7::SetRenderState accept DWORD values, your application must cast a variable that contains the value, as shown in the following code example.
lpd3dDevice->SetRenderState( D3DRENDERSTATE_FOGSTART, *((LPDWORD) (&fFogStart)) );
Values for this render state are floating-point values.Because the IDirect3DDevice7::SetRenderState and IDirect3DDevice7::SetRenderState accept DWORD values, your application must cast a variable that contains the value, as shown in the following code example.
lpd3dDevice->SetRenderState( D3DRENDERSTATE_FOGEND, *((LPDWORD) (&fFogEnd)) );
Values for this render state are floating-point values.Because the IDirect3DDevice7::SetRenderState and IDirect3DDevice7::SetRenderState accept DWORD values, your application must cast a variable that contains the value, as shown in the following code example.
lpd3dDevice->SetRenderState( D3DRENDERSTATE_FOGDENSITY, *((LPDWORD) (&fFogDensity)) );
You can only enable edge antialiasing on devices that expose the D3DPRASTERCAPS_ANTIALIASEDGES capability.
Applications should check the D3DDEVCAPS_DRAWPRIMTLVERTEX flag in the D3DDEVICEDESC7 structure to find out whether this render state is supported.
When color-keyed transparency is enabled, only texture surfaces that were created with the DDSD_CKSRCBLT flag are affected. Surfaces that were created without the DDSD_CKSRCBLT flag exhibit color-keyed transparency effects.
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.
This render state works only with D3DVERTEX vertices. When you specify D3DLVERTEX or D3DTLVERTEX vertices, the F (fog) component of the RGBF fog value should already be corrected for range.
Since no hardware currently supports per-pixel range-based fog, range correction is offered only for vertex fog. For more information, see Range-based Fog and Vertex Fog.
The comparison function is used to compare the reference value to a stencil buffer entry. This comparison only applies to the bits in the reference value and stencil buffer entry that are set in the stencil mask (set by the D3DRENDERSTATE_STENCILMASK render state). If TRUE, the stencil test passes.
For more information, see the following render states:
The D3DCLIPPLANEn macros are declared in the D3dtypes.h header file to provide a convenient way to enable clipping planes.
The D3DRENDERSTATE_BLENDENABLE member was superseded by the D3DRENDERSTATE_ALPHABLENDENABLE member. Its name was changed to make its meaning more explicit. To maintain compatibility with previous applications, the D3DRENDERSTATE_BLENDENABLE constant is declared as equivalent to D3DRENDERSTATE_ALPHABLENDENABLE:
#define D3DRENDERSTATE_BLENDENABLE D3DRENDERSTATE_ALPHABLENDENABLE
Direct3D defines the D3DRENDERSTATE_WRAPBIAS constant 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 D3DRENDERSTATE_WRAPn state values). Add the D3DRENDERSTATE_WRAPBIAS value to the zero-based index of a texture coordinate set to calculate the D3DRENDERSTATE_WRAPn value that corresponds to that index, as shown in the following example:
// Enable U/V wrapping for textures that use the texture
// coordinate set at the index within the dwIndex variable.
HRESULT hr = lpD3DDevice->SetRenderState(
dwIndex + D3DRENDERSTATE_WRAPBIAS,
D3DWRAP_0 | D3DWRAP1);
// If dwIndex is 3, the value that results from
// the addition equals D3DRENDERSTATE_WRAP3 (131).
The declaration of D3DRENDERSTATETYPE in D3dtypes.h contains legacy render states not supported by DirectX 7.0 interfaces. For more information, see Obsolete Render States.
D3DRENDERSTATE_TEXTUREHANDLE = 1, //Texture handle
D3DRENDERSTATE_TEXTUREADDRESS = 3, //Texture address
D3DRENDERSTATE_WRAPU = 5, //Wrap in u direction
D3DRENDERSTATE_WRAPV = 6, //Wrap in v direction
D3DRENDERSTATE_MONOENABLE = 11, //Enable mono rendering
D3DRENDERSTATE_ROP2 = 12, //Raster operation
D3DRENDERSTATE_PLANEMASK = 13, //Physical plane mask
D3DRENDERSTATE_TEXTUREMAG = 17, //Superseded
D3DRENDERSTATE_TEXTUREMIN = 18, //Superseded
D3DRENDERSTATE_TEXTUREMAPBLEND = 21, //Blend mode for map
D3DRENDERSTATE_SUBPIXEL = 31, //Enable subpixel correction
D3DRENDERSTATE_SUBPIXELX = 32, //Enable x subpixel correction
D3DRENDERSTATE_STIPPLEENABLE = 39, //Enable stippling
D3DRENDERSTATE_BORDERCOLOR = 43, //Border color
D3DRENDERSTATE_TEXTUREADDRESSU = 44, //U texture address mode
D3DRENDERSTATE_TEXTUREADDRESSV = 45, //V texture address mode
D3DRENDERSTATE_MIPMAPLODBIAS = 46, //Mipmap LOD bias
D3DRENDERSTATE_ANISOTROPY = 49, //Maximum anisotropy
D3DRENDERSTATE_FLUSHBATCH = 50, //Explicit flush for DP batching (DX5 Only)
D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, //Enable sort-independent transparency
D3DRENDERSTATE_STIPPLEPATTERN00 = 64, //First line of stipple pattern
// Stipple patterns 01 through 30 omitted here.
D3DRENDERSTATE_STIPPLEPATTERN31 = 95, //Last line of stipple pattern
Windows NT/2000: Requires Windows NT 4.0 SP3 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Version: Requires DirectX 2.0 or later.
Header: Declared in d3dtypes.h.
IDirect3DDevice7::SetRenderState, IDirect3DDevice7::GetRenderState, Render States