[DDRAW] fix 2D in D3D device (resent)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[DDRAW] fix 2D in D3D device (resent)

Christian Costa
Hi,

This time w/o the small spaces clean-up.

Changelog:
Disable depth test when there is no Z buffer attached.
Initialise texture states at creation instead of when tex name is
generated.

Christian Costa   [hidden email]


Index: dlls/ddraw/device_opengl.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/device_opengl.c,v
retrieving revision 1.9
diff -u -r1.9 device_opengl.c
--- dlls/ddraw/device_opengl.c 25 Sep 2005 15:18:18 -0000 1.9
+++ dlls/ddraw/device_opengl.c 5 Oct 2005 20:51:45 -0000
@@ -1325,6 +1325,7 @@
     IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
     int num_active_stages = 0;
     int num_tex_index = GET_TEXCOUNT_FROM_FVF(d3dvtVertexType);
+    BOOL reenable_depth_test = FALSE;
     
     /* I put the trace before the various locks... So as to better understand where locks occur :-) */
     if (TRACE_ON(ddraw)) {
@@ -1349,9 +1350,12 @@
 
  hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(This->surface, IDirectDrawSurface7),
     (DDSCAPS2 *) &zbuf_caps, &zbuf);
- if (!FAILED(hr)) {
+ if (SUCCEEDED(hr)) {
     This->current_zbuffer = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, zbuf);
     IDirectDrawSurface7_Release(zbuf);
+ } else if (glThis->depth_test) {
+    glDisable(GL_DEPTH_TEST);
+    reenable_depth_test = TRUE;
  }
     }
     if (This->current_zbuffer != NULL) {
@@ -1615,6 +1619,9 @@
     /* Whatever the case, disable the color material stuff */
     glDisable(GL_COLOR_MATERIAL);
 
+    if (reenable_depth_test)
+ glEnable(GL_DEPTH_TEST);
+
     LEAVE_GL();
     TRACE("End\n");    
 
Index: dlls/ddraw/texture.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/texture.c,v
retrieving revision 1.4
diff -u -r1.4 texture.c
--- dlls/ddraw/texture.c 3 Aug 2005 21:25:11 -0000 1.4
+++ dlls/ddraw/texture.c 5 Oct 2005 20:51:49 -0000
@@ -903,12 +903,14 @@
  private->tex_name = 0;
  if (surf->mipmap_level == 0) {
     private->main = NULL;
+    private->__global_dirty_flag = SURFACE_MEMORY_DIRTY;
     private->global_dirty_flag = &(private->__global_dirty_flag);
  } else {
     private->main = main;
     private->global_dirty_flag = &(((IDirect3DTextureGLImpl *) (private->main->tex_private))->__global_dirty_flag);
  }
  private->initial_upload_done = FALSE;
+ private->dirty_flag = SURFACE_MEMORY_DIRTY;
     }
 
     return D3D_OK;
@@ -925,15 +927,11 @@
     glGenTextures(1, &(private->tex_name));
     if (private->tex_name == 0) ERR("Error at creation of OpenGL texture ID !\n");
     TRACE(" GL texture id is : %d.\n", private->tex_name);
-    private->__global_dirty_flag = SURFACE_MEMORY_DIRTY;
  } else {
     private->tex_name = gltex_get_tex_name(private->main);
     TRACE(" GL texture id reusing id %d from surface %p (private at %p)).\n", private->tex_name, private->main, private->main->tex_private);
  }
  LEAVE_GL();
-
- /* And set the dirty flag accordingly */
- private->dirty_flag = SURFACE_MEMORY_DIRTY;
     }
     return ((IDirect3DTextureGLImpl *) (surf->tex_private))->tex_name;
 }