diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CBurningShader_Raster_Reference.cpp | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CBurningShader_Raster_Reference.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CBurningShader_Raster_Reference.cpp | 2286 |
1 files changed, 1143 insertions, 1143 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CBurningShader_Raster_Reference.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CBurningShader_Raster_Reference.cpp index dccdab6..35c006d 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CBurningShader_Raster_Reference.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CBurningShader_Raster_Reference.cpp | |||
@@ -1,1143 +1,1143 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #include "IrrCompileConfig.h" | 5 | #include "IrrCompileConfig.h" |
6 | #include "IBurningShader.h" | 6 | #include "IBurningShader.h" |
7 | 7 | ||
8 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 8 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ |
9 | 9 | ||
10 | 10 | ||
11 | namespace irr | 11 | namespace irr |
12 | { | 12 | { |
13 | 13 | ||
14 | namespace video | 14 | namespace video |
15 | { | 15 | { |
16 | 16 | ||
17 | /*! Render states define set-up states for all kinds of vertex and pixel processing. | 17 | /*! Render states define set-up states for all kinds of vertex and pixel processing. |
18 | Some render states set up vertex processing, and some set up pixel processing (see Render States). | 18 | Some render states set up vertex processing, and some set up pixel processing (see Render States). |
19 | Render states can be saved and restored using stateblocks (see State Blocks Save and Restore State). | 19 | Render states can be saved and restored using stateblocks (see State Blocks Save and Restore State). |
20 | */ | 20 | */ |
21 | enum BD3DRENDERSTATETYPE | 21 | enum BD3DRENDERSTATETYPE |
22 | { | 22 | { |
23 | /*! BD3DRS_ZENABLE | 23 | /*! BD3DRS_ZENABLE |
24 | Depth-buffering state as one member of the BD3DZBUFFERTYPE enumerated type. | 24 | Depth-buffering state as one member of the BD3DZBUFFERTYPE enumerated type. |
25 | Set this state to D3DZB_TRUE to enable z-buffering, | 25 | Set this state to D3DZB_TRUE to enable z-buffering, |
26 | D3DZB_USEW to enable w-buffering, or D3DZB_FALSE to disable depth buffering. | 26 | D3DZB_USEW to enable w-buffering, or D3DZB_FALSE to disable depth buffering. |
27 | The default value for this render state is D3DZB_TRUE if a depth stencil was created | 27 | The default value for this render state is D3DZB_TRUE if a depth stencil was created |
28 | along with the swap chain by setting the EnableAutoDepthStencil member of the | 28 | along with the swap chain by setting the EnableAutoDepthStencil member of the |
29 | D3DPRESENT_PARAMETERS structure to TRUE, and D3DZB_FALSE otherwise. | 29 | D3DPRESENT_PARAMETERS structure to TRUE, and D3DZB_FALSE otherwise. |
30 | */ | 30 | */ |
31 | BD3DRS_ZENABLE, | 31 | BD3DRS_ZENABLE, |
32 | 32 | ||
33 | /*! BD3DRS_FILLMODE | 33 | /*! BD3DRS_FILLMODE |
34 | One or more members of the D3DFILLMODE enumerated type. The default value is D3DFILL_SOLID. | 34 | One or more members of the D3DFILLMODE enumerated type. The default value is D3DFILL_SOLID. |
35 | */ | 35 | */ |
36 | BD3DRS_FILLMODE, | 36 | BD3DRS_FILLMODE, |
37 | 37 | ||
38 | /*! BD3DRS_SHADEMODE | 38 | /*! BD3DRS_SHADEMODE |
39 | One or more members of the D3DSHADEMODE enumerated type. The default value is D3DSHADE_GOURAUD. | 39 | One or more members of the D3DSHADEMODE enumerated type. The default value is D3DSHADE_GOURAUD. |
40 | */ | 40 | */ |
41 | BD3DRS_SHADEMODE, | 41 | BD3DRS_SHADEMODE, |
42 | 42 | ||
43 | /*! BD3DRS_ZWRITEENABLE | 43 | /*! BD3DRS_ZWRITEENABLE |
44 | TRUE to enable the application to write to the depth buffer. The default value is TRUE. | 44 | TRUE to enable the application to write to the depth buffer. The default value is TRUE. |
45 | This member enables an application to prevent the system from updating the depth buffer with | 45 | This member enables an application to prevent the system from updating the depth buffer with |
46 | new depth values. If FALSE, depth comparisons are still made according to the render state | 46 | new depth values. If FALSE, depth comparisons are still made according to the render state |
47 | D3DRS_ZFUNC, assuming that depth buffering is taking place, but depth values are not written | 47 | D3DRS_ZFUNC, assuming that depth buffering is taking place, but depth values are not written |
48 | to the buffer. | 48 | to the buffer. |
49 | */ | 49 | */ |
50 | BD3DRS_ZWRITEENABLE, | 50 | BD3DRS_ZWRITEENABLE, |
51 | 51 | ||
52 | /*! BD3DRS_ALPHATESTENABLE | 52 | /*! BD3DRS_ALPHATESTENABLE |
53 | TRUE to enable per pixel alpha testing. If the test passes, the pixel is processed by the frame | 53 | TRUE to enable per pixel alpha testing. If the test passes, the pixel is processed by the frame |
54 | buffer. Otherwise, all frame-buffer processing is skipped for the pixel. The test is done by | 54 | buffer. Otherwise, all frame-buffer processing is skipped for the pixel. The test is done by |
55 | comparing the incoming alpha value with the reference alpha value, using the comparison function | 55 | comparing the incoming alpha value with the reference alpha value, using the comparison function |
56 | provided by the D3DRS_ALPHAFUNC render state. The reference alpha value is determined by the value | 56 | provided by the D3DRS_ALPHAFUNC render state. The reference alpha value is determined by the value |
57 | set for D3DRS_ALPHAREF. For more information, see Alpha Testing State. | 57 | set for D3DRS_ALPHAREF. For more information, see Alpha Testing State. |
58 | The default value of this parameter is FALSE. | 58 | The default value of this parameter is FALSE. |
59 | */ | 59 | */ |
60 | BD3DRS_ALPHATESTENABLE, | 60 | BD3DRS_ALPHATESTENABLE, |
61 | 61 | ||
62 | /*! BD3DRS_SRCBLEND | 62 | /*! BD3DRS_SRCBLEND |
63 | One member of the BD3DBLEND enumerated type. The default value is BD3DBLEND_ONE. | 63 | One member of the BD3DBLEND enumerated type. The default value is BD3DBLEND_ONE. |
64 | */ | 64 | */ |
65 | BD3DRS_SRCBLEND, | 65 | BD3DRS_SRCBLEND, |
66 | 66 | ||
67 | /*! BD3DRS_DESTBLEND | 67 | /*! BD3DRS_DESTBLEND |
68 | One member of the BD3DBLEND enumerated type. The default value is BD3DBLEND_ZERO. | 68 | One member of the BD3DBLEND enumerated type. The default value is BD3DBLEND_ZERO. |
69 | */ | 69 | */ |
70 | BD3DRS_DESTBLEND, | 70 | BD3DRS_DESTBLEND, |
71 | 71 | ||
72 | /*! BD3DRS_CULLMODE | 72 | /*! BD3DRS_CULLMODE |
73 | Specifies how back-facing triangles are culled, if at all. This can be set to one | 73 | Specifies how back-facing triangles are culled, if at all. This can be set to one |
74 | member of the BD3DCULL enumerated type. The default value is BD3DCULL_CCW. | 74 | member of the BD3DCULL enumerated type. The default value is BD3DCULL_CCW. |
75 | */ | 75 | */ |
76 | BD3DRS_CULLMODE, | 76 | BD3DRS_CULLMODE, |
77 | 77 | ||
78 | /*! BD3DRS_ZFUNC | 78 | /*! BD3DRS_ZFUNC |
79 | One member of the BD3DCMPFUNC enumerated type. The default value is BD3DCMP_LESSEQUAL. | 79 | One member of the BD3DCMPFUNC enumerated type. The default value is BD3DCMP_LESSEQUAL. |
80 | This member enables an application to accept or reject a pixel, based on its distance from | 80 | This member enables an application to accept or reject a pixel, based on its distance from |
81 | the camera. The depth value of the pixel is compared with the depth-buffer value. If the depth | 81 | the camera. The depth value of the pixel is compared with the depth-buffer value. If the depth |
82 | value of the pixel passes the comparison function, the pixel is written. | 82 | value of the pixel passes the comparison function, the pixel is written. |
83 | 83 | ||
84 | The depth value is written to the depth buffer only if the render state is TRUE. | 84 | The depth value is written to the depth buffer only if the render state is TRUE. |
85 | Software rasterizers and many hardware accelerators work faster if the depth test fails, | 85 | Software rasterizers and many hardware accelerators work faster if the depth test fails, |
86 | because there is no need to filter and modulate the texture if the pixel is not going to be | 86 | because there is no need to filter and modulate the texture if the pixel is not going to be |
87 | rendered. | 87 | rendered. |
88 | */ | 88 | */ |
89 | BD3DRS_ZFUNC, | 89 | BD3DRS_ZFUNC, |
90 | 90 | ||
91 | /*! BD3DRS_ALPHAREF | 91 | /*! BD3DRS_ALPHAREF |
92 | Value that specifies a reference alpha value against which pixels are tested when alpha testing | 92 | Value that specifies a reference alpha value against which pixels are tested when alpha testing |
93 | is enabled. This is an 8-bit value placed in the low 8 bits of the DWORD render-state value. | 93 | is enabled. This is an 8-bit value placed in the low 8 bits of the DWORD render-state value. |
94 | Values can range from 0x00000000 through 0x000000FF. The default value is 0. | 94 | Values can range from 0x00000000 through 0x000000FF. The default value is 0. |
95 | */ | 95 | */ |
96 | BD3DRS_ALPHAREF, | 96 | BD3DRS_ALPHAREF, |
97 | 97 | ||
98 | /*! BD3DRS_ALPHAFUNC | 98 | /*! BD3DRS_ALPHAFUNC |
99 | One member of the BD3DCMPFUNC enumerated type. The default value is BD3DCMP_ALWAYS. | 99 | One member of the BD3DCMPFUNC enumerated type. The default value is BD3DCMP_ALWAYS. |
100 | This member enables an application to accept or reject a pixel, based on its alpha value. | 100 | This member enables an application to accept or reject a pixel, based on its alpha value. |
101 | */ | 101 | */ |
102 | BD3DRS_ALPHAFUNC, | 102 | BD3DRS_ALPHAFUNC, |
103 | 103 | ||
104 | /*! BD3DRS_DITHERENABLE | 104 | /*! BD3DRS_DITHERENABLE |
105 | TRUE to enable dithering. The default value is FALSE. | 105 | TRUE to enable dithering. The default value is FALSE. |
106 | */ | 106 | */ |
107 | BD3DRS_DITHERENABLE, | 107 | BD3DRS_DITHERENABLE, |
108 | 108 | ||
109 | /*! BD3DRS_ALPHABLENDENABLE | 109 | /*! BD3DRS_ALPHABLENDENABLE |
110 | TRUE to enable alpha-blended transparency. The default value is FALSE. | 110 | TRUE to enable alpha-blended transparency. The default value is FALSE. |
111 | The type of alpha blending is determined by the BD3DRS_SRCBLEND and BD3DRS_DESTBLEND render states. | 111 | The type of alpha blending is determined by the BD3DRS_SRCBLEND and BD3DRS_DESTBLEND render states. |
112 | */ | 112 | */ |
113 | BD3DRS_ALPHABLENDENABLE, | 113 | BD3DRS_ALPHABLENDENABLE, |
114 | 114 | ||
115 | /*! BD3DRS_FOGENABLE | 115 | /*! BD3DRS_FOGENABLE |
116 | TRUE to enable fog blending. The default value is FALSE. For more information about using fog | 116 | TRUE to enable fog blending. The default value is FALSE. For more information about using fog |
117 | blending, see Fog. | 117 | blending, see Fog. |
118 | */ | 118 | */ |
119 | BD3DRS_FOGENABLE, | 119 | BD3DRS_FOGENABLE, |
120 | 120 | ||
121 | /*! BD3DRS_SPECULARENABLE | 121 | /*! BD3DRS_SPECULARENABLE |
122 | TRUE to enable specular highlights. The default value is FALSE. | 122 | TRUE to enable specular highlights. The default value is FALSE. |
123 | Specular highlights are calculated as though every vertex in the object being lit is at the | 123 | Specular highlights are calculated as though every vertex in the object being lit is at the |
124 | object's origin. This gives the expected results as long as the object is modeled around the | 124 | object's origin. This gives the expected results as long as the object is modeled around the |
125 | origin and the distance from the light to the object is relatively large. In other cases, the | 125 | origin and the distance from the light to the object is relatively large. In other cases, the |
126 | results as undefined. | 126 | results as undefined. |
127 | When this member is set to TRUE, the specular color is added to the base color after the | 127 | When this member is set to TRUE, the specular color is added to the base color after the |
128 | texture cascade but before alpha blending. | 128 | texture cascade but before alpha blending. |
129 | */ | 129 | */ |
130 | BD3DRS_SPECULARENABLE, | 130 | BD3DRS_SPECULARENABLE, |
131 | 131 | ||
132 | /*! BD3DRS_FOGCOLOR | 132 | /*! BD3DRS_FOGCOLOR |
133 | Value whose type is D3DCOLOR. The default value is 0. For more information about fog color, | 133 | Value whose type is D3DCOLOR. The default value is 0. For more information about fog color, |
134 | see Fog Color. | 134 | see Fog Color. |
135 | */ | 135 | */ |
136 | BD3DRS_FOGCOLOR, | 136 | BD3DRS_FOGCOLOR, |
137 | 137 | ||
138 | /*! BD3DRS_FOGTABLEMODE | 138 | /*! BD3DRS_FOGTABLEMODE |
139 | The fog formula to be used for pixel fog. Set to one of the members of the D3DFOGMODE | 139 | The fog formula to be used for pixel fog. Set to one of the members of the D3DFOGMODE |
140 | enumerated type. The default value is D3DFOG_NONE. For more information about pixel fog, | 140 | enumerated type. The default value is D3DFOG_NONE. For more information about pixel fog, |
141 | see Pixel Fog. | 141 | see Pixel Fog. |
142 | */ | 142 | */ |
143 | BD3DRS_FOGTABLEMODE, | 143 | BD3DRS_FOGTABLEMODE, |
144 | 144 | ||
145 | /*! BD3DRS_FOGSTART | 145 | /*! BD3DRS_FOGSTART |
146 | Depth at which pixel or vertex fog effects begin for linear fog mode. The default value is 0.0f. | 146 | Depth at which pixel or vertex fog effects begin for linear fog mode. The default value is 0.0f. |
147 | Depth is specified in world space for vertex fog and either device space [0.0, 1.0] or world | 147 | Depth is specified in world space for vertex fog and either device space [0.0, 1.0] or world |
148 | space for pixel fog. For pixel fog, these values are in device space when the system uses z for | 148 | space for pixel fog. For pixel fog, these values are in device space when the system uses z for |
149 | fog calculations and world-world space when the system is using eye-relative fog (w-fog). For | 149 | fog calculations and world-world space when the system is using eye-relative fog (w-fog). For |
150 | more information, see Fog Parameters and Eye-Relative vs. Z-based Depth. | 150 | more information, see Fog Parameters and Eye-Relative vs. Z-based Depth. |
151 | Values for the this render state are floating-point values. | 151 | Values for the this render state are floating-point values. |
152 | Because the IDirect3DDevice9::SetRenderState method accepts DWORD values, your | 152 | Because the IDirect3DDevice9::SetRenderState method accepts DWORD values, your |
153 | application must cast a variable that contains the value, as shown in the following code example. | 153 | application must cast a variable that contains the value, as shown in the following code example. |
154 | pDevice9->SetRenderState( BD3DRS_FOGSTART, *((DWORD*) (&fFogStart))); | 154 | pDevice9->SetRenderState( BD3DRS_FOGSTART, *((DWORD*) (&fFogStart))); |
155 | */ | 155 | */ |
156 | BD3DRS_FOGSTART, | 156 | BD3DRS_FOGSTART, |
157 | 157 | ||
158 | /*! BD3DRS_FOGEND | 158 | /*! BD3DRS_FOGEND |
159 | Depth at which pixel or vertex fog effects end for linear fog mode. The default value is 1.0f. | 159 | Depth at which pixel or vertex fog effects end for linear fog mode. The default value is 1.0f. |
160 | Depth is specified in world space for vertex fog and either device space [0.0, 1.0] or world space | 160 | Depth is specified in world space for vertex fog and either device space [0.0, 1.0] or world space |
161 | for pixel fog. For pixel fog, these values are in device space when the system uses z for fog | 161 | for pixel fog. For pixel fog, these values are in device space when the system uses z for fog |
162 | calculations and in world space when the system is using eye-relative fog (w-fog). For more | 162 | calculations and in world space when the system is using eye-relative fog (w-fog). For more |
163 | information, see Fog Parameters and Eye-Relative vs. Z-based Depth. | 163 | information, see Fog Parameters and Eye-Relative vs. Z-based Depth. |
164 | Values for this render state are floating-point values. | 164 | Values for this render state are floating-point values. |
165 | */ | 165 | */ |
166 | BD3DRS_FOGEND, | 166 | BD3DRS_FOGEND, |
167 | 167 | ||
168 | /*! BD3DRS_FOGDENSITY | 168 | /*! BD3DRS_FOGDENSITY |
169 | Fog density for pixel or vertex fog used in the exponential fog modes (D3DFOG_EXP and D3DFOG_EXP2). | 169 | Fog density for pixel or vertex fog used in the exponential fog modes (D3DFOG_EXP and D3DFOG_EXP2). |
170 | Valid density values range from 0.0 through 1.0. The default value is 1.0. For more information, | 170 | Valid density values range from 0.0 through 1.0. The default value is 1.0. For more information, |
171 | see Fog Parameters. | 171 | see Fog Parameters. |
172 | Values for this render state are floating-point values. | 172 | Values for this render state are floating-point values. |
173 | */ | 173 | */ |
174 | BD3DRS_FOGDENSITY, | 174 | BD3DRS_FOGDENSITY, |
175 | 175 | ||
176 | 176 | ||
177 | /*! BD3DRS_RANGEFOGENABLE | 177 | /*! BD3DRS_RANGEFOGENABLE |
178 | TRUE to enable range-based vertex fog. The default value is FALSE, in which case the system | 178 | TRUE to enable range-based vertex fog. The default value is FALSE, in which case the system |
179 | uses depth-based fog. In range-based fog, the distance of an object from the viewer is used | 179 | uses depth-based fog. In range-based fog, the distance of an object from the viewer is used |
180 | to compute fog effects, not the depth of the object (that is, the z-coordinate) in the scene. | 180 | to compute fog effects, not the depth of the object (that is, the z-coordinate) in the scene. |
181 | In range-based fog, all fog methods work as usual, except that they use range instead of depth | 181 | In range-based fog, all fog methods work as usual, except that they use range instead of depth |
182 | in the computations. | 182 | in the computations. |
183 | Range is the correct factor to use for fog computations, but depth is commonly used instead | 183 | Range is the correct factor to use for fog computations, but depth is commonly used instead |
184 | because range is time-consuming to compute and depth is generally already available. Using depth | 184 | because range is time-consuming to compute and depth is generally already available. Using depth |
185 | to calculate fog has the undesirable effect of having the fogginess of peripheral objects change | 185 | to calculate fog has the undesirable effect of having the fogginess of peripheral objects change |
186 | as the viewer's eye moves - in this case, the depth changes and the range remains constant. | 186 | as the viewer's eye moves - in this case, the depth changes and the range remains constant. |
187 | 187 | ||
188 | Because no hardware currently supports per-pixel range-based fog, range correction is offered | 188 | Because no hardware currently supports per-pixel range-based fog, range correction is offered |
189 | only for vertex fog. | 189 | only for vertex fog. |
190 | For more information, see Vertex Fog. | 190 | For more information, see Vertex Fog. |
191 | */ | 191 | */ |
192 | BD3DRS_RANGEFOGENABLE = 48, | 192 | BD3DRS_RANGEFOGENABLE = 48, |
193 | 193 | ||
194 | /*! BD3DRS_STENCILENABLE | 194 | /*! BD3DRS_STENCILENABLE |
195 | TRUE to enable stenciling, or FALSE to disable stenciling. The default value is FALSE. | 195 | TRUE to enable stenciling, or FALSE to disable stenciling. The default value is FALSE. |
196 | For more information, see Stencil Buffer Techniques. | 196 | For more information, see Stencil Buffer Techniques. |
197 | */ | 197 | */ |
198 | BD3DRS_STENCILENABLE = 52, | 198 | BD3DRS_STENCILENABLE = 52, |
199 | 199 | ||
200 | /*! BD3DRS_STENCILFAIL | 200 | /*! BD3DRS_STENCILFAIL |
201 | Stencil operation to perform if the stencil test fails. Values are from the D3DSTENCILOP | 201 | Stencil operation to perform if the stencil test fails. Values are from the D3DSTENCILOP |
202 | enumerated type. The default value is D3DSTENCILOP_KEEP. | 202 | enumerated type. The default value is D3DSTENCILOP_KEEP. |
203 | */ | 203 | */ |
204 | BD3DRS_STENCILFAIL = 53, | 204 | BD3DRS_STENCILFAIL = 53, |
205 | 205 | ||
206 | /*! BD3DRS_STENCILZFAIL | 206 | /*! BD3DRS_STENCILZFAIL |
207 | Stencil operation to perform if the stencil test passes and the depth test (z-test) fails. | 207 | Stencil operation to perform if the stencil test passes and the depth test (z-test) fails. |
208 | Values are from the D3DSTENCILOP enumerated type. The default value is D3DSTENCILOP_KEEP. | 208 | Values are from the D3DSTENCILOP enumerated type. The default value is D3DSTENCILOP_KEEP. |
209 | */ | 209 | */ |
210 | BD3DRS_STENCILZFAIL = 54, | 210 | BD3DRS_STENCILZFAIL = 54, |
211 | 211 | ||
212 | /*! BD3DRS_STENCILPASS | 212 | /*! BD3DRS_STENCILPASS |
213 | Stencil operation to perform if both the stencil and the depth (z) tests pass. Values are | 213 | Stencil operation to perform if both the stencil and the depth (z) tests pass. Values are |
214 | from the D3DSTENCILOP enumerated type. The default value is D3DSTENCILOP_KEEP. | 214 | from the D3DSTENCILOP enumerated type. The default value is D3DSTENCILOP_KEEP. |
215 | */ | 215 | */ |
216 | BD3DRS_STENCILPASS = 55, | 216 | BD3DRS_STENCILPASS = 55, |
217 | 217 | ||
218 | /*! BD3DRS_STENCILFUNC | 218 | /*! BD3DRS_STENCILFUNC |
219 | Comparison function for the stencil test. Values are from the D3DCMPFUNC enumerated type. | 219 | Comparison function for the stencil test. Values are from the D3DCMPFUNC enumerated type. |
220 | The default value is D3DCMP_ALWAYS. | 220 | The default value is D3DCMP_ALWAYS. |
221 | The comparison function is used to compare the reference value to a stencil buffer entry. | 221 | The comparison function is used to compare the reference value to a stencil buffer entry. |
222 | This comparison applies only to the bits in the reference value and stencil buffer entry that | 222 | This comparison applies only to the bits in the reference value and stencil buffer entry that |
223 | are set in the stencil mask (set by the D3DRS_STENCILMASK render state). If TRUE, the stencil | 223 | are set in the stencil mask (set by the D3DRS_STENCILMASK render state). If TRUE, the stencil |
224 | test passes. | 224 | test passes. |
225 | */ | 225 | */ |
226 | BD3DRS_STENCILFUNC = 56, | 226 | BD3DRS_STENCILFUNC = 56, |
227 | 227 | ||
228 | /*! BD3DRS_STENCILREF | 228 | /*! BD3DRS_STENCILREF |
229 | An int reference value for the stencil test. The default value is 0. | 229 | An int reference value for the stencil test. The default value is 0. |
230 | */ | 230 | */ |
231 | BD3DRS_STENCILREF = 57, | 231 | BD3DRS_STENCILREF = 57, |
232 | 232 | ||
233 | /*! BD3DRS_STENCILMASK | 233 | /*! BD3DRS_STENCILMASK |
234 | Mask applied to the reference value and each stencil buffer entry to determine the significant | 234 | Mask applied to the reference value and each stencil buffer entry to determine the significant |
235 | bits for the stencil test. The default mask is 0xFFFFFFFF. | 235 | bits for the stencil test. The default mask is 0xFFFFFFFF. |
236 | */ | 236 | */ |
237 | BD3DRS_STENCILMASK = 58, | 237 | BD3DRS_STENCILMASK = 58, |
238 | 238 | ||
239 | /*! BD3DRS_STENCILWRITEMASK | 239 | /*! BD3DRS_STENCILWRITEMASK |
240 | Write mask applied to values written into the stencil buffer. The default mask is 0xFFFFFFFF. | 240 | Write mask applied to values written into the stencil buffer. The default mask is 0xFFFFFFFF. |
241 | */ | 241 | */ |
242 | BD3DRS_STENCILWRITEMASK = 59, | 242 | BD3DRS_STENCILWRITEMASK = 59, |
243 | 243 | ||
244 | /*! BD3DRS_TEXTUREFACTOR | 244 | /*! BD3DRS_TEXTUREFACTOR |
245 | Color used for multiple-texture blending with the D3DTA_TFACTOR texture-blending argument or the | 245 | Color used for multiple-texture blending with the D3DTA_TFACTOR texture-blending argument or the |
246 | D3DTOP_BLENDFACTORALPHA texture-blending operation. The associated value is a D3DCOLOR variable. | 246 | D3DTOP_BLENDFACTORALPHA texture-blending operation. The associated value is a D3DCOLOR variable. |
247 | The default value is opaque white (0xFFFFFFFF). | 247 | The default value is opaque white (0xFFFFFFFF). |
248 | */ | 248 | */ |
249 | BD3DRS_TEXTUREFACTOR = 60, | 249 | BD3DRS_TEXTUREFACTOR = 60, |
250 | 250 | ||
251 | /*! BD3DRS_WRAP0 | 251 | /*! BD3DRS_WRAP0 |
252 | Texture-wrapping behavior for multiple sets of texture coordinates. Valid values for this | 252 | Texture-wrapping behavior for multiple sets of texture coordinates. Valid values for this |
253 | render state can be any combination of the D3DWRAPCOORD_0 (or D3DWRAP_U), D3DWRAPCOORD_1 | 253 | render state can be any combination of the D3DWRAPCOORD_0 (or D3DWRAP_U), D3DWRAPCOORD_1 |
254 | (or D3DWRAP_V), D3DWRAPCOORD_2 (or D3DWRAP_W), and D3DWRAPCOORD_3 flags. These cause the system | 254 | (or D3DWRAP_V), D3DWRAPCOORD_2 (or D3DWRAP_W), and D3DWRAPCOORD_3 flags. These cause the system |
255 | to wrap in the direction of the first, second, third, and fourth dimensions, sometimes referred | 255 | to wrap in the direction of the first, second, third, and fourth dimensions, sometimes referred |
256 | to as the s, t, r, and q directions, for a given texture. The default value for this render state | 256 | to as the s, t, r, and q directions, for a given texture. The default value for this render state |
257 | is 0 (wrapping disabled in all directions). | 257 | is 0 (wrapping disabled in all directions). |
258 | */ | 258 | */ |
259 | BD3DRS_WRAP0 = 128, | 259 | BD3DRS_WRAP0 = 128, |
260 | BD3DRS_WRAP1 = 129, | 260 | BD3DRS_WRAP1 = 129, |
261 | BD3DRS_WRAP2 = 130, | 261 | BD3DRS_WRAP2 = 130, |
262 | BD3DRS_WRAP3 = 131, | 262 | BD3DRS_WRAP3 = 131, |
263 | BD3DRS_WRAP4 = 132, | 263 | BD3DRS_WRAP4 = 132, |
264 | BD3DRS_WRAP5 = 133, | 264 | BD3DRS_WRAP5 = 133, |
265 | BD3DRS_WRAP6 = 134, | 265 | BD3DRS_WRAP6 = 134, |
266 | BD3DRS_WRAP7 = 135, | 266 | BD3DRS_WRAP7 = 135, |
267 | 267 | ||
268 | /*! BD3DRS_CLIPPING | 268 | /*! BD3DRS_CLIPPING |
269 | TRUE to enable primitive clipping by Direct3D, or FALSE to disable it. The default value is TRUE. | 269 | TRUE to enable primitive clipping by Direct3D, or FALSE to disable it. The default value is TRUE. |
270 | */ | 270 | */ |
271 | BD3DRS_CLIPPING = 136, | 271 | BD3DRS_CLIPPING = 136, |
272 | 272 | ||
273 | /*! BD3DRS_LIGHTING | 273 | /*! BD3DRS_LIGHTING |
274 | TRUE to enable Direct3D lighting, or FALSE to disable it. The default value is TRUE. Only | 274 | TRUE to enable Direct3D lighting, or FALSE to disable it. The default value is TRUE. Only |
275 | vertices that include a vertex normal are properly lit; vertices that do not contain a normal | 275 | vertices that include a vertex normal are properly lit; vertices that do not contain a normal |
276 | employ a dot product of 0 in all lighting calculations. | 276 | employ a dot product of 0 in all lighting calculations. |
277 | */ | 277 | */ |
278 | BD3DRS_LIGHTING = 137, | 278 | BD3DRS_LIGHTING = 137, |
279 | 279 | ||
280 | /*! D3DRS_AMBIENT | 280 | /*! D3DRS_AMBIENT |
281 | Ambient light color. This value is of type D3DCOLOR. The default value is 0. | 281 | Ambient light color. This value is of type D3DCOLOR. The default value is 0. |
282 | */ | 282 | */ |
283 | BD3DRS_AMBIENT = 139, | 283 | BD3DRS_AMBIENT = 139, |
284 | 284 | ||
285 | /*! BD3DRS_FOGVERTEXMODE | 285 | /*! BD3DRS_FOGVERTEXMODE |
286 | Fog formula to be used for vertex fog. Set to one member of the BD3DFOGMODE enumerated type. | 286 | Fog formula to be used for vertex fog. Set to one member of the BD3DFOGMODE enumerated type. |
287 | The default value is D3DFOG_NONE. | 287 | The default value is D3DFOG_NONE. |
288 | */ | 288 | */ |
289 | BD3DRS_FOGVERTEXMODE = 140, | 289 | BD3DRS_FOGVERTEXMODE = 140, |
290 | 290 | ||
291 | /*! BD3DRS_COLORVERTEX | 291 | /*! BD3DRS_COLORVERTEX |
292 | TRUE to enable per-vertex color or FALSE to disable it. The default value is TRUE. Enabling | 292 | TRUE to enable per-vertex color or FALSE to disable it. The default value is TRUE. Enabling |
293 | per-vertex color allows the system to include the color defined for individual vertices in its | 293 | per-vertex color allows the system to include the color defined for individual vertices in its |
294 | lighting calculations. | 294 | lighting calculations. |
295 | For more information, see the following render states: | 295 | For more information, see the following render states: |
296 | BD3DRS_DIFFUSEMATERIALSOURCE | 296 | BD3DRS_DIFFUSEMATERIALSOURCE |
297 | BD3DRS_SPECULARMATERIALSOURCE | 297 | BD3DRS_SPECULARMATERIALSOURCE |
298 | BD3DRS_AMBIENTMATERIALSOURCE | 298 | BD3DRS_AMBIENTMATERIALSOURCE |
299 | BD3DRS_EMISSIVEMATERIALSOURCE | 299 | BD3DRS_EMISSIVEMATERIALSOURCE |
300 | */ | 300 | */ |
301 | BD3DRS_COLORVERTEX = 141, | 301 | BD3DRS_COLORVERTEX = 141, |
302 | 302 | ||
303 | /*! BD3DRS_LOCALVIEWER | 303 | /*! BD3DRS_LOCALVIEWER |
304 | TRUE to enable camera-relative specular highlights, or FALSE to use orthogonal specular | 304 | TRUE to enable camera-relative specular highlights, or FALSE to use orthogonal specular |
305 | highlights. The default value is TRUE. Applications that use orthogonal projection should | 305 | highlights. The default value is TRUE. Applications that use orthogonal projection should |
306 | specify false. | 306 | specify false. |
307 | */ | 307 | */ |
308 | BD3DRS_LOCALVIEWER = 142, | 308 | BD3DRS_LOCALVIEWER = 142, |
309 | 309 | ||
310 | /*! BD3DRS_NORMALIZENORMALS | 310 | /*! BD3DRS_NORMALIZENORMALS |
311 | TRUE to enable automatic normalization of vertex normals, or FALSE to disable it. The default | 311 | TRUE to enable automatic normalization of vertex normals, or FALSE to disable it. The default |
312 | value is FALSE. Enabling this feature causes the system to normalize the vertex normals for | 312 | value is FALSE. Enabling this feature causes the system to normalize the vertex normals for |
313 | vertices after transforming them to camera space, which can be computationally time-consuming. | 313 | vertices after transforming them to camera space, which can be computationally time-consuming. |
314 | */ | 314 | */ |
315 | BD3DRS_NORMALIZENORMALS = 143, | 315 | BD3DRS_NORMALIZENORMALS = 143, |
316 | 316 | ||
317 | /*! BD3DRS_DIFFUSEMATERIALSOURCE | 317 | /*! BD3DRS_DIFFUSEMATERIALSOURCE |
318 | Diffuse color source for lighting calculations. Valid values are members of the | 318 | Diffuse color source for lighting calculations. Valid values are members of the |
319 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_COLOR1. The value for this | 319 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_COLOR1. The value for this |
320 | render state is used only if the D3DRS_COLORVERTEX render state is set to TRUE. | 320 | render state is used only if the D3DRS_COLORVERTEX render state is set to TRUE. |
321 | */ | 321 | */ |
322 | BD3DRS_DIFFUSEMATERIALSOURCE = 145, | 322 | BD3DRS_DIFFUSEMATERIALSOURCE = 145, |
323 | 323 | ||
324 | /*! BD3DRS_SPECULARMATERIALSOURCE | 324 | /*! BD3DRS_SPECULARMATERIALSOURCE |
325 | Specular color source for lighting calculations. Valid values are members of the | 325 | Specular color source for lighting calculations. Valid values are members of the |
326 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_COLOR2. | 326 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_COLOR2. |
327 | */ | 327 | */ |
328 | BD3DRS_SPECULARMATERIALSOURCE = 146, | 328 | BD3DRS_SPECULARMATERIALSOURCE = 146, |
329 | 329 | ||
330 | /*! D3DRS_AMBIENTMATERIALSOURCE | 330 | /*! D3DRS_AMBIENTMATERIALSOURCE |
331 | Ambient color source for lighting calculations. Valid values are members of the | 331 | Ambient color source for lighting calculations. Valid values are members of the |
332 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_MATERIAL. | 332 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_MATERIAL. |
333 | */ | 333 | */ |
334 | BD3DRS_AMBIENTMATERIALSOURCE = 147, | 334 | BD3DRS_AMBIENTMATERIALSOURCE = 147, |
335 | 335 | ||
336 | /*! D3DRS_EMISSIVEMATERIALSOURCE | 336 | /*! D3DRS_EMISSIVEMATERIALSOURCE |
337 | Emissive color source for lighting calculations. Valid values are members of the | 337 | Emissive color source for lighting calculations. Valid values are members of the |
338 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_MATERIAL. | 338 | D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_MATERIAL. |
339 | */ | 339 | */ |
340 | BD3DRS_EMISSIVEMATERIALSOURCE = 148, | 340 | BD3DRS_EMISSIVEMATERIALSOURCE = 148, |
341 | 341 | ||
342 | /*! D3DRS_VERTEXBLEND | 342 | /*! D3DRS_VERTEXBLEND |
343 | Number of matrices to use to perform geometry blending, if any. Valid values are members | 343 | Number of matrices to use to perform geometry blending, if any. Valid values are members |
344 | of the D3DVERTEXBLENDFLAGS enumerated type. The default value is D3DVBF_DISABLE. | 344 | of the D3DVERTEXBLENDFLAGS enumerated type. The default value is D3DVBF_DISABLE. |
345 | */ | 345 | */ |
346 | BD3DRS_VERTEXBLEND = 151, | 346 | BD3DRS_VERTEXBLEND = 151, |
347 | 347 | ||
348 | /* D3DRS_CLIPPLANEENABLE | 348 | /* D3DRS_CLIPPLANEENABLE |
349 | Enables or disables user-defined clipping planes. Valid values are any DWORD in which the | 349 | Enables or disables user-defined clipping planes. Valid values are any DWORD in which the |
350 | status of each bit (set or not set) toggles the activation state of a corresponding user-defined | 350 | status of each bit (set or not set) toggles the activation state of a corresponding user-defined |
351 | clipping plane. The least significant bit (bit 0) controls the first clipping plane at index 0, | 351 | clipping plane. The least significant bit (bit 0) controls the first clipping plane at index 0, |
352 | and subsequent bits control the activation of clipping planes at higher indexes. If a bit is set, | 352 | and subsequent bits control the activation of clipping planes at higher indexes. If a bit is set, |
353 | the system applies the appropriate clipping plane during scene rendering. The default value is 0. | 353 | the system applies the appropriate clipping plane during scene rendering. The default value is 0. |
354 | The D3DCLIPPLANEn macros are defined to provide a convenient way to enable clipping planes. | 354 | The D3DCLIPPLANEn macros are defined to provide a convenient way to enable clipping planes. |
355 | */ | 355 | */ |
356 | BD3DRS_CLIPPLANEENABLE = 152, | 356 | BD3DRS_CLIPPLANEENABLE = 152, |
357 | BD3DRS_POINTSIZE = 154, | 357 | BD3DRS_POINTSIZE = 154, |
358 | BD3DRS_POINTSIZE_MIN = 155, | 358 | BD3DRS_POINTSIZE_MIN = 155, |
359 | BD3DRS_POINTSPRITEENABLE = 156, | 359 | BD3DRS_POINTSPRITEENABLE = 156, |
360 | BD3DRS_POINTSCALEENABLE = 157, | 360 | BD3DRS_POINTSCALEENABLE = 157, |
361 | BD3DRS_POINTSCALE_A = 158, | 361 | BD3DRS_POINTSCALE_A = 158, |
362 | BD3DRS_POINTSCALE_B = 159, | 362 | BD3DRS_POINTSCALE_B = 159, |
363 | BD3DRS_POINTSCALE_C = 160, | 363 | BD3DRS_POINTSCALE_C = 160, |
364 | BD3DRS_MULTISAMPLEANTIALIAS = 161, | 364 | BD3DRS_MULTISAMPLEANTIALIAS = 161, |
365 | BD3DRS_MULTISAMPLEMASK = 162, | 365 | BD3DRS_MULTISAMPLEMASK = 162, |
366 | BD3DRS_PATCHEDGESTYLE = 163, | 366 | BD3DRS_PATCHEDGESTYLE = 163, |
367 | BD3DRS_DEBUGMONITORTOKEN = 165, | 367 | BD3DRS_DEBUGMONITORTOKEN = 165, |
368 | BD3DRS_POINTSIZE_MAX = 166, | 368 | BD3DRS_POINTSIZE_MAX = 166, |
369 | BD3DRS_INDEXEDVERTEXBLENDENABLE = 167, | 369 | BD3DRS_INDEXEDVERTEXBLENDENABLE = 167, |
370 | BD3DRS_COLORWRITEENABLE = 168, | 370 | BD3DRS_COLORWRITEENABLE = 168, |
371 | BD3DRS_TWEENFACTOR = 170, | 371 | BD3DRS_TWEENFACTOR = 170, |
372 | BD3DRS_BLENDOP = 171, | 372 | BD3DRS_BLENDOP = 171, |
373 | BD3DRS_POSITIONDEGREE = 172, | 373 | BD3DRS_POSITIONDEGREE = 172, |
374 | BD3DRS_NORMALDEGREE = 173, | 374 | BD3DRS_NORMALDEGREE = 173, |
375 | BD3DRS_SCISSORTESTENABLE = 174, | 375 | BD3DRS_SCISSORTESTENABLE = 174, |
376 | BD3DRS_SLOPESCALEDEPTHBIAS = 175, | 376 | BD3DRS_SLOPESCALEDEPTHBIAS = 175, |
377 | BD3DRS_ANTIALIASEDLINEENABLE = 176, | 377 | BD3DRS_ANTIALIASEDLINEENABLE = 176, |
378 | BD3DRS_MINTESSELLATIONLEVEL = 178, | 378 | BD3DRS_MINTESSELLATIONLEVEL = 178, |
379 | BD3DRS_MAXTESSELLATIONLEVEL = 179, | 379 | BD3DRS_MAXTESSELLATIONLEVEL = 179, |
380 | BD3DRS_ADAPTIVETESS_X = 180, | 380 | BD3DRS_ADAPTIVETESS_X = 180, |
381 | BD3DRS_ADAPTIVETESS_Y = 181, | 381 | BD3DRS_ADAPTIVETESS_Y = 181, |
382 | BD3DRS_ADAPTIVETESS_Z = 182, | 382 | BD3DRS_ADAPTIVETESS_Z = 182, |
383 | BD3DRS_ADAPTIVETESS_W = 183, | 383 | BD3DRS_ADAPTIVETESS_W = 183, |
384 | BD3DRS_ENABLEADAPTIVETESSELLATION = 184, | 384 | BD3DRS_ENABLEADAPTIVETESSELLATION = 184, |
385 | BD3DRS_TWOSIDEDSTENCILMODE = 185, | 385 | BD3DRS_TWOSIDEDSTENCILMODE = 185, |
386 | BD3DRS_CCW_STENCILFAIL = 186, | 386 | BD3DRS_CCW_STENCILFAIL = 186, |
387 | BD3DRS_CCW_STENCILZFAIL = 187, | 387 | BD3DRS_CCW_STENCILZFAIL = 187, |
388 | BD3DRS_CCW_STENCILPASS = 188, | 388 | BD3DRS_CCW_STENCILPASS = 188, |
389 | BD3DRS_CCW_STENCILFUNC = 189, | 389 | BD3DRS_CCW_STENCILFUNC = 189, |
390 | BD3DRS_COLORWRITEENABLE1 = 190, | 390 | BD3DRS_COLORWRITEENABLE1 = 190, |
391 | BD3DRS_COLORWRITEENABLE2 = 191, | 391 | BD3DRS_COLORWRITEENABLE2 = 191, |
392 | BD3DRS_COLORWRITEENABLE3 = 192, | 392 | BD3DRS_COLORWRITEENABLE3 = 192, |
393 | BD3DRS_BLENDFACTOR = 193, | 393 | BD3DRS_BLENDFACTOR = 193, |
394 | BD3DRS_SRGBWRITEENABLE = 194, | 394 | BD3DRS_SRGBWRITEENABLE = 194, |
395 | BD3DRS_DEPTHBIAS = 195, | 395 | BD3DRS_DEPTHBIAS = 195, |
396 | BD3DRS_WRAP8 = 198, | 396 | BD3DRS_WRAP8 = 198, |
397 | BD3DRS_WRAP9 = 199, | 397 | BD3DRS_WRAP9 = 199, |
398 | BD3DRS_WRAP10 = 200, | 398 | BD3DRS_WRAP10 = 200, |
399 | BD3DRS_WRAP11 = 201, | 399 | BD3DRS_WRAP11 = 201, |
400 | BD3DRS_WRAP12 = 202, | 400 | BD3DRS_WRAP12 = 202, |
401 | BD3DRS_WRAP13 = 203, | 401 | BD3DRS_WRAP13 = 203, |
402 | BD3DRS_WRAP14 = 204, | 402 | BD3DRS_WRAP14 = 204, |
403 | BD3DRS_WRAP15 = 205, | 403 | BD3DRS_WRAP15 = 205, |
404 | BD3DRS_SEPARATEALPHABLENDENABLE = 206, | 404 | BD3DRS_SEPARATEALPHABLENDENABLE = 206, |
405 | BD3DRS_SRCBLENDALPHA = 207, | 405 | BD3DRS_SRCBLENDALPHA = 207, |
406 | BD3DRS_DESTBLENDALPHA = 208, | 406 | BD3DRS_DESTBLENDALPHA = 208, |
407 | BD3DRS_BLENDOPALPHA = 209, | 407 | BD3DRS_BLENDOPALPHA = 209, |
408 | 408 | ||
409 | BD3DRS_MAX_TYPE | 409 | BD3DRS_MAX_TYPE |
410 | }; | 410 | }; |
411 | 411 | ||
412 | 412 | ||
413 | 413 | ||
414 | /*! Defines constants that describe depth-buffer formats | 414 | /*! Defines constants that describe depth-buffer formats |
415 | Members of this enumerated type are used with the D3DRS_ZENABLE render state. | 415 | Members of this enumerated type are used with the D3DRS_ZENABLE render state. |
416 | */ | 416 | */ |
417 | enum BD3DZBUFFERTYPE | 417 | enum BD3DZBUFFERTYPE |
418 | { | 418 | { |
419 | BD3DZB_FALSE = 0, // Disable depth buffering | 419 | BD3DZB_FALSE = 0, // Disable depth buffering |
420 | BD3DZB_TRUE = 1, // Enable z-buffering | 420 | BD3DZB_TRUE = 1, // Enable z-buffering |
421 | BD3DZB_USEW = 2 //Enable w-buffering. | 421 | BD3DZB_USEW = 2 //Enable w-buffering. |
422 | }; | 422 | }; |
423 | 423 | ||
424 | //! Defines the supported compare functions. | 424 | //! Defines the supported compare functions. |
425 | enum BD3DCMPFUNC | 425 | enum BD3DCMPFUNC |
426 | { | 426 | { |
427 | BD3DCMP_NEVER = 1,// Always fail the test. | 427 | BD3DCMP_NEVER = 1,// Always fail the test. |
428 | BD3DCMP_LESS, // Accept the new pixel if its value is less than the value of the current pixel. | 428 | BD3DCMP_LESS, // Accept the new pixel if its value is less than the value of the current pixel. |
429 | BD3DCMP_EQUAL, // Accept the new pixel if its value equals the value of the current pixel. | 429 | BD3DCMP_EQUAL, // Accept the new pixel if its value equals the value of the current pixel. |
430 | BD3DCMP_LESSEQUAL, // Accept the new pixel if its value is less than or equal to the value of the current pixel. | 430 | BD3DCMP_LESSEQUAL, // Accept the new pixel if its value is less than or equal to the value of the current pixel. |
431 | BD3DCMP_GREATER, // Accept the new pixel if its value is greater than the value of the current pixel. | 431 | BD3DCMP_GREATER, // Accept the new pixel if its value is greater than the value of the current pixel. |
432 | BD3DCMP_NOTEQUAL, // Accept the new pixel if its value does not equal the value of the current pixel. | 432 | BD3DCMP_NOTEQUAL, // Accept the new pixel if its value does not equal the value of the current pixel. |
433 | BD3DCMP_GREATEREQUAL,// Accept the new pixel if its value is greater than or equal to the value of the current pixel. | 433 | BD3DCMP_GREATEREQUAL,// Accept the new pixel if its value is greater than or equal to the value of the current pixel. |
434 | BD3DCMP_ALWAYS // Always pass the test. | 434 | BD3DCMP_ALWAYS // Always pass the test. |
435 | }; | 435 | }; |
436 | 436 | ||
437 | enum BD3DMATERIALCOLORSOURCE | 437 | enum BD3DMATERIALCOLORSOURCE |
438 | { | 438 | { |
439 | BD3DMCS_MATERIAL = 0, // Use the color from the current material. | 439 | BD3DMCS_MATERIAL = 0, // Use the color from the current material. |
440 | BD3DMCS_COLOR1 = 1, // Use the diffuse vertex color. | 440 | BD3DMCS_COLOR1 = 1, // Use the diffuse vertex color. |
441 | BD3DMCS_COLOR2 = 2 // Use the specular vertex color. | 441 | BD3DMCS_COLOR2 = 2 // Use the specular vertex color. |
442 | }; | 442 | }; |
443 | 443 | ||
444 | 444 | ||
445 | //! Defines constants that describe the supported shading modes. | 445 | //! Defines constants that describe the supported shading modes. |
446 | enum BD3DSHADEMODE | 446 | enum BD3DSHADEMODE |
447 | { | 447 | { |
448 | /*! BD3DSHADE_FLAT | 448 | /*! BD3DSHADE_FLAT |
449 | Flat shading mode. The color and specular component of the first vertex in the triangle | 449 | Flat shading mode. The color and specular component of the first vertex in the triangle |
450 | are used to determine the color and specular component of the face. These colors remain | 450 | are used to determine the color and specular component of the face. These colors remain |
451 | constant across the triangle; that is, they are not interpolated. The specular alpha is | 451 | constant across the triangle; that is, they are not interpolated. The specular alpha is |
452 | interpolated. | 452 | interpolated. |
453 | */ | 453 | */ |
454 | BD3DSHADE_FLAT = 1, | 454 | BD3DSHADE_FLAT = 1, |
455 | 455 | ||
456 | /*! BD3DSHADE_GOURAUD | 456 | /*! BD3DSHADE_GOURAUD |
457 | Gouraud shading mode. The color and specular components of the face are determined by a | 457 | Gouraud shading mode. The color and specular components of the face are determined by a |
458 | linear interpolation between all three of the triangle's vertices. | 458 | linear interpolation between all three of the triangle's vertices. |
459 | */ | 459 | */ |
460 | BD3DSHADE_GOURAUD = 2, | 460 | BD3DSHADE_GOURAUD = 2, |
461 | 461 | ||
462 | /*! BD3DSHADE_PHONG | 462 | /*! BD3DSHADE_PHONG |
463 | Not supported. | 463 | Not supported. |
464 | */ | 464 | */ |
465 | BD3DSHADE_PHONG = 3 | 465 | BD3DSHADE_PHONG = 3 |
466 | }; | 466 | }; |
467 | 467 | ||
468 | /*! Defines constants describing the fill mode | 468 | /*! Defines constants describing the fill mode |
469 | The values in this enumerated type are used by the BD3DRS_FILLMODE render state | 469 | The values in this enumerated type are used by the BD3DRS_FILLMODE render state |
470 | */ | 470 | */ |
471 | enum BD3DFILLMODE | 471 | enum BD3DFILLMODE |
472 | { | 472 | { |
473 | BD3DFILL_POINT = 1, // Fill points. | 473 | BD3DFILL_POINT = 1, // Fill points. |
474 | BD3DFILL_WIREFRAME = 2, // Fill wireframes. | 474 | BD3DFILL_WIREFRAME = 2, // Fill wireframes. |
475 | BD3DFILL_SOLID = 3 // Fill solids. | 475 | BD3DFILL_SOLID = 3 // Fill solids. |
476 | }; | 476 | }; |
477 | 477 | ||
478 | 478 | ||
479 | 479 | ||
480 | /*! Defines the supported culling modes. | 480 | /*! Defines the supported culling modes. |
481 | The values in this enumerated type are used by the B3DRS_CULLMODE render state. | 481 | The values in this enumerated type are used by the B3DRS_CULLMODE render state. |
482 | The culling modes define how back faces are culled when rendering a geometry. | 482 | The culling modes define how back faces are culled when rendering a geometry. |
483 | */ | 483 | */ |
484 | enum BD3DCULL | 484 | enum BD3DCULL |
485 | { | 485 | { |
486 | BD3DCULL_NONE = 1, // Do not cull back faces. | 486 | BD3DCULL_NONE = 1, // Do not cull back faces. |
487 | BD3DCULL_CW = 2, // Cull back faces with clockwise vertices. | 487 | BD3DCULL_CW = 2, // Cull back faces with clockwise vertices. |
488 | BD3DCULL_CCW = 3 // Cull back faces with counterclockwise vertices. | 488 | BD3DCULL_CCW = 3 // Cull back faces with counterclockwise vertices. |
489 | }; | 489 | }; |
490 | 490 | ||
491 | struct SShaderParam | 491 | struct SShaderParam |
492 | { | 492 | { |
493 | u32 ColorUnits; | 493 | u32 ColorUnits; |
494 | u32 TextureUnits; | 494 | u32 TextureUnits; |
495 | 495 | ||
496 | u32 RenderState [ BD3DRS_MAX_TYPE ]; | 496 | u32 RenderState [ BD3DRS_MAX_TYPE ]; |
497 | void SetRenderState ( BD3DRENDERSTATETYPE state, u32 value ); | 497 | void SetRenderState ( BD3DRENDERSTATETYPE state, u32 value ); |
498 | }; | 498 | }; |
499 | 499 | ||
500 | void SShaderParam::SetRenderState ( BD3DRENDERSTATETYPE state, u32 value ) | 500 | void SShaderParam::SetRenderState ( BD3DRENDERSTATETYPE state, u32 value ) |
501 | { | 501 | { |
502 | RenderState [ state ] = value; | 502 | RenderState [ state ] = value; |
503 | } | 503 | } |
504 | 504 | ||
505 | 505 | ||
506 | 506 | ||
507 | class CBurningShader_Raster_Reference : public IBurningShader | 507 | class CBurningShader_Raster_Reference : public IBurningShader |
508 | { | 508 | { |
509 | public: | 509 | public: |
510 | 510 | ||
511 | //! constructor | 511 | //! constructor |
512 | CBurningShader_Raster_Reference(CBurningVideoDriver* driver); | 512 | CBurningShader_Raster_Reference(CBurningVideoDriver* driver); |
513 | 513 | ||
514 | //! draws an indexed triangle list | 514 | //! draws an indexed triangle list |
515 | virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); | 515 | virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); |
516 | 516 | ||
517 | virtual void setMaterial ( const SBurningShaderMaterial &material ); | 517 | virtual void setMaterial ( const SBurningShaderMaterial &material ); |
518 | 518 | ||
519 | 519 | ||
520 | private: | 520 | private: |
521 | void scanline (); | 521 | void scanline (); |
522 | void scanline2 (); | 522 | void scanline2 (); |
523 | 523 | ||
524 | sScanLineData line; | 524 | sScanLineData line; |
525 | sPixelShaderData pShader; | 525 | sPixelShaderData pShader; |
526 | 526 | ||
527 | void pShader_1 (); | 527 | void pShader_1 (); |
528 | void pShader_EMT_LIGHTMAP_M4 (); | 528 | void pShader_EMT_LIGHTMAP_M4 (); |
529 | 529 | ||
530 | SShaderParam ShaderParam; | 530 | SShaderParam ShaderParam; |
531 | 531 | ||
532 | REALINLINE u32 depthFunc (); | 532 | REALINLINE u32 depthFunc (); |
533 | REALINLINE void depthWrite (); | 533 | REALINLINE void depthWrite (); |
534 | 534 | ||
535 | 535 | ||
536 | }; | 536 | }; |
537 | 537 | ||
538 | //! constructor | 538 | //! constructor |
539 | CBurningShader_Raster_Reference::CBurningShader_Raster_Reference(CBurningVideoDriver* driver) | 539 | CBurningShader_Raster_Reference::CBurningShader_Raster_Reference(CBurningVideoDriver* driver) |
540 | : IBurningShader(driver) | 540 | : IBurningShader(driver) |
541 | { | 541 | { |
542 | #ifdef _DEBUG | 542 | #ifdef _DEBUG |
543 | setDebugName("CBurningShader_Raster_Reference"); | 543 | setDebugName("CBurningShader_Raster_Reference"); |
544 | #endif | 544 | #endif |
545 | } | 545 | } |
546 | 546 | ||
547 | 547 | ||
548 | /*! | 548 | /*! |
549 | */ | 549 | */ |
550 | void CBurningShader_Raster_Reference::pShader_EMT_LIGHTMAP_M4 () | 550 | void CBurningShader_Raster_Reference::pShader_EMT_LIGHTMAP_M4 () |
551 | { | 551 | { |
552 | tFixPoint r0, g0, b0; | 552 | tFixPoint r0, g0, b0; |
553 | tFixPoint r1, g1, b1; | 553 | tFixPoint r1, g1, b1; |
554 | 554 | ||
555 | f32 inversew = fix_inverse32 ( line.w[0] ); | 555 | f32 inversew = fix_inverse32 ( line.w[0] ); |
556 | 556 | ||
557 | getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); | 557 | getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); |
558 | getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); | 558 | getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); |
559 | 559 | ||
560 | 560 | ||
561 | pShader.dst[pShader.i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), | 561 | pShader.dst[pShader.i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), |
562 | clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), | 562 | clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), |
563 | clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) | 563 | clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) |
564 | ); | 564 | ); |
565 | 565 | ||
566 | } | 566 | } |
567 | 567 | ||
568 | /*! | 568 | /*! |
569 | */ | 569 | */ |
570 | void CBurningShader_Raster_Reference::pShader_1 () | 570 | void CBurningShader_Raster_Reference::pShader_1 () |
571 | { | 571 | { |
572 | tFixPoint r0, g0, b0; | 572 | tFixPoint r0, g0, b0; |
573 | tFixPoint tx0, ty0; | 573 | tFixPoint tx0, ty0; |
574 | 574 | ||
575 | const f32 inversew = fix_inverse32 ( line.w[0] ); | 575 | const f32 inversew = fix_inverse32 ( line.w[0] ); |
576 | 576 | ||
577 | tx0 = tofix ( line.t[0][0].x, inversew ); | 577 | tx0 = tofix ( line.t[0][0].x, inversew ); |
578 | ty0 = tofix ( line.t[0][0].y, inversew ); | 578 | ty0 = tofix ( line.t[0][0].y, inversew ); |
579 | 579 | ||
580 | getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); | 580 | getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); |
581 | pShader.dst[pShader.i] = fix_to_color ( r0, g0, b0 ); | 581 | pShader.dst[pShader.i] = fix_to_color ( r0, g0, b0 ); |
582 | 582 | ||
583 | } | 583 | } |
584 | 584 | ||
585 | 585 | ||
586 | /*! | 586 | /*! |
587 | */ | 587 | */ |
588 | void CBurningShader_Raster_Reference::setMaterial ( const SBurningShaderMaterial &material ) | 588 | void CBurningShader_Raster_Reference::setMaterial ( const SBurningShaderMaterial &material ) |
589 | { | 589 | { |
590 | const video::SMaterial &m = material.org; | 590 | const video::SMaterial &m = material.org; |
591 | 591 | ||
592 | u32 i; | 592 | u32 i; |
593 | u32 enable; | 593 | u32 enable; |
594 | 594 | ||
595 | ShaderParam.ColorUnits = 0; | 595 | ShaderParam.ColorUnits = 0; |
596 | ShaderParam.TextureUnits = 0; | 596 | ShaderParam.TextureUnits = 0; |
597 | for ( i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) | 597 | for ( i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) |
598 | { | 598 | { |
599 | if ( m.getTexture( i ) ) | 599 | if ( m.getTexture( i ) ) |
600 | ShaderParam.TextureUnits = i; | 600 | ShaderParam.TextureUnits = i; |
601 | } | 601 | } |
602 | 602 | ||
603 | // shademode | 603 | // shademode |
604 | ShaderParam.SetRenderState( BD3DRS_SHADEMODE, | 604 | ShaderParam.SetRenderState( BD3DRS_SHADEMODE, |
605 | m.GouraudShading ? BD3DSHADE_GOURAUD : BD3DSHADE_FLAT | 605 | m.GouraudShading ? BD3DSHADE_GOURAUD : BD3DSHADE_FLAT |
606 | ); | 606 | ); |
607 | 607 | ||
608 | // fillmode | 608 | // fillmode |
609 | ShaderParam.SetRenderState( BD3DRS_FILLMODE, | 609 | ShaderParam.SetRenderState( BD3DRS_FILLMODE, |
610 | m.Wireframe ? BD3DFILL_WIREFRAME : m.PointCloud ? BD3DFILL_POINT : BD3DFILL_SOLID | 610 | m.Wireframe ? BD3DFILL_WIREFRAME : m.PointCloud ? BD3DFILL_POINT : BD3DFILL_SOLID |
611 | ); | 611 | ); |
612 | 612 | ||
613 | // back face culling | 613 | // back face culling |
614 | ShaderParam.SetRenderState( BD3DRS_CULLMODE, | 614 | ShaderParam.SetRenderState( BD3DRS_CULLMODE, |
615 | m.BackfaceCulling ? BD3DCULL_CCW : BD3DCULL_NONE | 615 | m.BackfaceCulling ? BD3DCULL_CCW : BD3DCULL_NONE |
616 | ); | 616 | ); |
617 | 617 | ||
618 | // lighting | 618 | // lighting |
619 | ShaderParam.SetRenderState( BD3DRS_LIGHTING, m.Lighting ); | 619 | ShaderParam.SetRenderState( BD3DRS_LIGHTING, m.Lighting ); |
620 | 620 | ||
621 | // specular highlights | 621 | // specular highlights |
622 | enable = F32_LOWER_EQUAL_0 ( m.Shininess ); | 622 | enable = F32_LOWER_EQUAL_0 ( m.Shininess ); |
623 | ShaderParam.SetRenderState( BD3DRS_SPECULARENABLE, enable); | 623 | ShaderParam.SetRenderState( BD3DRS_SPECULARENABLE, enable); |
624 | ShaderParam.SetRenderState( BD3DRS_NORMALIZENORMALS, enable); | 624 | ShaderParam.SetRenderState( BD3DRS_NORMALIZENORMALS, enable); |
625 | ShaderParam.SetRenderState( BD3DRS_SPECULARMATERIALSOURCE, (m.ColorMaterial==ECM_SPECULAR)?BD3DMCS_COLOR1:BD3DMCS_MATERIAL); | 625 | ShaderParam.SetRenderState( BD3DRS_SPECULARMATERIALSOURCE, (m.ColorMaterial==ECM_SPECULAR)?BD3DMCS_COLOR1:BD3DMCS_MATERIAL); |
626 | 626 | ||
627 | // depth buffer enable and compare | 627 | // depth buffer enable and compare |
628 | ShaderParam.SetRenderState( BD3DRS_ZENABLE, (material.org.ZBuffer==video::ECFN_NEVER) ? BD3DZB_FALSE : BD3DZB_USEW); | 628 | ShaderParam.SetRenderState( BD3DRS_ZENABLE, (material.org.ZBuffer==video::ECFN_NEVER) ? BD3DZB_FALSE : BD3DZB_USEW); |
629 | switch (material.org.ZBuffer) | 629 | switch (material.org.ZBuffer) |
630 | { | 630 | { |
631 | case ECFN_NEVER: | 631 | case ECFN_NEVER: |
632 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_NEVER); | 632 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_NEVER); |
633 | break; | 633 | break; |
634 | case ECFN_LESSEQUAL: | 634 | case ECFN_LESSEQUAL: |
635 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_LESSEQUAL); | 635 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_LESSEQUAL); |
636 | break; | 636 | break; |
637 | case ECFN_EQUAL: | 637 | case ECFN_EQUAL: |
638 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_EQUAL); | 638 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_EQUAL); |
639 | break; | 639 | break; |
640 | case ECFN_LESS: | 640 | case ECFN_LESS: |
641 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_LESSEQUAL); | 641 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_LESSEQUAL); |
642 | break; | 642 | break; |
643 | case ECFN_NOTEQUAL: | 643 | case ECFN_NOTEQUAL: |
644 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_NOTEQUAL); | 644 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_NOTEQUAL); |
645 | break; | 645 | break; |
646 | case ECFN_GREATEREQUAL: | 646 | case ECFN_GREATEREQUAL: |
647 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_GREATEREQUAL); | 647 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_GREATEREQUAL); |
648 | break; | 648 | break; |
649 | case ECFN_GREATER: | 649 | case ECFN_GREATER: |
650 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_GREATER); | 650 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_GREATER); |
651 | break; | 651 | break; |
652 | case ECFN_ALWAYS: | 652 | case ECFN_ALWAYS: |
653 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_ALWAYS); | 653 | ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_ALWAYS); |
654 | break; | 654 | break; |
655 | } | 655 | } |
656 | 656 | ||
657 | // depth buffer write | 657 | // depth buffer write |
658 | ShaderParam.SetRenderState( BD3DRS_ZWRITEENABLE, m.ZWriteEnable ); | 658 | ShaderParam.SetRenderState( BD3DRS_ZWRITEENABLE, m.ZWriteEnable ); |
659 | } | 659 | } |
660 | 660 | ||
661 | /*! | 661 | /*! |
662 | */ | 662 | */ |
663 | REALINLINE u32 CBurningShader_Raster_Reference::depthFunc () | 663 | REALINLINE u32 CBurningShader_Raster_Reference::depthFunc () |
664 | { | 664 | { |
665 | if ( ShaderParam.RenderState [ BD3DRS_ZENABLE ] ) | 665 | if ( ShaderParam.RenderState [ BD3DRS_ZENABLE ] ) |
666 | { | 666 | { |
667 | switch ( ShaderParam.RenderState [ BD3DRS_ZFUNC ] ) | 667 | switch ( ShaderParam.RenderState [ BD3DRS_ZFUNC ] ) |
668 | { | 668 | { |
669 | case BD3DCMP_LESSEQUAL: | 669 | case BD3DCMP_LESSEQUAL: |
670 | return line.w[0] >= pShader.z[ pShader.i]; | 670 | return line.w[0] >= pShader.z[ pShader.i]; |
671 | case BD3DCMP_EQUAL: | 671 | case BD3DCMP_EQUAL: |
672 | return line.w[0] == pShader.z[ pShader.i]; | 672 | return line.w[0] == pShader.z[ pShader.i]; |
673 | } | 673 | } |
674 | } | 674 | } |
675 | return 1; | 675 | return 1; |
676 | } | 676 | } |
677 | 677 | ||
678 | /*! | 678 | /*! |
679 | */ | 679 | */ |
680 | REALINLINE void CBurningShader_Raster_Reference::depthWrite () | 680 | REALINLINE void CBurningShader_Raster_Reference::depthWrite () |
681 | { | 681 | { |
682 | if ( ShaderParam.RenderState [ BD3DRS_ZWRITEENABLE ] ) | 682 | if ( ShaderParam.RenderState [ BD3DRS_ZWRITEENABLE ] ) |
683 | { | 683 | { |
684 | pShader.z[pShader.i] = line.w[0]; | 684 | pShader.z[pShader.i] = line.w[0]; |
685 | } | 685 | } |
686 | } | 686 | } |
687 | 687 | ||
688 | /*! | 688 | /*! |
689 | */ | 689 | */ |
690 | REALINLINE void CBurningShader_Raster_Reference::scanline2() | 690 | REALINLINE void CBurningShader_Raster_Reference::scanline2() |
691 | { | 691 | { |
692 | // apply top-left fill-convention, left | 692 | // apply top-left fill-convention, left |
693 | pShader.xStart = core::ceil32( line.x[0] ); | 693 | pShader.xStart = core::ceil32( line.x[0] ); |
694 | pShader.xEnd = core::ceil32( line.x[1] ) - 1; | 694 | pShader.xEnd = core::ceil32( line.x[1] ) - 1; |
695 | 695 | ||
696 | pShader.dx = pShader.xEnd - pShader.xStart; | 696 | pShader.dx = pShader.xEnd - pShader.xStart; |
697 | if ( pShader.dx < 0 ) | 697 | if ( pShader.dx < 0 ) |
698 | return; | 698 | return; |
699 | 699 | ||
700 | // slopes | 700 | // slopes |
701 | const f32 invDeltaX = core::reciprocal ( line.x[1] - line.x[0] ); | 701 | const f32 invDeltaX = core::reciprocal ( line.x[1] - line.x[0] ); |
702 | const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; | 702 | const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; |
703 | 703 | ||
704 | // store slopes in endpoint, and correct first pixel | 704 | // store slopes in endpoint, and correct first pixel |
705 | 705 | ||
706 | line.w[0] += (line.w[1] = (line.w[1] - line.w[0]) * invDeltaX) * subPixel; | 706 | line.w[0] += (line.w[1] = (line.w[1] - line.w[0]) * invDeltaX) * subPixel; |
707 | 707 | ||
708 | u32 i; | 708 | u32 i; |
709 | 709 | ||
710 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 710 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
711 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 711 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
712 | { | 712 | { |
713 | line.c[i][1] = (line.c[i][1] - line.c[i][0]) * invDeltaX; | 713 | line.c[i][1] = (line.c[i][1] - line.c[i][0]) * invDeltaX; |
714 | line.c[i][0] += line.c[i][1] * subPixel; | 714 | line.c[i][0] += line.c[i][1] * subPixel; |
715 | } | 715 | } |
716 | #endif | 716 | #endif |
717 | 717 | ||
718 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 718 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
719 | { | 719 | { |
720 | line.t[i][1] = (line.t[i][1] - line.t[i][0]) * invDeltaX; | 720 | line.t[i][1] = (line.t[i][1] - line.t[i][0]) * invDeltaX; |
721 | line.t[i][0] += line.t[i][1] * subPixel; | 721 | line.t[i][0] += line.t[i][1] * subPixel; |
722 | } | 722 | } |
723 | 723 | ||
724 | pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->lock() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); | 724 | pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->lock() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); |
725 | pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); | 725 | pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); |
726 | 726 | ||
727 | for ( pShader.i = 0; pShader.i <= pShader.dx; ++pShader.i ) | 727 | for ( pShader.i = 0; pShader.i <= pShader.dx; ++pShader.i ) |
728 | { | 728 | { |
729 | if ( depthFunc() ) | 729 | if ( depthFunc() ) |
730 | { | 730 | { |
731 | depthWrite (); | 731 | depthWrite (); |
732 | } | 732 | } |
733 | 733 | ||
734 | // advance next pixel | 734 | // advance next pixel |
735 | line.w[0] += line.w[1]; | 735 | line.w[0] += line.w[1]; |
736 | 736 | ||
737 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 737 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
738 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 738 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
739 | { | 739 | { |
740 | line.c[i][0] += line.c[i][1]; | 740 | line.c[i][0] += line.c[i][1]; |
741 | } | 741 | } |
742 | #endif | 742 | #endif |
743 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 743 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
744 | { | 744 | { |
745 | line.t[i][0] += line.t[i][1]; | 745 | line.t[i][0] += line.t[i][1]; |
746 | } | 746 | } |
747 | } | 747 | } |
748 | } | 748 | } |
749 | 749 | ||
750 | 750 | ||
751 | /*! | 751 | /*! |
752 | */ | 752 | */ |
753 | REALINLINE void CBurningShader_Raster_Reference::scanline () | 753 | REALINLINE void CBurningShader_Raster_Reference::scanline () |
754 | { | 754 | { |
755 | u32 i; | 755 | u32 i; |
756 | 756 | ||
757 | // apply top-left fill-convention, left | 757 | // apply top-left fill-convention, left |
758 | pShader.xStart = core::ceil32( line.x[0] ); | 758 | pShader.xStart = core::ceil32( line.x[0] ); |
759 | pShader.xEnd = core::ceil32( line.x[1] ) - 1; | 759 | pShader.xEnd = core::ceil32( line.x[1] ) - 1; |
760 | 760 | ||
761 | pShader.dx = pShader.xEnd - pShader.xStart; | 761 | pShader.dx = pShader.xEnd - pShader.xStart; |
762 | if ( pShader.dx < 0 ) | 762 | if ( pShader.dx < 0 ) |
763 | return; | 763 | return; |
764 | 764 | ||
765 | // slopes | 765 | // slopes |
766 | const f32 invDeltaX = core::reciprocal ( line.x[1] - line.x[0] ); | 766 | const f32 invDeltaX = core::reciprocal ( line.x[1] - line.x[0] ); |
767 | 767 | ||
768 | // search z-buffer for first not occulled pixel | 768 | // search z-buffer for first not occulled pixel |
769 | pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); | 769 | pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); |
770 | 770 | ||
771 | // subTexel | 771 | // subTexel |
772 | const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; | 772 | const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; |
773 | 773 | ||
774 | const f32 b = (line.w[1] - line.w[0]) * invDeltaX; | 774 | const f32 b = (line.w[1] - line.w[0]) * invDeltaX; |
775 | f32 a = line.w[0] + ( b * subPixel ); | 775 | f32 a = line.w[0] + ( b * subPixel ); |
776 | 776 | ||
777 | pShader.i = 0; | 777 | pShader.i = 0; |
778 | 778 | ||
779 | if ( ShaderParam.RenderState [ BD3DRS_ZENABLE ] ) | 779 | if ( ShaderParam.RenderState [ BD3DRS_ZENABLE ] ) |
780 | { | 780 | { |
781 | u32 condition; | 781 | u32 condition; |
782 | switch ( ShaderParam.RenderState [ BD3DRS_ZFUNC ] ) | 782 | switch ( ShaderParam.RenderState [ BD3DRS_ZFUNC ] ) |
783 | { | 783 | { |
784 | case BD3DCMP_LESSEQUAL: | 784 | case BD3DCMP_LESSEQUAL: |
785 | condition = a < pShader.z[pShader.i]; | 785 | condition = a < pShader.z[pShader.i]; |
786 | break; | 786 | break; |
787 | case BD3DCMP_EQUAL: | 787 | case BD3DCMP_EQUAL: |
788 | condition = a != pShader.z[pShader.i]; | 788 | condition = a != pShader.z[pShader.i]; |
789 | break; | 789 | break; |
790 | } | 790 | } |
791 | while ( a < pShader.z[pShader.i] ) | 791 | while ( a < pShader.z[pShader.i] ) |
792 | { | 792 | { |
793 | a += b; | 793 | a += b; |
794 | 794 | ||
795 | pShader.i += 1; | 795 | pShader.i += 1; |
796 | if ( pShader.i > pShader.dx ) | 796 | if ( pShader.i > pShader.dx ) |
797 | return; | 797 | return; |
798 | 798 | ||
799 | } | 799 | } |
800 | } | 800 | } |
801 | 801 | ||
802 | // lazy setup rest of scanline | 802 | // lazy setup rest of scanline |
803 | 803 | ||
804 | line.w[0] = a; | 804 | line.w[0] = a; |
805 | line.w[1] = b; | 805 | line.w[1] = b; |
806 | 806 | ||
807 | pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->lock() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); | 807 | pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->lock() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); |
808 | 808 | ||
809 | a = (f32) pShader.i + subPixel; | 809 | a = (f32) pShader.i + subPixel; |
810 | 810 | ||
811 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 811 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
812 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 812 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
813 | { | 813 | { |
814 | line.c[i][1] = (line.c[i][1] - line.c[i][0]) * invDeltaX; | 814 | line.c[i][1] = (line.c[i][1] - line.c[i][0]) * invDeltaX; |
815 | line.c[i][0] += line.c[i][1] * a; | 815 | line.c[i][0] += line.c[i][1] * a; |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | 818 | ||
819 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 819 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
820 | { | 820 | { |
821 | line.t[i][1] = (line.t[i][1] - line.t[i][0]) * invDeltaX; | 821 | line.t[i][1] = (line.t[i][1] - line.t[i][0]) * invDeltaX; |
822 | line.t[i][0] += line.t[i][1] * a; | 822 | line.t[i][0] += line.t[i][1] * a; |
823 | } | 823 | } |
824 | 824 | ||
825 | for ( ; pShader.i <= pShader.dx; ++pShader.i ) | 825 | for ( ; pShader.i <= pShader.dx; ++pShader.i ) |
826 | { | 826 | { |
827 | if ( line.w[0] >= pShader.z[pShader.i] ) | 827 | if ( line.w[0] >= pShader.z[pShader.i] ) |
828 | { | 828 | { |
829 | pShader.z[pShader.i] = line.w[0]; | 829 | pShader.z[pShader.i] = line.w[0]; |
830 | 830 | ||
831 | pShader_EMT_LIGHTMAP_M4 (); | 831 | pShader_EMT_LIGHTMAP_M4 (); |
832 | } | 832 | } |
833 | 833 | ||
834 | line.w[0] += line.w[1]; | 834 | line.w[0] += line.w[1]; |
835 | 835 | ||
836 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 836 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
837 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 837 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
838 | { | 838 | { |
839 | line.c[i][0] += line.c[i][1]; | 839 | line.c[i][0] += line.c[i][1]; |
840 | } | 840 | } |
841 | #endif | 841 | #endif |
842 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 842 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
843 | { | 843 | { |
844 | line.t[i][0] += line.t[i][1]; | 844 | line.t[i][0] += line.t[i][1]; |
845 | } | 845 | } |
846 | } | 846 | } |
847 | 847 | ||
848 | } | 848 | } |
849 | 849 | ||
850 | 850 | ||
851 | 851 | ||
852 | void CBurningShader_Raster_Reference::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) | 852 | void CBurningShader_Raster_Reference::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) |
853 | { | 853 | { |
854 | sScanConvertData scan; | 854 | sScanConvertData scan; |
855 | u32 i; | 855 | u32 i; |
856 | 856 | ||
857 | // sort on height, y | 857 | // sort on height, y |
858 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); | 858 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); |
859 | if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); | 859 | if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); |
860 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); | 860 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); |
861 | 861 | ||
862 | 862 | ||
863 | // calculate delta y of the edges | 863 | // calculate delta y of the edges |
864 | scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); | 864 | scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); |
865 | scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); | 865 | scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); |
866 | scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); | 866 | scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); |
867 | 867 | ||
868 | if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) | 868 | if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) |
869 | return; | 869 | return; |
870 | 870 | ||
871 | 871 | ||
872 | // find if the major edge is left or right aligned | 872 | // find if the major edge is left or right aligned |
873 | f32 temp[4]; | 873 | f32 temp[4]; |
874 | 874 | ||
875 | temp[0] = a->Pos.x - c->Pos.x; | 875 | temp[0] = a->Pos.x - c->Pos.x; |
876 | temp[1] = a->Pos.y - c->Pos.y; | 876 | temp[1] = a->Pos.y - c->Pos.y; |
877 | temp[2] = b->Pos.x - a->Pos.x; | 877 | temp[2] = b->Pos.x - a->Pos.x; |
878 | temp[3] = b->Pos.y - a->Pos.y; | 878 | temp[3] = b->Pos.y - a->Pos.y; |
879 | 879 | ||
880 | scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; | 880 | scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; |
881 | scan.right = 1 - scan.left; | 881 | scan.right = 1 - scan.left; |
882 | 882 | ||
883 | // calculate slopes for the major edge | 883 | // calculate slopes for the major edge |
884 | scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; | 884 | scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; |
885 | scan.x[0] = a->Pos.x; | 885 | scan.x[0] = a->Pos.x; |
886 | 886 | ||
887 | scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; | 887 | scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; |
888 | scan.w[0] = a->Pos.w; | 888 | scan.w[0] = a->Pos.w; |
889 | 889 | ||
890 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 890 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
891 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 891 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
892 | { | 892 | { |
893 | scan.c[i][0] = a->Color[i]; | 893 | scan.c[i][0] = a->Color[i]; |
894 | scan.slopeC[i][0] = (c->Color[i] - a->Color[i]) * scan.invDeltaY[0]; | 894 | scan.slopeC[i][0] = (c->Color[i] - a->Color[i]) * scan.invDeltaY[0]; |
895 | } | 895 | } |
896 | #endif | 896 | #endif |
897 | 897 | ||
898 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 898 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
899 | { | 899 | { |
900 | scan.t[i][0] = a->Tex[i]; | 900 | scan.t[i][0] = a->Tex[i]; |
901 | scan.slopeT[i][0] = (c->Tex[i] - a->Tex[i]) * scan.invDeltaY[0]; | 901 | scan.slopeT[i][0] = (c->Tex[i] - a->Tex[i]) * scan.invDeltaY[0]; |
902 | } | 902 | } |
903 | 903 | ||
904 | // top left fill convention y run | 904 | // top left fill convention y run |
905 | s32 yStart; | 905 | s32 yStart; |
906 | s32 yEnd; | 906 | s32 yEnd; |
907 | 907 | ||
908 | f32 subPixel; | 908 | f32 subPixel; |
909 | 909 | ||
910 | // rasterize upper sub-triangle | 910 | // rasterize upper sub-triangle |
911 | if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) | 911 | if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) |
912 | { | 912 | { |
913 | // calculate slopes for top edge | 913 | // calculate slopes for top edge |
914 | scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; | 914 | scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; |
915 | scan.x[1] = a->Pos.x; | 915 | scan.x[1] = a->Pos.x; |
916 | 916 | ||
917 | scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; | 917 | scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; |
918 | scan.w[1] = a->Pos.w; | 918 | scan.w[1] = a->Pos.w; |
919 | 919 | ||
920 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 920 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
921 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 921 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
922 | { | 922 | { |
923 | scan.c[i][1] = a->Color[i]; | 923 | scan.c[i][1] = a->Color[i]; |
924 | scan.slopeC[i][1] = (b->Color[i] - a->Color[i]) * scan.invDeltaY[1]; | 924 | scan.slopeC[i][1] = (b->Color[i] - a->Color[i]) * scan.invDeltaY[1]; |
925 | } | 925 | } |
926 | #endif | 926 | #endif |
927 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 927 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
928 | { | 928 | { |
929 | scan.t[i][1] = a->Tex[i]; | 929 | scan.t[i][1] = a->Tex[i]; |
930 | scan.slopeT[i][1] = (b->Tex[i] - a->Tex[i]) * scan.invDeltaY[1]; | 930 | scan.slopeT[i][1] = (b->Tex[i] - a->Tex[i]) * scan.invDeltaY[1]; |
931 | } | 931 | } |
932 | 932 | ||
933 | // apply top-left fill convention, top part | 933 | // apply top-left fill convention, top part |
934 | yStart = core::ceil32( a->Pos.y ); | 934 | yStart = core::ceil32( a->Pos.y ); |
935 | yEnd = core::ceil32( b->Pos.y ) - 1; | 935 | yEnd = core::ceil32( b->Pos.y ) - 1; |
936 | 936 | ||
937 | subPixel = ( (f32) yStart ) - a->Pos.y; | 937 | subPixel = ( (f32) yStart ) - a->Pos.y; |
938 | 938 | ||
939 | // correct to pixel center | 939 | // correct to pixel center |
940 | scan.x[0] += scan.slopeX[0] * subPixel; | 940 | scan.x[0] += scan.slopeX[0] * subPixel; |
941 | scan.x[1] += scan.slopeX[1] * subPixel; | 941 | scan.x[1] += scan.slopeX[1] * subPixel; |
942 | 942 | ||
943 | scan.w[0] += scan.slopeW[0] * subPixel; | 943 | scan.w[0] += scan.slopeW[0] * subPixel; |
944 | scan.w[1] += scan.slopeW[1] * subPixel; | 944 | scan.w[1] += scan.slopeW[1] * subPixel; |
945 | 945 | ||
946 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 946 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
947 | { | 947 | { |
948 | scan.c[i][0] += scan.slopeC[i][0] * subPixel; | 948 | scan.c[i][0] += scan.slopeC[i][0] * subPixel; |
949 | scan.c[i][1] += scan.slopeC[i][1] * subPixel; | 949 | scan.c[i][1] += scan.slopeC[i][1] * subPixel; |
950 | } | 950 | } |
951 | 951 | ||
952 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 952 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
953 | { | 953 | { |
954 | scan.t[i][0] += scan.slopeT[i][0] * subPixel; | 954 | scan.t[i][0] += scan.slopeT[i][0] * subPixel; |
955 | scan.t[i][1] += scan.slopeT[i][1] * subPixel; | 955 | scan.t[i][1] += scan.slopeT[i][1] * subPixel; |
956 | } | 956 | } |
957 | 957 | ||
958 | // rasterize the edge scanlines | 958 | // rasterize the edge scanlines |
959 | for( line.y = yStart; line.y <= yEnd; ++line.y) | 959 | for( line.y = yStart; line.y <= yEnd; ++line.y) |
960 | { | 960 | { |
961 | line.x[scan.left] = scan.x[0]; | 961 | line.x[scan.left] = scan.x[0]; |
962 | line.w[scan.left] = scan.w[0]; | 962 | line.w[scan.left] = scan.w[0]; |
963 | 963 | ||
964 | line.x[scan.right] = scan.x[1]; | 964 | line.x[scan.right] = scan.x[1]; |
965 | line.w[scan.right] = scan.w[1]; | 965 | line.w[scan.right] = scan.w[1]; |
966 | 966 | ||
967 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 967 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
968 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 968 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
969 | { | 969 | { |
970 | line.c[i][scan.left] = scan.c[i][0]; | 970 | line.c[i][scan.left] = scan.c[i][0]; |
971 | line.c[i][scan.right] = scan.c[i][1]; | 971 | line.c[i][scan.right] = scan.c[i][1]; |
972 | } | 972 | } |
973 | #endif | 973 | #endif |
974 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 974 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
975 | { | 975 | { |
976 | line.t[i][scan.left] = scan.t[i][0]; | 976 | line.t[i][scan.left] = scan.t[i][0]; |
977 | line.t[i][scan.right] = scan.t[i][1]; | 977 | line.t[i][scan.right] = scan.t[i][1]; |
978 | } | 978 | } |
979 | 979 | ||
980 | // render a scanline | 980 | // render a scanline |
981 | scanline (); | 981 | scanline (); |
982 | 982 | ||
983 | scan.x[0] += scan.slopeX[0]; | 983 | scan.x[0] += scan.slopeX[0]; |
984 | scan.x[1] += scan.slopeX[1]; | 984 | scan.x[1] += scan.slopeX[1]; |
985 | 985 | ||
986 | scan.w[0] += scan.slopeW[0]; | 986 | scan.w[0] += scan.slopeW[0]; |
987 | scan.w[1] += scan.slopeW[1]; | 987 | scan.w[1] += scan.slopeW[1]; |
988 | 988 | ||
989 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 989 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
990 | { | 990 | { |
991 | scan.c[i][0] += scan.slopeC[i][0]; | 991 | scan.c[i][0] += scan.slopeC[i][0]; |
992 | scan.c[i][1] += scan.slopeC[i][1]; | 992 | scan.c[i][1] += scan.slopeC[i][1]; |
993 | } | 993 | } |
994 | 994 | ||
995 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 995 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
996 | { | 996 | { |
997 | scan.t[i][0] += scan.slopeT[i][0]; | 997 | scan.t[i][0] += scan.slopeT[i][0]; |
998 | scan.t[i][1] += scan.slopeT[i][1]; | 998 | scan.t[i][1] += scan.slopeT[i][1]; |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | } | 1001 | } |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | // rasterize lower sub-triangle | 1004 | // rasterize lower sub-triangle |
1005 | if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) | 1005 | if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) |
1006 | { | 1006 | { |
1007 | // advance to middle point | 1007 | // advance to middle point |
1008 | if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) | 1008 | if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) |
1009 | { | 1009 | { |
1010 | temp[0] = b->Pos.y - a->Pos.y; // dy | 1010 | temp[0] = b->Pos.y - a->Pos.y; // dy |
1011 | 1011 | ||
1012 | scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; | 1012 | scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; |
1013 | scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; | 1013 | scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; |
1014 | 1014 | ||
1015 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 1015 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
1016 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 1016 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
1017 | { | 1017 | { |
1018 | scan.c[i][0] = a->Color[i] + scan.slopeC[i][0] * temp[0]; | 1018 | scan.c[i][0] = a->Color[i] + scan.slopeC[i][0] * temp[0]; |
1019 | } | 1019 | } |
1020 | #endif | 1020 | #endif |
1021 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 1021 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
1022 | { | 1022 | { |
1023 | scan.t[i][0] = a->Tex[i] + scan.slopeT[i][0] * temp[0]; | 1023 | scan.t[i][0] = a->Tex[i] + scan.slopeT[i][0] * temp[0]; |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | // calculate slopes for bottom edge | 1027 | // calculate slopes for bottom edge |
1028 | scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; | 1028 | scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; |
1029 | scan.x[1] = b->Pos.x; | 1029 | scan.x[1] = b->Pos.x; |
1030 | 1030 | ||
1031 | scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; | 1031 | scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; |
1032 | scan.w[1] = b->Pos.w; | 1032 | scan.w[1] = b->Pos.w; |
1033 | 1033 | ||
1034 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 1034 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
1035 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 1035 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
1036 | { | 1036 | { |
1037 | scan.c[i][1] = b->Color[i]; | 1037 | scan.c[i][1] = b->Color[i]; |
1038 | scan.slopeC[i][1] = (c->Color[i] - b->Color[i]) * scan.invDeltaY[2]; | 1038 | scan.slopeC[i][1] = (c->Color[i] - b->Color[i]) * scan.invDeltaY[2]; |
1039 | } | 1039 | } |
1040 | #endif | 1040 | #endif |
1041 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 1041 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
1042 | { | 1042 | { |
1043 | scan.t[i][1] = b->Tex[i]; | 1043 | scan.t[i][1] = b->Tex[i]; |
1044 | scan.slopeT[i][1] = (c->Tex[i] - b->Tex[i]) * scan.invDeltaY[2]; | 1044 | scan.slopeT[i][1] = (c->Tex[i] - b->Tex[i]) * scan.invDeltaY[2]; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | // apply top-left fill convention, top part | 1047 | // apply top-left fill convention, top part |
1048 | yStart = core::ceil32( b->Pos.y ); | 1048 | yStart = core::ceil32( b->Pos.y ); |
1049 | yEnd = core::ceil32( c->Pos.y ) - 1; | 1049 | yEnd = core::ceil32( c->Pos.y ) - 1; |
1050 | 1050 | ||
1051 | 1051 | ||
1052 | subPixel = ( (f32) yStart ) - b->Pos.y; | 1052 | subPixel = ( (f32) yStart ) - b->Pos.y; |
1053 | 1053 | ||
1054 | // correct to pixel center | 1054 | // correct to pixel center |
1055 | scan.x[0] += scan.slopeX[0] * subPixel; | 1055 | scan.x[0] += scan.slopeX[0] * subPixel; |
1056 | scan.x[1] += scan.slopeX[1] * subPixel; | 1056 | scan.x[1] += scan.slopeX[1] * subPixel; |
1057 | 1057 | ||
1058 | scan.w[0] += scan.slopeW[0] * subPixel; | 1058 | scan.w[0] += scan.slopeW[0] * subPixel; |
1059 | scan.w[1] += scan.slopeW[1] * subPixel; | 1059 | scan.w[1] += scan.slopeW[1] * subPixel; |
1060 | 1060 | ||
1061 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 1061 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
1062 | { | 1062 | { |
1063 | scan.c[i][0] += scan.slopeC[i][0] * subPixel; | 1063 | scan.c[i][0] += scan.slopeC[i][0] * subPixel; |
1064 | scan.c[i][1] += scan.slopeC[i][1] * subPixel; | 1064 | scan.c[i][1] += scan.slopeC[i][1] * subPixel; |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 1067 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
1068 | { | 1068 | { |
1069 | scan.t[i][0] += scan.slopeT[i][0] * subPixel; | 1069 | scan.t[i][0] += scan.slopeT[i][0] * subPixel; |
1070 | scan.t[i][1] += scan.slopeT[i][1] * subPixel; | 1070 | scan.t[i][1] += scan.slopeT[i][1] * subPixel; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | // rasterize the edge scanlines | 1073 | // rasterize the edge scanlines |
1074 | for( line.y = yStart; line.y <= yEnd; ++line.y) | 1074 | for( line.y = yStart; line.y <= yEnd; ++line.y) |
1075 | { | 1075 | { |
1076 | line.x[scan.left] = scan.x[0]; | 1076 | line.x[scan.left] = scan.x[0]; |
1077 | line.w[scan.left] = scan.w[0]; | 1077 | line.w[scan.left] = scan.w[0]; |
1078 | 1078 | ||
1079 | line.x[scan.right] = scan.x[1]; | 1079 | line.x[scan.right] = scan.x[1]; |
1080 | line.w[scan.right] = scan.w[1]; | 1080 | line.w[scan.right] = scan.w[1]; |
1081 | 1081 | ||
1082 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 1082 | #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
1083 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) | 1083 | for ( i = 0; i != ShaderParam.ColorUnits; ++i ) |
1084 | { | 1084 | { |
1085 | line.c[i][scan.left] = scan.c[i][0]; | 1085 | line.c[i][scan.left] = scan.c[i][0]; |
1086 | line.c[i][scan.right] = scan.c[i][1]; | 1086 | line.c[i][scan.right] = scan.c[i][1]; |
1087 | } | 1087 | } |
1088 | #endif | 1088 | #endif |
1089 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 1089 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
1090 | { | 1090 | { |
1091 | line.t[i][scan.left] = scan.t[i][0]; | 1091 | line.t[i][scan.left] = scan.t[i][0]; |
1092 | line.t[i][scan.right] = scan.t[i][1]; | 1092 | line.t[i][scan.right] = scan.t[i][1]; |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | // render a scanline | 1095 | // render a scanline |
1096 | scanline (); | 1096 | scanline (); |
1097 | 1097 | ||
1098 | scan.x[0] += scan.slopeX[0]; | 1098 | scan.x[0] += scan.slopeX[0]; |
1099 | scan.x[1] += scan.slopeX[1]; | 1099 | scan.x[1] += scan.slopeX[1]; |
1100 | 1100 | ||
1101 | scan.w[0] += scan.slopeW[0]; | 1101 | scan.w[0] += scan.slopeW[0]; |
1102 | scan.w[1] += scan.slopeW[1]; | 1102 | scan.w[1] += scan.slopeW[1]; |
1103 | 1103 | ||
1104 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 1104 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
1105 | { | 1105 | { |
1106 | scan.c[i][0] += scan.slopeC[i][0]; | 1106 | scan.c[i][0] += scan.slopeC[i][0]; |
1107 | scan.c[i][1] += scan.slopeC[i][1]; | 1107 | scan.c[i][1] += scan.slopeC[i][1]; |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) | 1110 | for ( i = 0; i != ShaderParam.TextureUnits; ++i ) |
1111 | { | 1111 | { |
1112 | scan.t[i][0] += scan.slopeT[i][0]; | 1112 | scan.t[i][0] += scan.slopeT[i][0]; |
1113 | scan.t[i][1] += scan.slopeT[i][1]; | 1113 | scan.t[i][1] += scan.slopeT[i][1]; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | 1119 | ||
1120 | } // end namespace video | 1120 | } // end namespace video |
1121 | } // end namespace irr | 1121 | } // end namespace irr |
1122 | 1122 | ||
1123 | 1123 | ||
1124 | namespace irr | 1124 | namespace irr |
1125 | { | 1125 | { |
1126 | namespace video | 1126 | namespace video |
1127 | { | 1127 | { |
1128 | 1128 | ||
1129 | 1129 | ||
1130 | 1130 | ||
1131 | //! creates a flat triangle renderer | 1131 | //! creates a flat triangle renderer |
1132 | IBurningShader* createTriangleRendererReference(CBurningVideoDriver* driver) | 1132 | IBurningShader* createTriangleRendererReference(CBurningVideoDriver* driver) |
1133 | { | 1133 | { |
1134 | return new CBurningShader_Raster_Reference(driver); | 1134 | return new CBurningShader_Raster_Reference(driver); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | 1137 | ||
1138 | } // end namespace video | 1138 | } // end namespace video |
1139 | } // end namespace irr | 1139 | } // end namespace irr |
1140 | 1140 | ||
1141 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 1141 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ |
1142 | 1142 | ||
1143 | 1143 | ||