Changelog: - do not search for attached surfaces if the texture has not the MIPMAP flag set - add GL crit. section support for matrix setting - support the various BLEND texture operations -- Lionel Ulmer - http://www.bbrox.org/
--- dlls/ddraw_CVS/d3ddevice/mesa.c Sat May 24 01:37:13 2003 +++ dlls/ddraw/d3ddevice/mesa.c Sat May 24 22:03:05 2003 @@ -1783,6 +1783,27 @@ glTexEnvi(GL_TEXTURE_ENV, parm, GL_ADD_SIGNED_EXT); break; + /* For the four blending modes, use the Arg2 parameter */ + case D3DTOP_BLENDDIFFUSEALPHA: + case D3DTOP_BLENDTEXTUREALPHA: + case D3DTOP_BLENDFACTORALPHA: + case D3DTOP_BLENDCURRENTALPHA: { + GLenum src = GL_PRIMARY_COLOR_EXT; /* Just to prevent a compiler warning.. */ + + switch (dwState) { + case D3DTOP_BLENDDIFFUSEALPHA: src = GL_PRIMARY_COLOR_EXT; + case D3DTOP_BLENDTEXTUREALPHA: src = GL_TEXTURE; + case D3DTOP_BLENDFACTORALPHA: src = GL_CONSTANT_EXT; + case D3DTOP_BLENDCURRENTALPHA: src = GL_PREVIOUS_EXT; + } + + glTexEnvi(GL_TEXTURE_ENV, parm, GL_INTERPOLATE_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, src); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, src); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA); + } break; + default: handled = FALSE; break; @@ -1942,7 +1963,9 @@ } if ((dwState & 0xFF) != D3DTTFF_DISABLE) { + LEAVE_GL(); This->matrices_updated(This, TEXMAT0_CHANGED << dwStage); + ENTER_GL(); } if (handled == TRUE) { @@ -2722,19 +2745,25 @@ glThis->transform_state = GL_TRANSFORM_NONE; } } - for (tex_mat = TEXMAT0_CHANGED, tex_stage = 0; tex_mat <= TEXMAT7_CHANGED; tex_mat <<= 1, tex_stage++) { - if (matrices & tex_mat) { - if (This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXTURETRANSFORMFLAGS - 1] != D3DTTFF_DISABLE) { - if (tex_stage == 0) { - /* No multi-texturing support for now ... */ + if (matrices & (TEXMAT0_CHANGED|TEXMAT1_CHANGED|TEXMAT2_CHANGED|TEXMAT3_CHANGED| + TEXMAT4_CHANGED|TEXMAT5_CHANGED|TEXMAT6_CHANGED|TEXMAT7_CHANGED)) + { + ENTER_GL(); + for (tex_mat = TEXMAT0_CHANGED, tex_stage = 0; tex_mat <= TEXMAT7_CHANGED; tex_mat <<= 1, tex_stage++) { + if (matrices & tex_mat) { + if (This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXTURETRANSFORMFLAGS - 1] != D3DTTFF_DISABLE) { + if (tex_stage == 0) { + /* No multi-texturing support for now ... */ + glMatrixMode(GL_TEXTURE); + glLoadMatrixf((float *) This->tex_mat[tex_stage]); + } + } else { glMatrixMode(GL_TEXTURE); - glLoadMatrixf((float *) This->tex_mat[tex_stage]); + glLoadIdentity(); } - } else { - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); } } + LEAVE_GL(); } } --- dlls/ddraw_CVS/d3dtexture.c Wed May 21 22:42:08 2003 +++ dlls/ddraw/d3dtexture.c Sat May 24 18:30:11 2003 @@ -585,7 +585,11 @@ } } - surf_ptr = get_sub_mimaplevel(surf_ptr); + if (surf_ptr->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) { + surf_ptr = get_sub_mimaplevel(surf_ptr); + } else { + surf_ptr = NULL; + } } return DD_OK; @@ -817,8 +821,16 @@ } } - src_ptr = get_sub_mimaplevel(src_ptr); - dst_ptr = get_sub_mimaplevel(dst_ptr); + if (src_ptr->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) { + src_ptr = get_sub_mimaplevel(src_ptr); + } else { + src_ptr = NULL; + } + if (dst_ptr->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) { + dst_ptr = get_sub_mimaplevel(dst_ptr); + } else { + dst_ptr = NULL; + } if ((src_ptr == NULL) || (dst_ptr == NULL)) { if (src_ptr != dst_ptr) {