The D3DRENDERSTATETYPE enumerated type describes the render state for the D3DOP_STATERENDER opcode. This enumerated type is part of the D3DSTATE structure. The values mentioned in the following descriptions are set in the second member of this structure.
Values 40 through 49 were introduced with DirectX 5.0.
typedef enum _D3DRENDERSTATETYPE {
D3DRENDERSTATE_TEXTUREHANDLE = 1, // texture handle
D3DRENDERSTATE_ANTIALIAS = 2, // antialiasing mode
D3DRENDERSTATE_TEXTUREADDRESS = 3, // texture address
D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, // perspective correction
D3DRENDERSTATE_WRAPU = 5, // wrap in u direction
D3DRENDERSTATE_WRAPV = 6, // wrap in v direction
D3DRENDERSTATE_ZENABLE = 7, // enable z test
D3DRENDERSTATE_FILLMODE = 8, // fill mode
D3DRENDERSTATE_SHADEMODE = 9, // shade mode
D3DRENDERSTATE_LINEPATTERN = 10, // line pattern
D3DRENDERSTATE_MONOENABLE = 11, // enable mono rendering
D3DRENDERSTATE_ROP2 = 12, // raster operation
D3DRENDERSTATE_PLANEMASK = 13, // physical plane mask
D3DRENDERSTATE_ZWRITEENABLE = 14, // enable z writes
D3DRENDERSTATE_ALPHATESTENABLE = 15, // enable alpha tests
D3DRENDERSTATE_LASTPIXEL = 16, // draw last pixel in a line
D3DRENDERSTATE_TEXTUREMAG = 17, // how textures are magnified
D3DRENDERSTATE_TEXTUREMIN = 18, // how textures are reduced
D3DRENDERSTATE_SRCBLEND = 19, // blend factor for source
D3DRENDERSTATE_DESTBLEND = 20, // blend factor for destination
D3DRENDERSTATE_TEXTUREMAPBLEND = 21, // blend mode for map
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_SUBPIXEL = 31, // enable subpixel correction
D3DRENDERSTATE_SUBPIXELX = 32, // enable x subpixel correction
D3DRENDERSTATE_STIPPLEDALPHA = 33, // enable stippled alpha
D3DRENDERSTATE_FOGCOLOR = 34, // fog color
D3DRENDERSTATE_FOGTABLEMODE = 35, // fog mode
D3DRENDERSTATE_FOGTABLESTART = 36, // fog table start
D3DRENDERSTATE_FOGTABLEEND = 37, // fog table end
D3DRENDERSTATE_FOGTABLEDENSITY = 38, // fog density
D3DRENDERSTATE_STIPPLEENABLE = 39, // enables stippling
D3DRENDERSTATE_EDGEANTIALIAS = 40, // antialias edges
D3DRENDERSTATE_COLORKEYENABLE = 41, // enable color-key transparency
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_ZBIAS = 47, // z-bias
D3DRENDERSTATE_RANGEFOGENABLE = 48, // enables range-based fog
D3DRENDERSTATE_ANISOTROPY = 49, // max. anisotropy
D3DRENDERSTATE_FLUSHBATCH = 50, // explicit flush for DP batching (DX5 Only)
D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, // enable sort-independent transparency
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_STIPPLEPATTERN00 = 64, // first line of stipple pattern
// Stipple patterns 01 through 30 omitted here.
D3DRENDERSTATE_STIPPLEPATTERN31 = 95, // last line of stipple pattern
D3DRENDERSTATE_WRAP0 = 128, // wrapping flags for first texture
// Wrap renderstates 1 through 6 omitted here.
D3DRENDERSTATE_WRAP7 = 135, // wrapping flags for last texture
D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff,
} D3DRENDERSTATETYPE;
If the specified texture is in a system memory surface and the driver can only support texturing from display memory surfaces, the call will fail.
In retail builds the texture handle is not validated.
You can only enable full-scene antialiasing on devices that expose the D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT or D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT capabilities.
Applications that need to specify separate texture-addressing modes for the u and v coordinates of a texture can use the D3DRENDERSTATE_TEXTUREADDRESSU and D3DRENDERSTATE_TEXTUREADDRESSV render states.
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.
In monochromatic rendering, only the intensity (gray scale) component of the color and specular components are interpolated across the triangle. This means that only one channel (gray) is interpolated across the triangle instead of 3 channels (R,G,B), which is a performance gain for some hardware. This gray-scale component is derived from the blue channel of the color and specular components of the triangle.
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.
One of the members of the D3DTEXTUREBLEND enumerated type. The default value is D3DTBLEND_MODULATE.
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, you can 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 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 may 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 D3DDEVICEDESC 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.
Subpixel correction is the ability to draw pixels in precisely their correct locations. In a system that implemented subpixel correction, if a pixel were at position 0.1356, its position would be interpolated from the actual coordinate rather than simply drawn at 0 (using the integer values). Hardware can be non-subpixel correct or subpixel correct in x or in both x and y. When interpolating across the x-direction the actual coordinate is used. All hardware should be subpixel correct. Some software rasterizers are not subpixel correct because of the performance loss.
Subpixel correction means that the hardware always pre-steps the interpolant values in the x-direction to the nearest pixel centers and then steps one pixel at a time in the y-direction. For each x span it also pre-steps in the x-direction to the nearest pixel center and then steps in the x-direction one pixel each time. This results in very accurate rendering and eliminates almost all jittering of pixels on triangle edges. Most hardware either doesn't support it (always off) or always supports it (always on).
Current software rasterizers ignore this render state. You can use the D3DPSHADECAPS_ALPHAFLATSTIPPLED flag in the D3DPRIMCAPS structure to discover whether the current hardware supports this render state.
These render states enable you to exclude fog effects for positions close to the camera. For example, you could set the starting depth to 0.3 to prevent fog effects for depths between 0.0 and 0.299, and the ending depth to 0.7 to prevent additional fog effects for depths between 0.701 and 1.0.
You can only enable edge antialiasing on devices that expose the D3DPRASTERCAPS_ANTIALIASEDGES capability.
Applications should check the D3DDEVCAPS_DRAWPRIMTLVERTEX flag in the D3DDEVICEDESC 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 will be affected. Surfaces that were created without the DDSD_CKSRCBLT flag will exhibit color-keyed transparency effects.
The format of the physical-color information specified by the DWORD value depends on the format of the DirectDraw surface.
This render state applies only to the u texture coordinate. This render state, along with D3DRENDERSTATE_TEXTUREADDRESSV, allows you to specify separate texture-addressing modes for the u and v coordinates of a texture. Because the D3DRENDERSTATE_TEXTUREADDRESS render state applies to both the u and v texture coordinates, it overrides any values set for the D3DRENDERSTATE_TEXTUREADDRESSU render state.
This render state applies only to the v texture coordinate. This render state, along with D3DRENDERSTATE_TEXTUREADDRESSU, allows you to specify separate texture-addressing modes for the u and v coordinates of a texture. Because the D3DRENDERSTATE_TEXTUREADDRESS render state applies to both the u and v texture coordinates, it overrides any values set for the D3DRENDERSTATE_TEXTUREADDRESSV render state.
Each unit bias (+/-1.0) biases the selection by exactly one mipmap level. A positive bias will cause the use of larger mipmap levels, resulting in a sharper but more aliased image. A negative bias will cause the use of smaller mipmap levels, resulting in a blurrier image. Applying a negative bias also results in the referencing of a smaller amount of texture data, which can boost performance on some systems.
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 eye is rotated — in this case, the depth changes while 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 offered only for vertex fog. For more information, see Range-based Fog and Vertex Fog.
This render state can be an integer value that enables a degree of anisotropic filtering, used for bilinear or trilinear filtering. The value determines the maximum aspect ratio of the sampling filter kernel. To determine the range of appropriate values, use the D3DPRASTERCAPS_ANISOTROPY flag in the D3DPRIMCAPS structure.
Anisotropy is the distortion visible in the texels of a 3-D object whose surface is oriented at an angle with respect to the plane of the screen. The anisotropy is measured as the elongation (length divided by width) of a screen pixel that is inverse-mapped into texture space.
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 the comparison is true, the stencil test passes.
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 legacy 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_U | D3DWRAPV);
// If dwIndex is 3, the value that results from
// the addition equates to D3DRENDERSTATE_WRAP3 (131).
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.
Header: Declared in d3dtypes.h.