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.
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_BLENDENABLE = 27, // replaced by D3DRENDERSTATE_ALPHABLENDENABLE
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_ALPHABLENDENABLE = 42, // enable alpha-blend 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_STIPPLEPATTERN00 = 64, // first line of stipple pattern
// Stipple patterns 01 through 30 omitted here.
D3DRENDERSTATE_STIPPLEPATTERN31 = 95, // last line of stipple pattern
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.
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.
If a square were exactly perpendicular to the viewer, all the points in the square would appear the same. But if the square were tilted with respect to the viewer so that one edge was closer than the other, one side would appear to be longer than the other. Perspective correction ensures that the interpolation of texture coordinates happens correctly in such cases.
In monochromatic rendering, only the intensity (grayscale) 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 grayscale 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.
The z value of the pixel is compared with the z-buffer value. If the z value of the pixel passes the comparison function, the pixel is written.
The z value is written to the z-buffer only if the render state D3DRENDERSTATE_ZWRITEENABLE is TRUE.
Software rasterizers and many hardware accelerators work faster if the z test fails, since there is no need to filter and modulate the texture if the pixel is not going to be rendered.
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.
In this mode of operation, the primitives are rendered without writing pixels or updating the z-buffer, and the driver returns TRUE if any of them would be visible. Since no pixels are rendered, this operation is often much faster than it would be if the primitives were naively rendered.
Direct3D's retained mode uses this operation as a quick-reject test: it does the z-visible test on the bounding box of a set of primitives and only renders them if it returns TRUE.
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.
Applications should not antialias interior edges of objects. The lines forming the outside edges should be drawn last.
This render state was introduced in DirectX 5. Applications should check the D3DDEVCAPS_DRAWPRIMTLVERTEX flag in the D3DDEVICEDESC structure to find out whether this render state is supported.
Prior to DirectX 5, this render state was called D3DRENDERSTATE_BLENDENABLE. Its name was changed to make its meaning more explicit.
Prior to DirectX 5, the software rasterizers used this render state to toggle both color keying and alpha blending. With DirectX 5, you should 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.
The format of the physical-color information specified by the DWORD value depends on the format of the DirectDraw surface.
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, 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 is calculated at vertices.
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.
Windows NT: Use version 4.0 or later.
Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
Windows CE: Unsupported.
Header: Declared in d3dtypes.h.