D3DRENDERSTATETYPE

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;

Members

D3DRENDERSTATE_TEXTUREHANDLE

Texture handle. The default value is NULL, which disables texture mapping and reverts to flat or Gouraud shading.

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.

D3DRENDERSTATE_ANTIALIAS

One of the members of the D3DANTIALIASMODE enumerated type specifying the antialiasing of primitive edges. The default value is D3DANTIALIAS_NONE.

D3DRENDERSTATE_TEXTUREADDRESS

One of the members of the D3DTEXTUREADDRESS enumerated type. The default value is D3DTADDRESS_WRAP.

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.

D3DRENDERSTATE_TEXTUREPERSPECTIVE

TRUE for perspective correction. The default value is FALSE.

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.

D3DRENDERSTATE_WRAPU

TRUE for wrapping in u direction. The default value is FALSE.

D3DRENDERSTATE_WRAPV

TRUE for wrapping in v direction. The default value is FALSE.

D3DRENDERSTATE_ZENABLE

TRUE to enable the z-buffer comparison test when writing to the frame buffer. The default value is FALSE.

D3DRENDERSTATE_FILLMODE

One or more members of the D3DFILLMODE enumerated type. The default value is D3DFILL_SOLID.

D3DRENDERSTATE_SHADEMODE

One or more members of the D3DSHADEMODE enumerated type. The default value is D3DSHADE_GOURAUD.

D3DRENDERSTATE_LINEPATTERN

The D3DLINEPATTERN structure. The default values are 0 for wRepeatPattern and 0 for wLinePattern.

D3DRENDERSTATE_MONOENABLE

TRUE to enable monochromatic rendering, using a grayscale based on the blue channel of the color rather than full RGB. The default value is FALSE. If the device does not support RGB rendering, the value will be TRUE. Applications can check whether the device supports RGB rendering by using the dcmColorModel member of the D3DDEVICEDESC structure.

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.

D3DRENDERSTATE_ROP2

One of the 16 standard Windows ROP2 binary raster operations specifying how the supplied pixels are combined with the pixels of the display surface. The default value is R2_COPYPEN. Applications can use the D3DPRASTERCAPS_ROP2 flag in the dwRasterCaps member of the D3DPRIMCAPS structure to determine whether additional raster operations are supported.

D3DRENDERSTATE_PLANEMASK

Physical plane mask whose type is ULONG. The default value is the bitwise negation of zero (~0). This physical plane mask can be used to turn off the red bit, the blue bit, and so on.

D3DRENDERSTATE_ZWRITEENABLE

TRUE to enable z writes. The default value is TRUE. This member enables an application to prevent the system from updating the z-buffer with new z values. If this state is FALSE, z comparisons are still made according to the render state D3DRENDERSTATE_ZFUNC (assuming z-buffering is taking place), but z values are not written to the z-buffer.

D3DRENDERSTATE_ALPHATESTENABLE

TRUE to enable alpha tests. The default value is FALSE. This member enables applications to turn off the tests that otherwise would 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 D3DRENDERSTATE_ALPHAFUNC render state. When this mode is enabled, alpha blending occurs only if the test succeeds.

D3DRENDERSTATE_LASTPIXEL

TRUE to prevent drawing the last pixel in a line or triangle. The default value is FALSE.

D3DRENDERSTATE_TEXTUREMAG

One of the members of the D3DTEXTUREFILTER enumerated type. This render state describes how a texture should be filtered when it is being magnified (that is, when a texel must cover more than one pixel). The valid values are D3DFILTER_NEAREST (the default) and D3DFILTER_LINEAR.

D3DRENDERSTATE_TEXTUREMIN

One of the members of the D3DTEXTUREFILTER enumerated type. This render state describes how a texture should be filtered when it is being made smaller (that is, when a pixel contains more than one texel). Any of the members of the D3DTEXTUREFILTER enumerated type can be specified for this render state. The default value is D3DFILTER_NEAREST.

D3DRENDERSTATE_SRCBLEND

One of the members of the D3DBLEND enumerated type. The default value is D3DBLEND_ONE.

D3DRENDERSTATE_DESTBLEND

One of the members of the D3DBLEND enumerated type. The default value is D3DBLEND_ZERO.

D3DRENDERSTATE_TEXTUREMAPBLEND

One of the members of the D3DTEXTUREBLEND enumerated type. The default value is D3DTBLEND_MODULATE.

D3DRENDERSTATE_CULLMODE

One of the members of the D3DCULL enumerated type. The default value is D3DCULL_CCW. Software renderers have a fixed culling order and do not support changing the culling mode.

D3DRENDERSTATE_ZFUNC

One of the members of the D3DCMPFUNC enumerated type. 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 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.

D3DRENDERSTATE_ALPHAREF

Value specifying a reference alpha value against which pixels are tested when alpha-testing is enabled. This value's type is D3DFIXED. It is a 16.16 fixed-point value in the range [0 - 1]. The default value is 0.

D3DRENDERSTATE_ALPHAFUNC

One of the members of the D3DCMPFUNC enumerated type. The default value is D3DCMP_ALWAYS. This member enables an application to accept or reject a pixel based on its alpha value.

D3DRENDERSTATE_DITHERENABLE

TRUE to enable dithering. The default value is FALSE.

D3DRENDERSTATE_BLENDENABLE

Replaced by the D3DRENDERSTATE_ALPHABLENDENABLE render state for DirectX 5.

D3DRENDERSTATE_FOGENABLE

TRUE to enable fog. The default value is FALSE.

D3DRENDERSTATE_SPECULARENABLE

TRUE to enable specular highlights. The default value is TRUE.

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.

D3DRENDERSTATE_ZVISIBLE

TRUE to enable z-checking. The default value is FALSE. Z-checking is a culling technique in which a polygon representing the screen space of an entire group of polygons is tested against the z-buffer to discover whether any of the polygons should be drawn.

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.

D3DRENDERSTATE_SUBPIXEL

TRUE to enable subpixel correction. The default value is FALSE.

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).

D3DRENDERSTATE_SUBPIXELX

TRUE to enable subpixel correction in the x direction only. The default value is FALSE.

D3DRENDERSTATE_STIPPLEDALPHA

TRUE to enable stippled alpha. The default value is FALSE.

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.

D3DRENDERSTATE_FOGCOLOR

Value whose type is D3DCOLOR. The default value is 0.

D3DRENDERSTATE_FOGTABLEMODE

One of the members of the D3DFOGMODE enumerated type. The default value is D3DFOG_NONE.

D3DRENDERSTATE_FOGTABLESTART

Position in fog table at which fog effects begin for linear fog mode. You specify a position in the fog table with a value between 0.0 and 1.0. This render state enables you to exclude fog effects for positions close to the camera; for example, you could set this value to 0.3 to prevent fog effects for positions between 0.0 and 0.299.

D3DRENDERSTATE_FOGTABLEEND

Position in fog table at which fog effects end for linear fog mode. You specify a position in the fog table with a value between 0.0 and 1.0. This render state enables you to set a position in the fog table at which fog effects will not increase. For example, you could set this value to 0.7 to prevent additional fog effects for positions between 0.701 and 1.0.

D3DRENDERSTATE_FOGTABLEDENSITY

Sets the maximum fog density for linear fog mode. This value can range from 0 to 1.

D3DRENDERSTATE_STIPPLEENABLE

Enables stippling in the device driver. When stippled alpha is enabled, it overrides the current stipple pattern, as specified by the D3DRENDERSTATE_STIPPLEPATTERN00 through D3DRENDERSTATE_STIPPLEPATTERN31 render states. When stippled alpha is disabled, the stipple pattern must be returned.

D3DRENDERSTATE_EDGEANTIALIAS

TRUE to antialias lines forming the convex outline of objects. The default value is FALSE. When set to TRUE, only lines should be drawn. The behavior is undefined if triangles or points are drawn when this render state is set. Antialiasing is performed simply 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.

Applications should not antialias interior edges of objects. The lines forming the outside edges should be drawn last.

D3DRENDERSTATE_COLORKEYENABLE

TRUE to enable color-keyed transparency. The default value is FALSE. You can use this render state with D3DRENDERSTATE_ALPHABLENDENABLE to implement fine blending control.

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.

D3DRENDERSTATE_ALPHABLENDENABLE

TRUE to enable alpha-blended transparency. The default value is FALSE.

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.

D3DRENDERSTATE_BORDERCOLOR

A DWORD value specifying a border color. If the texture addressing mode is specified as D3DTADDRESS_BORDER (as set in the D3DTEXTUREADDRESS enumerated type), this render state specifies the border color the system uses when it encounters texture coordinates outside the range [0.0, 1.0].

The format of the physical-color information specified by the DWORD value depends on the format of the DirectDraw surface.

D3DRENDERSTATE_TEXTUREADDRESSU

One of the members of the D3DTEXTUREADDRESS enumerated type. The default value is D3DTADDRESS_WRAP. 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.

D3DRENDERSTATE_TEXTUREADDRESSV

One of the members of the D3DTEXTUREADDRESS enumerated type. The default value is D3DTADDRESS_WRAP. 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.

D3DRENDERSTATE_MIPMAPLODBIAS

Floating-point D3DVALUE value used to change the level of detail (LOD) bias. This value offsets the value of the mipmap level that is computed by trilinear texturing. It is usually in the range -1.0 to 1.0; the default value is 0.0.

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.

D3DRENDERSTATE_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. For details, see Working With Z-Buffers.

D3DRENDERSTATE_RANGEFOGENABLE

TRUE to enable range-based fog. (The default value is FALSE, 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 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.

D3DRENDERSTATE_ANISOTROPY

Integer value that enables a degree of anisotropic filtering. (This is 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.

D3DRENDERSTATE_STIPPLEPATTERN00 through D3DRENDERSTATE_STIPPLEPATTERN31

Stipple pattern. Each render state applies to a separate line of the stipple pattern. Together, these render states specify a 32x32 stipple pattern.

D3DRENDERSTATE_FORCE_DWORD

Forces this enumerated type to be 32 bits in size.

QuickInfo

  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.

See Also

D3DOPCODE, D3DSTATE