2 * Direct3D state management
4 * Copyright 2006 Stefan Dösinger for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
30 #define GLINFO_LOCATION ((IWineD3DImpl *)(stateblock->wineD3DDevice->wineD3D))->gl_info
32 static void state_unknown(DWORD state, IWineD3DStateBlockImpl *stateblock) {
33 /* State which does exist, but wined3d doesn't know about */
34 if(STATE_IS_RENDER(state)) {
35 WINED3DRENDERSTATETYPE RenderState = state - STATE_RENDER(0);
36 FIXME("(%s, %d) Unknown renderstate\n", debug_d3drenderstate(RenderState), stateblock->renderState[RenderState]);
38 FIXME("(%d) Unknown state with unknown type\n", state);
42 static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock) {
43 /* Used for states which are not mapped to a gl state as-is, but used somehow different,
44 * e.g as a parameter for drawing, or which are unimplemented in windows d3d
46 if(STATE_IS_RENDER(state)) {
47 WINED3DRENDERSTATETYPE RenderState = state - STATE_RENDER(0);
48 TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState), stateblock->renderState[RenderState]);
50 /* Shouldn't have an unknown type here */
51 FIXME("%d no direct mapping to gl of state with unknown type\n", state);
55 static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock) {
56 /* Print a WARN, this allows the stateblock code to loop over all states to generate a display
57 * list without causing confusing terminal output. Deliberately no special debug name here
58 * because its undefined.
60 WARN("undefined state %d\n", state);
63 static void state_fillmode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
64 D3DFILLMODE Value = stateblock->renderState[WINED3DRS_FILLMODE];
68 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
69 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
71 case D3DFILL_WIREFRAME:
72 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
73 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
76 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
77 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
80 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value);
84 static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock) {
86 /* TODO: Lighting is only enabled if Vertex normals are passed by the application,
87 * so merge the lighting render state with the vertex declaration once it is available
90 if (stateblock->renderState[WINED3DRS_LIGHTING]) {
91 glEnable(GL_LIGHTING);
92 checkGLcall("glEnable GL_LIGHTING");
94 glDisable(GL_LIGHTING);
95 checkGLcall("glDisable GL_LIGHTING");
99 static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
100 switch ((WINED3DZBUFFERTYPE) stateblock->renderState[WINED3DRS_ZENABLE]) {
101 case WINED3DZB_FALSE:
102 glDisable(GL_DEPTH_TEST);
103 checkGLcall("glDisable GL_DEPTH_TEST");
106 glEnable(GL_DEPTH_TEST);
107 checkGLcall("glEnable GL_DEPTH_TEST");
110 glEnable(GL_DEPTH_TEST);
111 checkGLcall("glEnable GL_DEPTH_TEST");
112 FIXME("W buffer is not well handled\n");
115 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock->renderState[WINED3DRS_ZENABLE]);
119 static void state_cullmode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
120 /* TODO: Put this into the offscreen / onscreen rendering block due to device->render_offscreen */
122 /* If we are culling "back faces with clockwise vertices" then
123 set front faces to be counter clockwise and enable culling
125 switch ((WINED3DCULL) stateblock->renderState[WINED3DRS_CULLMODE]) {
126 case WINED3DCULL_NONE:
127 glDisable(GL_CULL_FACE);
128 checkGLcall("glDisable GL_CULL_FACE");
131 glEnable(GL_CULL_FACE);
132 checkGLcall("glEnable GL_CULL_FACE");
133 if (stateblock->wineD3DDevice->render_offscreen) {
135 checkGLcall("glFrontFace GL_CW");
138 checkGLcall("glFrontFace GL_CCW");
142 case WINED3DCULL_CCW:
143 glEnable(GL_CULL_FACE);
144 checkGLcall("glEnable GL_CULL_FACE");
145 if (stateblock->wineD3DDevice->render_offscreen) {
147 checkGLcall("glFrontFace GL_CCW");
150 checkGLcall("glFrontFace GL_CW");
155 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock->renderState[WINED3DRS_CULLMODE]);
159 static void state_shademode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
160 switch ((WINED3DSHADEMODE) stateblock->renderState[WINED3DRS_SHADEMODE]) {
161 case WINED3DSHADE_FLAT:
162 glShadeModel(GL_FLAT);
163 checkGLcall("glShadeModel(GL_FLAT)");
165 case WINED3DSHADE_GOURAUD:
166 glShadeModel(GL_SMOOTH);
167 checkGLcall("glShadeModel(GL_SMOOTH)");
169 case WINED3DSHADE_PHONG:
170 FIXME("WINED3DSHADE_PHONG isn't supported\n");
173 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock->renderState[WINED3DRS_SHADEMODE]);
177 static void state_ditherenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
178 if (stateblock->renderState[WINED3DRS_DITHERENABLE]) {
180 checkGLcall("glEnable GL_DITHER");
182 glDisable(GL_DITHER);
183 checkGLcall("glDisable GL_DITHER");
187 static void state_zwritenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
188 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
189 * this has to be merged with ZENABLE and ZFUNC
191 if (stateblock->renderState[WINED3DRS_ZWRITEENABLE]) {
193 checkGLcall("glDepthMask(1)");
196 checkGLcall("glDepthMask(0)");
200 static void state_zfunc(DWORD state, IWineD3DStateBlockImpl *stateblock) {
201 int glParm = CompareFunc(stateblock->renderState[WINED3DRS_ZFUNC]);
205 checkGLcall("glDepthFunc");
209 static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock) {
211 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_AMBIENT], col);
213 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
214 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
215 checkGLcall("glLightModel for MODEL_AMBIENT");
218 static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock) {
219 int srcBlend = GL_ZERO;
220 int dstBlend = GL_ZERO;
223 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
224 /* TODO: Is enabling blending really affected by the blendfactor??? */
225 if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
226 stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
227 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE] ||
228 stateblock->renderState[WINED3DRS_BLENDFACTOR] != 0xFFFFFFFF) {
230 checkGLcall("glEnable GL_BLEND");
233 checkGLcall("glDisable GL_BLEND");
234 /* Nothing more to do - get out */
238 switch (stateblock->renderState[WINED3DRS_SRCBLEND]) {
239 case WINED3DBLEND_ZERO : srcBlend = GL_ZERO; break;
240 case WINED3DBLEND_ONE : srcBlend = GL_ONE; break;
241 case WINED3DBLEND_SRCCOLOR : srcBlend = GL_SRC_COLOR; break;
242 case WINED3DBLEND_INVSRCCOLOR : srcBlend = GL_ONE_MINUS_SRC_COLOR; break;
243 case WINED3DBLEND_SRCALPHA : srcBlend = GL_SRC_ALPHA; break;
244 case WINED3DBLEND_INVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA; break;
245 case WINED3DBLEND_DESTALPHA : srcBlend = GL_DST_ALPHA; break;
246 case WINED3DBLEND_INVDESTALPHA : srcBlend = GL_ONE_MINUS_DST_ALPHA; break;
247 case WINED3DBLEND_DESTCOLOR : srcBlend = GL_DST_COLOR; break;
248 case WINED3DBLEND_INVDESTCOLOR : srcBlend = GL_ONE_MINUS_DST_COLOR; break;
249 case WINED3DBLEND_SRCALPHASAT : srcBlend = GL_SRC_ALPHA_SATURATE; break;
251 case WINED3DBLEND_BOTHSRCALPHA : srcBlend = GL_SRC_ALPHA;
252 dstBlend = GL_SRC_ALPHA;
255 case WINED3DBLEND_BOTHINVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA;
256 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
259 case WINED3DBLEND_BLENDFACTOR : srcBlend = GL_CONSTANT_COLOR; break;
260 case WINED3DBLEND_INVBLENDFACTOR : srcBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
262 FIXME("Unrecognized src blend value %d\n", stateblock->renderState[WINED3DRS_SRCBLEND]);
265 switch (stateblock->renderState[WINED3DRS_DESTBLEND]) {
266 case WINED3DBLEND_ZERO : dstBlend = GL_ZERO; break;
267 case WINED3DBLEND_ONE : dstBlend = GL_ONE; break;
268 case WINED3DBLEND_SRCCOLOR : dstBlend = GL_SRC_COLOR; break;
269 case WINED3DBLEND_INVSRCCOLOR : dstBlend = GL_ONE_MINUS_SRC_COLOR; break;
270 case WINED3DBLEND_SRCALPHA : dstBlend = GL_SRC_ALPHA; break;
271 case WINED3DBLEND_INVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA; break;
272 case WINED3DBLEND_DESTALPHA : dstBlend = GL_DST_ALPHA; break;
273 case WINED3DBLEND_INVDESTALPHA : dstBlend = GL_ONE_MINUS_DST_ALPHA; break;
274 case WINED3DBLEND_DESTCOLOR : dstBlend = GL_DST_COLOR; break;
275 case WINED3DBLEND_INVDESTCOLOR : dstBlend = GL_ONE_MINUS_DST_COLOR; break;
276 case WINED3DBLEND_SRCALPHASAT : dstBlend = GL_SRC_ALPHA_SATURATE; break;
278 case WINED3DBLEND_BOTHSRCALPHA : dstBlend = GL_SRC_ALPHA;
279 srcBlend = GL_SRC_ALPHA;
282 case WINED3DBLEND_BOTHINVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA;
283 srcBlend = GL_ONE_MINUS_SRC_ALPHA;
286 case D3DBLEND_BLENDFACTOR : dstBlend = GL_CONSTANT_COLOR; break;
287 case D3DBLEND_INVBLENDFACTOR : dstBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
289 FIXME("Unrecognized dst blend value %d\n", stateblock->renderState[WINED3DRS_DESTBLEND]);
292 if(stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
293 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
294 glEnable(GL_LINE_SMOOTH);
295 checkGLcall("glEnable(GL_LINE_SMOOTH)");
296 if(srcBlend != GL_SRC_ALPHA) {
297 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible src blending param - what to do?\n");
298 srcBlend = GL_SRC_ALPHA;
300 if(dstBlend != GL_ONE_MINUS_SRC_ALPHA) {
301 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible dst blending param - what to do?\n");
302 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
305 glDisable(GL_LINE_SMOOTH);
306 checkGLcall("glDisable(GL_LINE_SMOOTH)");
309 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend, dstBlend);
310 glBlendFunc(srcBlend, dstBlend);
311 checkGLcall("glBlendFunc");
313 /* TODO: Remove when state management done */
314 stateblock->wineD3DDevice->dstBlend = dstBlend;
315 stateblock->wineD3DDevice->srcBlend = srcBlend;
317 TRACE("Setting BlendFactor to %d\n", stateblock->renderState[WINED3DRS_BLENDFACTOR]);
318 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_BLENDFACTOR], col);
319 glBlendColor (col[0],col[1],col[2],col[3]);
320 checkGLcall("glBlendColor");
323 static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock) {
326 BOOL enable_ckey = FALSE;
328 IWineD3DSurfaceImpl *surf;
330 /* Find out if the texture on the first stage has a ckey set
331 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
332 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
333 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
334 * in case it finds some texture+colorkeyenable combination which needs extra care.
336 if(stateblock->textures[0]) {
337 surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)stateblock->textures[0])->surfaces[0];
338 if(surf->CKeyFlags & DDSD_CKSRCBLT) enable_ckey = TRUE;
341 if (stateblock->renderState[WINED3DRS_ALPHATESTENABLE] ||
342 (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey)) {
343 glEnable(GL_ALPHA_TEST);
344 checkGLcall("glEnable GL_ALPHA_TEST");
346 glDisable(GL_ALPHA_TEST);
347 checkGLcall("glDisable GL_ALPHA_TEST");
348 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
354 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey) {
355 glParm = GL_NOTEQUAL;
358 ref = ((float) stateblock->renderState[WINED3DRS_ALPHAREF]) / 255.0f;
359 glParm = CompareFunc(stateblock->renderState[WINED3DRS_ALPHAFUNC]);
362 stateblock->wineD3DDevice->alphafunc = glParm; /* Remove when state management done */
363 glAlphaFunc(glParm, ref);
364 checkGLcall("glAlphaFunc");
366 /* TODO: Some texture blending operations seem to affect the alpha test */
369 static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock) {
370 DWORD enable = 0xFFFFFFFF;
371 DWORD disable = 0x00000000;
373 /* TODO: Keep track of previously enabled clipplanes to avoid unneccessary resetting
374 * of already set values
377 /* If enabling / disabling all
378 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
380 if (stateblock->renderState[WINED3DRS_CLIPPING]) {
381 enable = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
382 disable = ~stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
384 disable = 0xffffffff;
388 if (enable & WINED3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
389 if (enable & WINED3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
390 if (enable & WINED3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
391 if (enable & WINED3DCLIPPLANE3) { glEnable(GL_CLIP_PLANE3); checkGLcall("glEnable(clip plane 3)"); }
392 if (enable & WINED3DCLIPPLANE4) { glEnable(GL_CLIP_PLANE4); checkGLcall("glEnable(clip plane 4)"); }
393 if (enable & WINED3DCLIPPLANE5) { glEnable(GL_CLIP_PLANE5); checkGLcall("glEnable(clip plane 5)"); }
395 if (disable & WINED3DCLIPPLANE0) { glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)"); }
396 if (disable & WINED3DCLIPPLANE1) { glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)"); }
397 if (disable & WINED3DCLIPPLANE2) { glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)"); }
398 if (disable & WINED3DCLIPPLANE3) { glDisable(GL_CLIP_PLANE3); checkGLcall("glDisable(clip plane 3)"); }
399 if (disable & WINED3DCLIPPLANE4) { glDisable(GL_CLIP_PLANE4); checkGLcall("glDisable(clip plane 4)"); }
400 if (disable & WINED3DCLIPPLANE5) { glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)"); }
402 /** update clipping status */
404 stateblock->clip_status.ClipUnion = 0;
405 stateblock->clip_status.ClipIntersection = 0xFFFFFFFF;
407 stateblock->clip_status.ClipUnion = 0;
408 stateblock->clip_status.ClipIntersection = 0;
412 static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock) {
413 int glParm = GL_FUNC_ADD;
415 if(!GL_SUPPORT(EXT_BLEND_MINMAX)) {
416 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
420 switch ((WINED3DBLENDOP) stateblock->renderState[WINED3DRS_BLENDOP]) {
421 case WINED3DBLENDOP_ADD : glParm = GL_FUNC_ADD; break;
422 case WINED3DBLENDOP_SUBTRACT : glParm = GL_FUNC_SUBTRACT; break;
423 case WINED3DBLENDOP_REVSUBTRACT : glParm = GL_FUNC_REVERSE_SUBTRACT; break;
424 case WINED3DBLENDOP_MIN : glParm = GL_MIN; break;
425 case WINED3DBLENDOP_MAX : glParm = GL_MAX; break;
427 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock->renderState[WINED3DRS_BLENDOP]);
430 TRACE("glBlendEquation(%x)\n", glParm);
431 GL_EXTCALL(glBlendEquation(glParm));
432 checkGLcall("glBlendEquation");
436 state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
437 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
438 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
439 * specular color. This is wrong:
440 * Separate specular color means the specular colour is maintained separately, whereas
441 * single color means it is merged in. However in both cases they are being used to
443 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
444 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
448 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
449 * Instead, we need to setup the FinalCombiner properly.
451 * The default setup for the FinalCombiner is:
453 * <variable> <input> <mapping> <usage>
454 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
455 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
456 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
457 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
458 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
459 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
460 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
462 * That's pretty much fine as it is, except for variable B, which needs to take
463 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
464 * whether WINED3DRS_SPECULARENABLE is enabled or not.
467 TRACE("Setting specular enable state\n");
468 /* TODO: Add to the material setting functions */
469 if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
470 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
471 checkGLcall("glMaterialfv");
472 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
473 glEnable(GL_COLOR_SUM_EXT);
475 TRACE("Specular colors cannot be enabled in this version of opengl\n");
477 checkGLcall("glEnable(GL_COLOR_SUM)");
479 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
480 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
481 checkGLcall("glFinalCombinerInputNV()");
484 float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
486 /* for the case of enabled lighting: */
487 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
488 checkGLcall("glMaterialfv");
490 /* for the case of disabled lighting: */
491 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
492 glDisable(GL_COLOR_SUM_EXT);
494 TRACE("Specular colors cannot be disabled in this version of opengl\n");
496 checkGLcall("glDisable(GL_COLOR_SUM)");
498 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
499 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
500 checkGLcall("glFinalCombinerInputNV()");
505 static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
508 /* Note the texture color applies to all textures whereas
509 * GL_TEXTURE_ENV_COLOR applies to active only
512 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
514 if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
515 /* And now the default texture color as well */
516 for (i = 0; i < GL_LIMITS(texture_stages); i++) {
517 /* Note the WINED3DRS value applies to all textures, but GL has one
518 * per texture, so apply it now ready to be used!
520 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
521 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
522 checkGLcall("glActiveTextureARB");
524 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
527 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
528 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
534 renderstate_stencil_twosided(IWineD3DStateBlockImpl *stateblock, GLint face, GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass ) {
535 #if 0 /* Don't use OpenGL 2.0 calls for now */
536 if(GL_EXTCALL(glStencilFuncSeparate) && GL_EXTCALL(glStencilOpSeparate)) {
537 GL_EXTCALL(glStencilFuncSeparate(face, func, ref, mask));
538 checkGLcall("glStencilFuncSeparate(...)");
539 GL_EXTCALL(glStencilOpSeparate(face, stencilFail, depthFail, stencilPass));
540 checkGLcall("glStencilOpSeparate(...)");
544 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE)) {
545 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
546 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
547 GL_EXTCALL(glActiveStencilFaceEXT(face));
548 checkGLcall("glActiveStencilFaceEXT(...)");
549 glStencilFunc(func, ref, mask);
550 checkGLcall("glStencilFunc(...)");
551 glStencilOp(stencilFail, depthFail, stencilPass);
552 checkGLcall("glStencilOp(...)");
553 } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL)) {
554 GL_EXTCALL(glStencilFuncSeparateATI(face, func, ref, mask));
555 checkGLcall("glStencilFuncSeparateATI(...)");
556 GL_EXTCALL(glStencilOpSeparateATI(face, stencilFail, depthFail, stencilPass));
557 checkGLcall("glStencilOpSeparateATI(...)");
559 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
564 state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock) {
565 DWORD onesided_enable = FALSE;
566 DWORD twosided_enable = FALSE;
567 GLint func = GL_ALWAYS;
568 GLint func_ccw = GL_ALWAYS;
571 GLint stencilFail = GL_KEEP;
572 GLint depthFail = GL_KEEP;
573 GLint stencilPass = GL_KEEP;
574 GLint stencilFail_ccw = GL_KEEP;
575 GLint depthFail_ccw = GL_KEEP;
576 GLint stencilPass_ccw = GL_KEEP;
578 if( stateblock->set.renderState[WINED3DRS_STENCILENABLE] )
579 onesided_enable = stateblock->renderState[WINED3DRS_STENCILENABLE];
580 if( stateblock->set.renderState[WINED3DRS_TWOSIDEDSTENCILMODE] )
581 twosided_enable = stateblock->renderState[WINED3DRS_TWOSIDEDSTENCILMODE];
582 if( stateblock->set.renderState[WINED3DRS_STENCILFUNC] )
583 if( !( func = CompareFunc(stateblock->renderState[WINED3DRS_STENCILFUNC]) ) )
585 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFUNC] )
586 if( !( func_ccw = CompareFunc(stateblock->renderState[WINED3DRS_CCW_STENCILFUNC]) ) )
588 if( stateblock->set.renderState[WINED3DRS_STENCILREF] )
589 ref = stateblock->renderState[WINED3DRS_STENCILREF];
590 if( stateblock->set.renderState[WINED3DRS_STENCILMASK] )
591 mask = stateblock->renderState[WINED3DRS_STENCILMASK];
592 if( stateblock->set.renderState[WINED3DRS_STENCILFAIL] )
593 stencilFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILFAIL]);
594 if( stateblock->set.renderState[WINED3DRS_STENCILZFAIL] )
595 depthFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILZFAIL]);
596 if( stateblock->set.renderState[WINED3DRS_STENCILPASS] )
597 stencilPass = StencilOp(stateblock->renderState[WINED3DRS_STENCILPASS]);
598 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFAIL] )
599 stencilFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILFAIL]);
600 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILZFAIL] )
601 depthFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILZFAIL]);
602 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILPASS] )
603 stencilPass_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILPASS]);
605 TRACE("(onesided %d, twosided %d, ref %x, mask %x, \
606 GL_FRONT: func: %x, fail %x, zfail %x, zpass %x \
607 GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
608 onesided_enable, twosided_enable, ref, mask,
609 func, stencilFail, depthFail, stencilPass,
610 func_ccw, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
612 if (twosided_enable) {
613 renderstate_stencil_twosided(stateblock, GL_FRONT, func, ref, mask, stencilFail, depthFail, stencilPass);
614 renderstate_stencil_twosided(stateblock, GL_BACK, func_ccw, ref, mask, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
616 if (onesided_enable) {
617 glEnable(GL_STENCIL_TEST);
618 checkGLcall("glEnable GL_STENCIL_TEST");
619 glStencilFunc(func, ref, mask);
620 checkGLcall("glStencilFunc(...)");
621 glStencilOp(stencilFail, depthFail, stencilPass);
622 checkGLcall("glStencilOp(...)");
624 glDisable(GL_STENCIL_TEST);
625 checkGLcall("glDisable GL_STENCIL_TEST");
630 static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
631 glStencilMask(stateblock->renderState[WINED3DRS_STENCILWRITEMASK]);
632 checkGLcall("glStencilMask");
635 static void state_fog(DWORD state, IWineD3DStateBlockImpl *stateblock) {
636 /* TODO: Put this into the vertex type block once that is in the state table */
637 BOOL fogenable = stateblock->renderState[WINED3DRS_FOGENABLE];
638 float fogstart, fogend;
646 /* No fog? Disable it, and we're done :-) */
648 checkGLcall("glDisable GL_FOG");
651 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGSTART];
652 fogstart = tmpvalue.f;
653 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGEND];
657 /* Activate when vertex shaders are in the state table */
658 if(stateblock->vertexShader && ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function &&
659 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog) {
660 glFogi(GL_FOG_MODE, GL_LINEAR);
661 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
664 stateblock->wineD3DDevice->last_was_foggy_shader = TRUE;
668 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
669 * the system will apply only pixel(=table) fog effects."
671 /* else */ if(stateblock->renderState[WINED3DRS_FOGTABLEMODE] == D3DFOG_NONE) {
672 glHint(GL_FOG_HINT, GL_FASTEST);
673 checkGLcall("glHint(GL_FOG_HINT, GL_FASTEST)");
675 stateblock->wineD3DDevice->last_was_foggy_shader = FALSE;
677 switch (stateblock->renderState[WINED3DRS_FOGVERTEXMODE]) {
678 /* Processed vertices have their fog factor stored in the specular value. Fall too the none case.
679 * If we are drawing untransformed vertices atm, d3ddevice_set_ortho will update the fog
682 if(!stateblock->wineD3DDevice->last_was_rhw) {
683 glFogi(GL_FOG_MODE, GL_EXP);
684 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
685 if(GL_SUPPORT(EXT_FOG_COORD)) {
686 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
687 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
693 if(!stateblock->wineD3DDevice->last_was_rhw) {
694 glFogi(GL_FOG_MODE, GL_EXP2);
695 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
696 if(GL_SUPPORT(EXT_FOG_COORD)) {
697 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
698 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
703 case D3DFOG_LINEAR: {
704 if(!stateblock->wineD3DDevice->last_was_rhw) {
705 glFogi(GL_FOG_MODE, GL_LINEAR);
706 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
707 if(GL_SUPPORT(EXT_FOG_COORD)) {
708 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
709 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
715 /* Both are none? According to msdn the alpha channel of the specular
716 * color contains a fog factor. Set it in drawStridedSlow.
717 * Same happens with Vertexfog on transformed vertices
719 if(GL_SUPPORT(EXT_FOG_COORD)) {
720 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
721 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)\n");
722 glFogi(GL_FOG_MODE, GL_LINEAR);
723 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
727 /* Disable GL fog, handle this in software in drawStridedSlow */
732 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock->renderState[WINED3DRS_FOGVERTEXMODE]);
735 glHint(GL_FOG_HINT, GL_NICEST);
736 checkGLcall("glHint(GL_FOG_HINT, GL_NICEST)");
738 stateblock->wineD3DDevice->last_was_foggy_shader = FALSE;
740 switch (stateblock->renderState[WINED3DRS_FOGTABLEMODE]) {
742 glFogi(GL_FOG_MODE, GL_EXP);
743 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
744 if(GL_SUPPORT(EXT_FOG_COORD)) {
745 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
746 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
751 glFogi(GL_FOG_MODE, GL_EXP2);
752 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
753 if(GL_SUPPORT(EXT_FOG_COORD)) {
754 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
755 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
760 glFogi(GL_FOG_MODE, GL_LINEAR);
761 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
762 if(GL_SUPPORT(EXT_FOG_COORD)) {
763 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
764 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
768 case D3DFOG_NONE: /* Won't happen */
770 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock->renderState[WINED3DRS_FOGTABLEMODE]);
776 checkGLcall("glEnable GL_FOG");
778 glFogfv(GL_FOG_START, &fogstart);
779 checkGLcall("glFogf(GL_FOG_START, fogstart");
780 TRACE("Fog Start == %f\n", fogstart);
782 glFogfv(GL_FOG_END, &fogend);
783 checkGLcall("glFogf(GL_FOG_END, fogend");
784 TRACE("Fog End == %f\n", fogend);
787 checkGLcall("glDisable GL_FOG");
790 if (GL_SUPPORT(NV_FOG_DISTANCE)) {
791 glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV);
795 static void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
797 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_FOGCOLOR], col);
798 /* Set the default alpha blend color */
799 glFogfv(GL_FOG_COLOR, &col[0]);
800 checkGLcall("glFog GL_FOG_COLOR");
803 static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock) {
808 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGDENSITY];
809 glFogfv(GL_FOG_DENSITY, &tmpvalue.f);
810 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
813 /* TODO: Merge with primitive type + init_materials()!! */
814 static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) {
815 GLenum Parm = GL_AMBIENT_AND_DIFFUSE;
817 if (stateblock->renderState[WINED3DRS_COLORVERTEX]) {
818 TRACE("diff %d, amb %d, emis %d, spec %d\n",
819 stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE],
820 stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE],
821 stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE],
822 stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE]);
824 if (stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE] == D3DMCS_COLOR1) {
825 if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
826 Parm = GL_AMBIENT_AND_DIFFUSE;
830 } else if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
832 } else if (stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == D3DMCS_COLOR1) {
834 } else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == D3DMCS_COLOR1) {
841 if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
843 stateblock->wineD3DDevice->tracking_color = NEEDS_TRACKING;
844 stateblock->wineD3DDevice->tracking_parm = Parm;
848 if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
852 static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock) {
855 WINED3DLINEPATTERN lp;
857 tmppattern.d = stateblock->renderState[WINED3DRS_LINEPATTERN];
859 TRACE("Line pattern: repeat %d bits %x\n", tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
861 if (tmppattern.lp.wRepeatFactor) {
862 glLineStipple(tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
863 checkGLcall("glLineStipple(repeat, linepattern)");
864 glEnable(GL_LINE_STIPPLE);
865 checkGLcall("glEnable(GL_LINE_STIPPLE);");
867 glDisable(GL_LINE_STIPPLE);
868 checkGLcall("glDisable(GL_LINE_STIPPLE);");
872 static void state_zbias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
878 if (stateblock->renderState[WINED3DRS_ZBIAS]) {
879 tmpvalue.d = stateblock->renderState[WINED3DRS_ZBIAS];
880 TRACE("ZBias value %f\n", tmpvalue.f);
881 glPolygonOffset(0, -tmpvalue.f);
882 checkGLcall("glPolygonOffset(0, -Value)");
883 glEnable(GL_POLYGON_OFFSET_FILL);
884 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
885 glEnable(GL_POLYGON_OFFSET_LINE);
886 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
887 glEnable(GL_POLYGON_OFFSET_POINT);
888 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
890 glDisable(GL_POLYGON_OFFSET_FILL);
891 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
892 glDisable(GL_POLYGON_OFFSET_LINE);
893 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
894 glDisable(GL_POLYGON_OFFSET_POINT);
895 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
900 static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock) {
901 if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS]) {
902 glEnable(GL_NORMALIZE);
903 checkGLcall("glEnable(GL_NORMALIZE);");
905 glDisable(GL_NORMALIZE);
906 checkGLcall("glDisable(GL_NORMALIZE);");
910 static void state_psize(DWORD state, IWineD3DStateBlockImpl *stateblock) {
916 /* FIXME: check that pointSize isn't outside glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); or -ve */
917 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE];
918 TRACE("Set point size to %f\n", tmpvalue.f);
919 glPointSize(tmpvalue.f);
920 checkGLcall("glPointSize(...);");
923 static void state_psizemin(DWORD state, IWineD3DStateBlockImpl *stateblock) {
929 if (GL_SUPPORT(EXT_POINT_PARAMETERS)) {
930 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MIN];
931 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, tmpvalue.f);
932 checkGLcall("glPointParameterfEXT(...);");
934 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl\n");
938 static void state_psizemax(DWORD state, IWineD3DStateBlockImpl *stateblock) {
944 if (GL_SUPPORT(EXT_POINT_PARAMETERS)) {
945 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MAX];
946 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, tmpvalue.f);
947 checkGLcall("glPointParameterfEXT(...);");
949 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl\n");
953 static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock) {
954 /* TODO: Group this with the viewport */
956 * POINTSCALEENABLE controls how point size value is treated. If set to
957 * true, the point size is scaled with respect to height of viewport.
958 * When set to false point size is in pixels.
960 * http://msdn.microsoft.com/library/en-us/directx9_c/point_sprites.asp
964 GLfloat att[3] = {1.0f, 0.0f, 0.0f};
967 * Minimum valid point size for OpenGL is 1.0f. For Direct3D it is 0.0f.
968 * This means that OpenGL will clamp really small point sizes to 1.0f.
969 * To correct for this we need to multiply by the scale factor when sizes
970 * are less than 1.0f. scale_factor = 1.0f / point_size.
972 GLfloat pointSize = *((float*)&stateblock->renderState[WINED3DRS_POINTSIZE]);
973 if(pointSize > 0.0f) {
976 if(pointSize < 1.0f) {
977 scaleFactor = pointSize * pointSize;
982 if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
983 att[0] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_A]) /
984 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
985 att[1] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_B]) /
986 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
987 att[2] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_C]) /
988 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
992 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
993 GL_EXTCALL(glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
994 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...");
996 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
997 GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
998 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...");
1000 TRACE("POINT_PARAMETERS not supported in this version of opengl\n");
1004 static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1005 DWORD Value = stateblock->renderState[WINED3DRS_COLORWRITEENABLE];
1007 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1008 Value & D3DCOLORWRITEENABLE_RED ? 1 : 0,
1009 Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
1010 Value & D3DCOLORWRITEENABLE_BLUE ? 1 : 0,
1011 Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
1012 glColorMask(Value & D3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
1013 Value & D3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
1014 Value & D3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
1015 Value & D3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
1016 checkGLcall("glColorMask(...)");
1018 /* depends on WINED3DRS_COLORWRITEENABLE. */
1019 if(stateblock->renderState[WINED3DRS_COLORWRITEENABLE1] != 0x0000000F ||
1020 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2] != 0x0000000F ||
1021 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3] != 0x0000000F ) {
1022 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1023 stateblock->renderState[WINED3DRS_COLORWRITEENABLE1],
1024 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2],
1025 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3]);
1029 static void state_localviewer(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1030 if(stateblock->renderState[WINED3DRS_LOCALVIEWER]) {
1031 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
1032 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1034 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
1035 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1039 static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1040 if(stateblock->renderState[WINED3DRS_LASTPIXEL]) {
1041 TRACE("Last Pixel Drawing Enabled\n");
1043 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1047 static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1048 /* TODO: NV_POINT_SPRITE */
1049 if (!GL_SUPPORT(ARB_POINT_SPRITE)) {
1050 TRACE("Point sprites not supported\n");
1055 * Point sprites are always enabled. Value controls texture coordinate
1056 * replacement mode. Must be set true for point sprites to use
1059 glEnable(GL_POINT_SPRITE_ARB);
1060 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1062 if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) {
1063 glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, TRUE);
1064 checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, TRUE)");
1066 glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, FALSE);
1067 checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, FALSE)");
1071 const struct StateEntry StateTable[] =
1073 /* State name representative, apply function */
1074 { /* 0, Undefined */ 0, state_undefined },
1075 { /* 1, WINED3DRS_TEXTUREHANDLE */ 0 /* Handled in ddraw */, state_undefined },
1076 { /* 2, WINED3DRS_ANTIALIAS */ STATE_RENDER(WINED3DRS_ANTIALIAS), state_unknown },
1077 { /* 3, WINED3DRS_TEXTUREADDRESS */ 0 /* Handled in ddraw */, state_undefined },
1078 { /* 4, WINED3DRS_TEXTUREPERSPECTIVE */ STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE), state_unknown },
1079 { /* 5, WINED3DRS_WRAPU */ STATE_RENDER(WINED3DRS_WRAPU), state_unknown },
1080 { /* 6, WINED3DRS_WRAPV */ STATE_RENDER(WINED3DRS_WRAPV), state_unknown },
1081 { /* 7, WINED3DRS_ZENABLE */ STATE_RENDER(WINED3DRS_ZENABLE), state_zenable },
1082 { /* 8, WINED3DRS_FILLMODE */ STATE_RENDER(WINED3DRS_FILLMODE), state_fillmode },
1083 { /* 9, WINED3DRS_SHADEMODE */ STATE_RENDER(WINED3DRS_SHADEMODE), state_shademode },
1084 { /* 10, WINED3DRS_LINEPATTERN */ STATE_RENDER(WINED3DRS_LINEPATTERN), state_linepattern },
1085 { /* 11, WINED3DRS_MONOENABLE */ STATE_RENDER(WINED3DRS_MONOENABLE), state_unknown },
1086 { /* 12, WINED3DRS_ROP2 */ STATE_RENDER(WINED3DRS_ROP2), state_unknown },
1087 { /* 13, WINED3DRS_PLANEMASK */ STATE_RENDER(WINED3DRS_PLANEMASK), state_unknown },
1088 { /* 14, WINED3DRS_ZWRITEENABLE */ STATE_RENDER(WINED3DRS_ZWRITEENABLE), state_zwritenable },
1089 { /* 15, WINED3DRS_ALPHATESTENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1090 { /* 16, WINED3DRS_LASTPIXEL */ STATE_RENDER(WINED3DRS_LASTPIXEL), state_lastpixel },
1091 { /* 17, WINED3DRS_TEXTUREMAG */ 0 /* Handled in ddraw */, state_undefined },
1092 { /* 18, WINED3DRS_TEXTUREMIN */ 0 /* Handled in ddraw */, state_undefined },
1093 { /* 19, WINED3DRS_SRCBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1094 { /* 20, WINED3DRS_DESTBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1095 { /* 21, WINED3DRS_TEXTUREMAPBLEND */ 0 /* Handled in ddraw */, state_undefined },
1096 { /* 22, WINED3DRS_CULLMODE */ STATE_RENDER(WINED3DRS_CULLMODE), state_cullmode },
1097 { /* 23, WINED3DRS_ZFUNC */ STATE_RENDER(WINED3DRS_ZFUNC), state_zfunc },
1098 { /* 24, WINED3DRS_ALPHAREF */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1099 { /* 25, WINED3DRS_ALPHAFUNC */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1100 { /* 26, WINED3DRS_DITHERENABLE */ STATE_RENDER(WINED3DRS_DITHERENABLE), state_ditherenable },
1101 { /* 27, WINED3DRS_ALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1102 { /* 28, WINED3DRS_FOGENABLE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1103 { /* 29, WINED3DRS_SPECULARENABLE */ STATE_RENDER(WINED3DRS_SPECULARENABLE), state_specularenable},
1104 { /* 30, WINED3DRS_ZVISIBLE */ 0 /* Not supported according to the msdn */, state_nogl },
1105 { /* 31, WINED3DRS_SUBPIXEL */ STATE_RENDER(WINED3DRS_SUBPIXEL), state_unknown },
1106 { /* 32, WINED3DRS_SUBPIXELX */ STATE_RENDER(WINED3DRS_SUBPIXELX), state_unknown },
1107 { /* 33, WINED3DRS_STIPPLEDALPHA */ STATE_RENDER(WINED3DRS_STIPPLEDALPHA), state_unknown },
1108 { /* 34, WINED3DRS_FOGCOLOR */ STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor },
1109 { /* 35, WINED3DRS_FOGTABLEMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1110 { /* 36, WINED3DRS_FOGSTART */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1111 { /* 37, WINED3DRS_FOGEND */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1112 { /* 38, WINED3DRS_FOGDENSITY */ STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity },
1113 { /* 39, WINED3DRS_STIPPLEENABLE */ STATE_RENDER(WINED3DRS_STIPPLEENABLE), state_unknown },
1114 { /* 40, WINED3DRS_EDGEANTIALIAS */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1115 { /* 41, WINED3DRS_COLORKEYENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1116 { /* 42, undefined */ 0, state_undefined },
1117 { /* 43, WINED3DRS_BORDERCOLOR */ STATE_RENDER(WINED3DRS_BORDERCOLOR), state_unknown },
1118 { /* 44, WINED3DRS_TEXTUREADDRESSU */ 0, /* Handled in ddraw */ state_undefined },
1119 { /* 45, WINED3DRS_TEXTUREADDRESSV */ 0, /* Handled in ddraw */ state_undefined },
1120 { /* 46, WINED3DRS_MIPMAPLODBIAS */ STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), state_unknown },
1121 { /* 47, WINED3DRS_ZBIAS */ STATE_RENDER(WINED3DRS_ZBIAS), state_zbias },
1122 { /* 48, WINED3DRS_RANGEFOGENABLE */ 0, state_nogl },
1123 { /* 49, WINED3DRS_ANISOTROPY */ STATE_RENDER(WINED3DRS_ANISOTROPY), state_unknown },
1124 { /* 50, WINED3DRS_FLUSHBATCH */ STATE_RENDER(WINED3DRS_FLUSHBATCH), state_unknown },
1125 { /* 51, WINED3DRS_TRANSLUCENTSORTINDEPENDENT */ STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT), state_unknown },
1126 { /* 52, WINED3DRS_STENCILENABLE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1127 { /* 53, WINED3DRS_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1128 { /* 54, WINED3DRS_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1129 { /* 55, WINED3DRS_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1130 { /* 56, WINED3DRS_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1131 { /* 57, WINED3DRS_STENCILREF */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1132 { /* 58, WINED3DRS_STENCILMASK */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1133 { /* 59, WINED3DRS_STENCILWRITEMASK */ STATE_RENDER(WINED3DRS_STENCILWRITEMASK), state_stencilwrite },
1134 { /* 60, WINED3DRS_TEXTUREFACTOR */ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor },
1135 /* A BIG hole. If wanted, 'fixed' states like the vertex type or the bound shaders can be put here */
1136 { /* 61, Undefined */ 0, state_undefined },
1137 { /* 62, Undefined */ 0, state_undefined },
1138 { /* 63, Undefined */ 0, state_undefined },
1139 { /* 64, Undefined */ 0, state_undefined },
1140 { /* 65, Undefined */ 0, state_undefined },
1141 { /* 66, Undefined */ 0, state_undefined },
1142 { /* 67, Undefined */ 0, state_undefined },
1143 { /* 68, Undefined */ 0, state_undefined },
1144 { /* 69, Undefined */ 0, state_undefined },
1145 { /* 70, Undefined */ 0, state_undefined },
1146 { /* 71, Undefined */ 0, state_undefined },
1147 { /* 72, Undefined */ 0, state_undefined },
1148 { /* 73, Undefined */ 0, state_undefined },
1149 { /* 74, Undefined */ 0, state_undefined },
1150 { /* 75, Undefined */ 0, state_undefined },
1151 { /* 76, Undefined */ 0, state_undefined },
1152 { /* 77, Undefined */ 0, state_undefined },
1153 { /* 78, Undefined */ 0, state_undefined },
1154 { /* 79, Undefined */ 0, state_undefined },
1155 { /* 80, Undefined */ 0, state_undefined },
1156 { /* 81, Undefined */ 0, state_undefined },
1157 { /* 82, Undefined */ 0, state_undefined },
1158 { /* 83, Undefined */ 0, state_undefined },
1159 { /* 84, Undefined */ 0, state_undefined },
1160 { /* 85, Undefined */ 0, state_undefined },
1161 { /* 86, Undefined */ 0, state_undefined },
1162 { /* 87, Undefined */ 0, state_undefined },
1163 { /* 88, Undefined */ 0, state_undefined },
1164 { /* 89, Undefined */ 0, state_undefined },
1165 { /* 90, Undefined */ 0, state_undefined },
1166 { /* 91, Undefined */ 0, state_undefined },
1167 { /* 92, Undefined */ 0, state_undefined },
1168 { /* 93, Undefined */ 0, state_undefined },
1169 { /* 94, Undefined */ 0, state_undefined },
1170 { /* 95, Undefined */ 0, state_undefined },
1171 { /* 96, Undefined */ 0, state_undefined },
1172 { /* 97, Undefined */ 0, state_undefined },
1173 { /* 98, Undefined */ 0, state_undefined },
1174 { /* 99, Undefined */ 0, state_undefined },
1175 { /*100, Undefined */ 0, state_undefined },
1176 { /*101, Undefined */ 0, state_undefined },
1177 { /*102, Undefined */ 0, state_undefined },
1178 { /*103, Undefined */ 0, state_undefined },
1179 { /*104, Undefined */ 0, state_undefined },
1180 { /*105, Undefined */ 0, state_undefined },
1181 { /*106, Undefined */ 0, state_undefined },
1182 { /*107, Undefined */ 0, state_undefined },
1183 { /*108, Undefined */ 0, state_undefined },
1184 { /*109, Undefined */ 0, state_undefined },
1185 { /*110, Undefined */ 0, state_undefined },
1186 { /*111, Undefined */ 0, state_undefined },
1187 { /*112, Undefined */ 0, state_undefined },
1188 { /*113, Undefined */ 0, state_undefined },
1189 { /*114, Undefined */ 0, state_undefined },
1190 { /*115, Undefined */ 0, state_undefined },
1191 { /*116, Undefined */ 0, state_undefined },
1192 { /*117, Undefined */ 0, state_undefined },
1193 { /*118, Undefined */ 0, state_undefined },
1194 { /*119, Undefined */ 0, state_undefined },
1195 { /*120, Undefined */ 0, state_undefined },
1196 { /*121, Undefined */ 0, state_undefined },
1197 { /*122, Undefined */ 0, state_undefined },
1198 { /*123, Undefined */ 0, state_undefined },
1199 { /*124, Undefined */ 0, state_undefined },
1200 { /*125, Undefined */ 0, state_undefined },
1201 { /*126, Undefined */ 0, state_undefined },
1202 { /*127, Undefined */ 0, state_undefined },
1204 { /*128, WINED3DRS_WRAP0 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1205 { /*129, WINED3DRS_WRAP1 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1206 { /*130, WINED3DRS_WRAP2 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1207 { /*131, WINED3DRS_WRAP3 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1208 { /*132, WINED3DRS_WRAP4 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1209 { /*133, WINED3DRS_WRAP5 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1210 { /*134, WINED3DRS_WRAP6 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1211 { /*135, WINED3DRS_WRAP7 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1212 { /*136, WINED3DRS_CLIPPING */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
1213 { /*137, WINED3DRS_LIGHTING */ STATE_RENDER(WINED3DRS_LIGHTING) /* Vertex decl! */,state_lighting },
1214 { /*138, WINED3DRS_EXTENTS */ STATE_RENDER(WINED3DRS_EXTENTS), state_unknown },
1215 { /*139, WINED3DRS_AMBIENT */ STATE_RENDER(WINED3DRS_AMBIENT), state_ambient },
1216 { /*140, WINED3DRS_FOGVERTEXMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1217 { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
1218 { /*142, WINED3DRS_LOCALVIEWER */ STATE_RENDER(WINED3DRS_LOCALVIEWER), state_localviewer },
1219 { /*143, WINED3DRS_NORMALIZENORMALS */ STATE_RENDER(WINED3DRS_NORMALIZENORMALS), state_normalize },
1220 { /*144, WINED3DRS_COLORKEYBLENDENABLE */ STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE), state_unknown },
1221 { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
1222 { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
1223 { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
1224 { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
1225 { /*149, Undefined */ 0, state_undefined },
1226 { /*150, Undefined */ 0, state_undefined },
1227 { /*151, WINED3DRS_VERTEXBLEND */ 0, state_nogl },
1228 { /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
1229 { /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl },
1230 { /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSIZE), state_psize },
1231 { /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN), state_psizemin },
1232 { /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), state_pointsprite },
1233 { /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
1234 { /*158, WINED3DRS_POINTSCALE_A */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
1235 { /*159, WINED3DRS_POINTSCALE_B */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
1236 { /*160, WINED3DRS_POINTSCALE_C */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
1237 { /*161, WINED3DRS_MULTISAMPLEANTIALIAS */ STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS), state_unknown },
1238 { /*162, WINED3DRS_MULTISAMPLEMASK */ STATE_RENDER(WINED3DRS_MULTISAMPLEMASK), state_unknown },
1239 { /*163, WINED3DRS_PATCHEDGESTYLE */ STATE_RENDER(WINED3DRS_PATCHEDGESTYLE), state_unknown },
1240 { /*164, WINED3DRS_PATCHSEGMENTS */ STATE_RENDER(WINED3DRS_PATCHSEGMENTS), state_unknown },
1241 { /*165, WINED3DRS_DEBUGMONITORTOKEN */ STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN), state_unknown },
1242 { /*166, WINED3DRS_POINTSIZE_MAX */ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax },
1243 { /*167, WINED3DRS_INDEXEDVERTEXBLENDENABLE */ 0, state_nogl },
1244 { /*168, WINED3DRS_COLORWRITEENABLE */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
1245 { /*169, Undefined */ 0, state_undefined },
1246 { /*170, WINED3DRS_TWEENFACTOR */ 0, state_nogl },
1247 { /*171, WINED3DRS_BLENDOP */ STATE_RENDER(WINED3DRS_BLENDOP), state_blendop },
1248 { /*172, WINED3DRS_POSITIONDEGREE */ STATE_RENDER(WINED3DRS_POSITIONDEGREE), state_unknown },
1249 { /*173, WINED3DRS_NORMALDEGREE */ STATE_RENDER(WINED3DRS_NORMALDEGREE), state_unknown },
1250 /*172, WINED3DRS_POSITIONORDER */ /* Value assigned to 2 state names */
1251 /*173, WINED3DRS_NORMALORDER */ /* Value assigned to 2 state names */
1252 { /*174, WINED3DRS_SCISSORTESTENABLE */ STATE_RENDER(WINED3DRS_SCISSORTESTENABLE), state_unknown },
1253 { /*175, WINED3DRS_SLOPESCALEDEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_unknown },
1254 { /*176, WINED3DRS_ANTIALIASEDLINEENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1255 { /*177, undefined */ 0, state_undefined },
1256 { /*178, WINED3DRS_MINTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_unknown },
1257 { /*179, WINED3DRS_MAXTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_unknown },
1258 { /*180, WINED3DRS_ADAPTIVETESS_X */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_unknown },
1259 { /*181, WINED3DRS_ADAPTIVETESS_Y */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_unknown },
1260 { /*182, WINED3DRS_ADAPTIVETESS_Z */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_unknown },
1261 { /*183, WINED3DRS_ADAPTIVETESS_W */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_unknown },
1262 { /*184, WINED3DRS_ENABLEADAPTIVETESSELLATION */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_unknown },
1263 { /*185, WINED3DRS_TWOSIDEDSTENCILMODE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1264 { /*186, WINED3DRS_CCW_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1265 { /*187, WINED3DRS_CCW_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1266 { /*188, WINED3DRS_CCW_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1267 { /*189, WINED3DRS_CCW_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1268 { /*190, WINED3DRS_COLORWRITEENABLE1 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
1269 { /*191, WINED3DRS_COLORWRITEENABLE2 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
1270 { /*192, WINED3DRS_COLORWRITEENABLE3 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
1271 { /*193, WINED3DRS_BLENDFACTOR */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1272 { /*194, WINED3DRS_SRGBWRITEENABLE */ 0, state_nogl },
1273 { /*195, WINED3DRS_DEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_unknown },
1274 { /*196, undefined */ 0, state_undefined },
1275 { /*197, undefined */ 0, state_undefined },
1276 { /*198, WINED3DRS_WRAP8 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1277 { /*199, WINED3DRS_WRAP9 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1278 { /*200, WINED3DRS_WRAP10 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1279 { /*201, WINED3DRS_WRAP11 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1280 { /*202, WINED3DRS_WRAP12 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1281 { /*203, WINED3DRS_WRAP13 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1282 { /*204, WINED3DRS_WRAP14 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1283 { /*205, WINED3DRS_WRAP15 */ STATE_RENDER(WINED3DRS_WRAP0), state_unknown },
1284 { /*206, WINED3DRS_SEPARATEALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_unknown },
1285 { /*207, WINED3DRS_SRCBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_unknown },
1286 { /*208, WINED3DRS_DESTBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_unknown },
1287 { /*209, WINED3DRS_BLENDOPALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_unknown },