[D3D] Fix some others issues in DS
Lionel Ulmer
lionel.ulmer at free.fr
Sun Nov 16 06:30:50 CST 2003
Changelog:
- fix some other multi-texturing problems
--
Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
--- dlls/ddraw_CVS/d3ddevice/mesa.c Sat Nov 15 15:48:55 2003
+++ dlls/ddraw/d3ddevice/mesa.c Sun Nov 16 12:59:34 2003
@@ -105,13 +105,13 @@
IDirect3DDeviceGLImpl* gl_d3d_dev = (IDirect3DDeviceGLImpl*) d3d_dev;
DWORD opt_bitmap = 0x00000000;
- if (gl_d3d_dev->current_bound_texture[1] != NULL) {
+ if ((gl_d3d_dev->current_bound_texture[1] != NULL) &&
+ ((d3d_dev->state_block.texture_stage_state[1][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE))) {
if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE1_WINE) {
GL_extensions.glActiveTexture(GL_TEXTURE1_WINE);
gl_d3d_dev->current_active_tex_unit = GL_TEXTURE1_WINE;
}
- /* 'unbound' texture level 1 in that case to disable multi-texturing */
- glBindTexture(GL_TEXTURE_2D, 0);
+ /* Disable multi-texturing for level 1 to disable all others */
glDisable(GL_TEXTURE_2D);
}
if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE0_WINE) {
@@ -196,7 +196,6 @@
if (gl_d3d_dev->blending != 0) glEnable(GL_BLEND);
if (gl_d3d_dev->fogging != 0) glEnable(GL_FOG);
glDisable(GL_SCISSOR_TEST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, gl_d3d_dev->current_tex_env);
if (opt_bitmap & DEPTH_RANGE_BIT) {
glDepthRange(d3d_dev->active_viewport.dvMinZ, d3d_dev->active_viewport.dvMaxZ);
}
@@ -209,11 +208,27 @@
d3d_dev->matrices_updated(d3d_dev, TEXMAT0_CHANGED);
}
- /* This is a hack to prevent querying the current texture from GL. Basically, at the next
- DrawPrimitive call, this will bind the correct texture to this stage. */
+ if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE0_WINE) {
+ GL_extensions.glActiveTexture(GL_TEXTURE0_WINE);
+ gl_d3d_dev->current_active_tex_unit = GL_TEXTURE0_WINE;
+ }
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, gl_d3d_dev->current_tex_env);
+ /* Note that here we could directly re-bind the previous texture... But it would in some case be a spurious
+ bind if ever the game changes the texture just after.
+
+ So choose 0x00000001 to postpone the binding to the next time we draw something on screen. */
gl_d3d_dev->current_bound_texture[0] = (IDirectDrawSurfaceImpl *) 0x00000001;
- gl_d3d_dev->current_bound_texture[1] = (IDirectDrawSurfaceImpl *) 0x00000000;
if (d3d_dev->state_block.texture_stage_state[0][D3DTSS_COLOROP - 1] == D3DTOP_DISABLE) glDisable(GL_TEXTURE_2D);
+
+ /* And re-enabled if needed texture level 1 */
+ if ((gl_d3d_dev->current_bound_texture[1] != NULL) &&
+ (d3d_dev->state_block.texture_stage_state[1][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE)) {
+ if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE1_WINE) {
+ GL_extensions.glActiveTexture(GL_TEXTURE1_WINE);
+ gl_d3d_dev->current_active_tex_unit = GL_TEXTURE1_WINE;
+ }
+ glEnable(GL_TEXTURE_2D);
+ }
}
/* retrieve the X drawable to use on a given DC */
@@ -1332,7 +1347,7 @@
/* Compute the number of active texture stages and set the various texture parameters */
num_active_stages = draw_primitive_handle_textures(This);
- /* And restore to handle '0' in the case we use glTexCorrd calls */
+ /* And restore to handle '0' in the case we use glTexCoord calls */
if (glThis->current_active_tex_unit != GL_TEXTURE0_WINE) {
GL_extensions.glActiveTexture(GL_TEXTURE0_WINE);
glThis->current_active_tex_unit = GL_TEXTURE0_WINE;
@@ -1909,14 +1924,16 @@
glDisable(GL_TEXTURE_2D);
TRACE(" disabling 2D texturing.\n");
} else {
- /* Re-enable texturing */
- if (This->current_texture[0] != NULL) {
+ /* Re-enable texturing only if COLOROP was not already disabled... */
+ if ((glThis->current_bound_texture[dwStage] != NULL) &&
+ (This->state_block.texture_stage_state[dwStage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE)) {
glEnable(GL_TEXTURE_2D);
TRACE(" enabling 2D texturing.\n");
}
/* Re-Enable GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT */
- if (dwState != D3DTOP_DISABLE) {
+ if ((dwState != D3DTOP_DISABLE) &&
+ (This->state_block.texture_stage_state[dwStage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE)) {
if (glThis->current_tex_env != GL_COMBINE_EXT) {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glThis->current_tex_env = GL_COMBINE_EXT;
@@ -2153,6 +2170,10 @@
IDirectDrawSurfaceImpl *surf_ptr = This->current_texture[stage];
GLenum unit;
+ /* If this stage is disabled, no need to go further... */
+ if (This->state_block.texture_stage_state[stage][D3DTSS_COLOROP - 1] == D3DTOP_DISABLE)
+ break;
+
/* First check if we need to bind any other texture for this stage */
if (This->current_texture[stage] != glThis->current_bound_texture[stage]) {
if (This->current_texture[stage] == NULL) {
@@ -2164,10 +2185,7 @@
glThis->current_active_tex_unit = unit;
}
glBindTexture(GL_TEXTURE_2D, 0);
-
- if (stage == 0) {
- glDisable(GL_TEXTURE_2D);
- }
+ glDisable(GL_TEXTURE_2D);
} else {
GLenum tex_name = ((IDirect3DTextureGLImpl *) surf_ptr->tex_private)->tex_name;
--- dlls/ddraw_CVS/direct3d/mesa.c Mon Nov 10 19:42:20 2003
+++ dlls/ddraw/direct3d/mesa.c Sat Nov 15 22:46:35 2003
@@ -446,7 +446,7 @@
This->d3d_private = globject;
- TRACE(" creating Mesa private storage at %p.\n", globject);
+ TRACE(" creating OpenGL private storage at %p.\n", globject);
return D3D_OK;
}
More information about the wine-patches
mailing list