[D3D] Some viewport fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This patch makes Nomad Soul display 3D. This game is playbable now.

Bye,
Christian.

Changelog :
Add necessary AddRef/Release stuff to {Set/Get}CurrentViewport.
When changing parameters of a viewport, do the appropriate update if it is current.


Christian Costa titan.costa@wanadoo.fr

Index: d3dviewport.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3dviewport.c,v
retrieving revision 1.22
diff -u -r1.22 d3dviewport.c
--- d3dviewport.c	5 Sep 2003 23:08:41 -0000	1.22
+++ d3dviewport.c	12 Oct 2003 09:33:44 -0000
@@ -180,6 +180,7 @@
                                              LPD3DVIEWPORT lpData)
 {
     ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
+    LPDIRECT3DVIEWPORT3 current_viewport;
     TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
 
     if (TRACE_ON(ddraw)) {
@@ -196,7 +197,14 @@
     */
     This->viewports.vp1.dvMinZ = 0.0;
     This->viewports.vp1.dvMaxZ = 1.0;
-    
+
+    if (This->active_device) {
+      IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This->active_device, IDirect3DDevice3), &current_viewport);
+      if (ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport) == This)
+          This->activate(This);
+      IDirect3DViewport3_Release(current_viewport);
+    }
+
     return DD_OK;
 }
 
@@ -402,6 +410,7 @@
                                             LPD3DVIEWPORT2 lpData)
 {
     ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
+    LPDIRECT3DVIEWPORT3 current_viewport;
     TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
 
     if (TRACE_ON(ddraw)) {
@@ -412,6 +421,14 @@
     This->use_vp2 = 1;
     memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2));
     memcpy(&(This->viewports.vp2), lpData, lpData->dwSize);
+
+    if (This->active_device) {
+      IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This->active_device, IDirect3DDevice3), &current_viewport);
+      if (ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport) == This)
+        This->activate(This);
+      IDirect3DViewport3_Release(current_viewport);
+    }
+
     return DD_OK;
 }
 
Index: d3ddevice/main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3ddevice/main.c,v
retrieving revision 1.49
diff -u -r1.49 main.c
--- d3ddevice/main.c	5 Sep 2003 23:08:41 -0000	1.49
+++ d3ddevice/main.c	12 Oct 2003 09:33:49 -0000
@@ -1100,15 +1100,24 @@
     ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
     TRACE("(%p/%p)->(%p)\n", This, iface, lpDirect3DViewport3);
 
+    /* Do nothing if the specified viewport is the same as the current one */
+    if (This->current_viewport == ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport3))
+      return DD_OK;
+    
     /* Should check if the viewport was added or not */
 
+    /* Release previous viewport and AddRef the new one */
+    if (This->current_viewport)
+      IDirect3DViewport3_Release(ICOM_INTERFACE(This->current_viewport, IDirect3DViewport3));
+    IDirect3DViewport3_AddRef(lpDirect3DViewport3);
+    
     /* Set this viewport as the current viewport */
     This->current_viewport = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport3);
 
     /* Activate this viewport */
     This->current_viewport->active_device = This;
     This->current_viewport->activate(This->current_viewport);
-    
+
     return DD_OK;
 }
 
@@ -1120,6 +1129,10 @@
     TRACE("(%p/%p)->(%p)\n", This, iface, lplpDirect3DViewport3);
 
     *lplpDirect3DViewport3 = ICOM_INTERFACE(This->current_viewport, IDirect3DViewport3);
+
+    /* AddRef the returned viewport */
+    IDirect3DViewport3_AddRef(*lplpDirect3DViewport3);
+    
     TRACE(" returning interface %p\n", *lplpDirect3DViewport3);
     
     return DD_OK;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux