[D3D 44] Delyaed texture creation for badly behaved games

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

 



Changelog:
 Enable the application to create first textures and then the D3D Device

-- 
		 Lionel Ulmer - http://www.bbrox.org/
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3ddevice/mesa.c	2002-12-24 15:17:49.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3ddevice/mesa.c	2002-12-24 13:53:54.000000000 +0100
@@ -302,6 +302,9 @@
 	if (This->current_texture[0] != NULL)
 	    IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[0], IDirect3DTexture2));
 
+	/* And warn the D3D object that this device is no longer active... */
+	This->d3d->removed_device(This->d3d, This);
+
 	ENTER_GL();
 	glXDestroyContext(glThis->display, glThis->gl_context);
 	LEAVE_GL();
@@ -1880,6 +1887,9 @@
     *obj = object;
 
     TRACE(" creating implementation at %p.\n", *obj);
+
+    /* And finally warn D3D that this device is now present */
+    object->d3d->added_device(object->d3d, object);
     
     return DD_OK;
 }
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3d_private.h	2002-12-24 15:17:49.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3d_private.h	2002-12-24 15:31:12.000000000 +0100
@@ -54,7 +54,11 @@
     IDirectDrawImpl*	ddraw;
 
     /* Used as a callback function to create a texture */
-    HRESULT (*create_texture)(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main, DWORD mipmap_level);
+    HRESULT (*create_texture)(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main);
+
+    /* Used as a callback for Devices to tell to the D3D object it's been created */
+    HRESULT (*added_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device);
+    HRESULT (*removed_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device);
 };
 
 /*****************************************************************************
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3dtexture.c	2002-12-24 15:17:49.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3dtexture.c	2002-12-24 15:31:02.000000000 +0100
@@ -105,7 +105,7 @@
 		}
 
 		glTexSubImage2D(GL_TEXTURE_2D,
-				glThis->mipmap_level,
+				texture->mipmap_level,
 				0, 0,
 				tex_d->dwWidth, tex_d->dwHeight,
 				GL_RGBA,
@@ -200,7 +200,7 @@
 			      table);           /* the color table */
 	    
 	    glTexImage2D(GL_TEXTURE_2D,       /* target */
-			 glThis->mipmap_level,                   /* level */
+			 This->mipmap_level,                   /* level */
 			 GL_COLOR_INDEX8_EXT, /* internal format */
 			 src_d->dwWidth, src_d->dwHeight, /* width, height */
 			 0,                   /* border */
@@ -222,7 +222,7 @@
 	    
 	    if (init_upload)
 	        glTexImage2D(GL_TEXTURE_2D,
-			     glThis->mipmap_level,
+			     This->mipmap_level,
 			     GL_RGBA,
 			     src_d->dwWidth, src_d->dwHeight,
 			     0,
@@ -231,7 +231,7 @@
 			     surface);
 	    else
 	        glTexSubImage2D(GL_TEXTURE_2D,
-				glThis->mipmap_level,
+				This->mipmap_level,
 				0, 0,
 				src_d->dwWidth, src_d->dwHeight,
 				GL_RGBA,
@@ -250,7 +250,7 @@
 		   ********************** */
 	    if (init_upload)
 	        glTexImage2D(GL_TEXTURE_2D,
-			     glThis->mipmap_level,
+			     This->mipmap_level,
 			     GL_RGB,
 			     src_d->dwWidth, src_d->dwHeight,
 			     0,
@@ -259,7 +259,7 @@
 			     src_d->lpSurface);
 	    else
 	        glTexSubImage2D(GL_TEXTURE_2D,
-				glThis->mipmap_level,
+				This->mipmap_level,
 				0, 0,
 				src_d->dwWidth, src_d->dwHeight,
 				GL_RGB,
@@ -269,7 +269,7 @@
   	    if (src_d->ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000) {
 		if (init_upload)
 		    glTexImage2D(GL_TEXTURE_2D,
-				 glThis->mipmap_level,
+				 This->mipmap_level,
 				 GL_RGB,
 				 src_d->dwWidth, src_d->dwHeight,
 				 0,
@@ -278,7 +278,7 @@
 				 src_d->lpSurface);
 		else
 		    glTexSubImage2D(GL_TEXTURE_2D,
-				    glThis->mipmap_level,
+				    This->mipmap_level,
 				    0, 0,
 				    src_d->dwWidth, src_d->dwHeight,
 				    GL_RGB,
@@ -288,7 +288,7 @@
 	    } else if (src_d->ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000001) {
 		if (init_upload)
 		    glTexImage2D(GL_TEXTURE_2D,
-				 glThis->mipmap_level,
+				 This->mipmap_level,
 				 GL_RGBA,
 				 src_d->dwWidth, src_d->dwHeight,
 				 0,
@@ -297,7 +297,7 @@
 				 src_d->lpSurface);
 		else
 		    glTexSubImage2D(GL_TEXTURE_2D,
-				    glThis->mipmap_level,
+				    This->mipmap_level,
 				    0, 0,
 				    src_d->dwWidth, src_d->dwHeight,
 				    GL_RGBA,
@@ -306,7 +306,7 @@
 	    } else if (src_d->ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x0000000F) {
 	        if (init_upload)
 		    glTexImage2D(GL_TEXTURE_2D,
-				 glThis->mipmap_level,
+				 This->mipmap_level,
 				 GL_RGBA,
 				 src_d->dwWidth, src_d->dwHeight,
 				 0,
@@ -315,7 +315,7 @@
 				 src_d->lpSurface);
 		else
 		    glTexSubImage2D(GL_TEXTURE_2D,
-				    glThis->mipmap_level,
+				    This->mipmap_level,
 				    0, 0,
 				    src_d->dwWidth, src_d->dwHeight,
 				    GL_RGBA,
@@ -335,7 +335,7 @@
 		
 		if (init_upload)
 		    glTexImage2D(GL_TEXTURE_2D,
-				 glThis->mipmap_level,
+				 This->mipmap_level,
 				 GL_RGBA,
 				 src_d->dwWidth, src_d->dwHeight,
 				 0,
@@ -344,7 +344,7 @@
 				 surface);
 		else
 		    glTexSubImage2D(GL_TEXTURE_2D,
-				    glThis->mipmap_level,
+				    This->mipmap_level,
 				    0, 0,
 				    src_d->dwWidth, src_d->dwHeight,
 				    GL_RGBA,
@@ -366,7 +366,7 @@
 		
 		if (init_upload)
 		    glTexImage2D(GL_TEXTURE_2D,
-				 glThis->mipmap_level,
+				 This->mipmap_level,
 				 GL_RGBA,
 				 src_d->dwWidth, src_d->dwHeight,
 				 0,
@@ -375,7 +375,7 @@
 				 surface);
 		else
 		    glTexSubImage2D(GL_TEXTURE_2D,
-				    glThis->mipmap_level,
+				    This->mipmap_level,
 				    0, 0,
 				    src_d->dwWidth, src_d->dwHeight,
 				    GL_RGBA,
@@ -389,7 +389,7 @@
 	} else if (src_d->ddpfPixelFormat.u1.dwRGBBitCount == 24) {
 	    if (init_upload)
 	        glTexImage2D(GL_TEXTURE_2D,
-			     glThis->mipmap_level,
+			     This->mipmap_level,
 			     GL_RGB,
 			     src_d->dwWidth, src_d->dwHeight,
 			     0,
@@ -398,7 +398,7 @@
 			     src_d->lpSurface);
 	    else
 	        glTexSubImage2D(GL_TEXTURE_2D,
-				glThis->mipmap_level,
+				This->mipmap_level,
 				0, 0,
 				src_d->dwWidth, src_d->dwHeight,
 				GL_RGB,
@@ -407,7 +407,7 @@
 	} else if (src_d->ddpfPixelFormat.u1.dwRGBBitCount == 32) {
 	    if (init_upload)
 	        glTexImage2D(GL_TEXTURE_2D,
-			     glThis->mipmap_level,
+			     This->mipmap_level,
 			     GL_RGBA,
 			     src_d->dwWidth, src_d->dwHeight,
 			     0,
@@ -416,7 +416,7 @@
 			     src_d->lpSurface);
 	    else
 	        glTexSubImage2D(GL_TEXTURE_2D,
-				glThis->mipmap_level,
+				This->mipmap_level,
 				0, 0,
 				src_d->dwWidth, src_d->dwHeight,
 				GL_RGBA,
@@ -571,16 +571,18 @@
     
     TRACE("(%p/%p)->(%p)\n", This, iface, lpD3DTexture2);
 
-    if (glThis->loaded == FALSE) {
-        /* Only check memory for not already loaded texture... */
-        mem_used = This->surface_desc.dwHeight *
-	           This->surface_desc.u1.lPitch;
-	if (This->ddraw_owner->allocate_memory(This->ddraw_owner, mem_used) < 0) {
-	    TRACE(" out of virtual memory... Warning application.\n");
-	    return D3DERR_TEXTURE_LOAD_FAILED;
+    if (glThis != NULL) {
+        if (glThis->loaded == FALSE) {
+	    /* Only check memory for not already loaded texture... */
+	    mem_used = This->surface_desc.dwHeight *
+	               This->surface_desc.u1.lPitch;
+	    if (This->ddraw_owner->allocate_memory(This->ddraw_owner, mem_used) < 0) {
+	        TRACE(" out of virtual memory... Warning application.\n");
+		return D3DERR_TEXTURE_LOAD_FAILED;
+	    }
 	}
+	glThis->loaded = TRUE;
     }
-    glThis->loaded = TRUE;
     
     TRACE("Copied surface %p to surface %p\n", lpD3DTextureImpl, This);
 
@@ -616,18 +618,20 @@
 	   texture object. */
 	memcpy(dst_d->lpSurface, src_d->lpSurface, src_d->u1.lPitch * src_d->dwHeight);
 
-	/* If the GetHandle was not done, it is an error... */
-	if (glThis->tex_name == 0) ERR("Unbound GL texture !!!\n");
-
-	ENTER_GL();
-
-	/* Now, load the texture */
-	/* d3dd->set_context(d3dd); We need to set the context somehow.... */
+	if (glThis != NULL) {
+	    /* If the GetHandle was not done, it is an error... */
+	    if (glThis->tex_name == 0) ERR("Unbound GL texture !!!\n");
 
-	gltex_upload_texture(This, glThis->first_unlock);
-	glThis->first_unlock = FALSE;
-	
-	LEAVE_GL();
+	    ENTER_GL();
+	    
+	    /* Now, load the texture */
+	    /* d3dd->set_context(d3dd); We need to set the context somehow.... */
+	    
+	    gltex_upload_texture(This, glThis->first_unlock);
+	    glThis->first_unlock = FALSE;
+	    
+	    LEAVE_GL();
+	}
     }
 
     return D3D_OK;
@@ -760,50 +764,55 @@
 #endif
 
 HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, 
-			  IDirectDrawSurfaceImpl *main, DWORD mipmap_level)
+			  IDirectDrawSurfaceImpl *main)
 {
-    IDirect3DTextureGLImpl *private;
-
-    private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTextureGLImpl));
-    if (private == NULL) return DDERR_OUTOFMEMORY;
+    IDirect3DGLImpl *gl_d3d = (IDirect3DGLImpl *) d3d;
 
-    private->final_release = surf->final_release;
-    private->lock_update = surf->lock_update;
-    private->unlock_update = surf->unlock_update;
-    private->mipmap_level = mipmap_level;
-    
-    /* If at creation, we can optimize stuff and wait the first 'unlock' to upload a valid stuff to OpenGL.
-       Otherwise, it will be uploaded here (and may be invalid). */
-    if (at_creation == TRUE)
-        private->first_unlock = TRUE;
-    else
-        private->first_unlock = FALSE;
-    surf->final_release = gltex_final_release;
-    surf->lock_update = gltex_lock_update;
-    surf->unlock_update = gltex_unlock_update;
-    surf->tex_private = private;
-    surf->SetColorKey_cb = gltex_setcolorkey_cb;
-    
+    /* First, initialize the texture vtables... */
     ICOM_INIT_INTERFACE(surf, IDirect3DTexture,  VTABLE_IDirect3DTexture);
     ICOM_INIT_INTERFACE(surf, IDirect3DTexture2, VTABLE_IDirect3DTexture2);
+	
+    /* Only create all the private stuff if we actually have an OpenGL context.. */
+    if (gl_d3d->current_device != NULL) {
+        IDirect3DTextureGLImpl *private;
+
+        private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTextureGLImpl));
+	if (private == NULL) return DDERR_OUTOFMEMORY;
+
+	private->final_release = surf->final_release;
+	private->lock_update = surf->lock_update;
+	private->unlock_update = surf->unlock_update;
+	
+	/* If at creation, we can optimize stuff and wait the first 'unlock' to upload a valid stuff to OpenGL.
+	   Otherwise, it will be uploaded here (and may be invalid). */
+	if (at_creation == TRUE)
+	    private->first_unlock = TRUE;
+	else
+	    private->first_unlock = FALSE;
+	surf->final_release = gltex_final_release;
+	surf->lock_update = gltex_lock_update;
+	surf->unlock_update = gltex_unlock_update;
+	surf->tex_private = private;
+	surf->SetColorKey_cb = gltex_setcolorkey_cb;
+	
+	ENTER_GL();
+	if (surf->mipmap_level == 0) {
+	    glGenTextures(1, &(private->tex_name));
+	    if (private->tex_name == 0) ERR("Error at creation of OpenGL texture ID !\n");
+	    TRACE(" GL texture created for surface %p (private data at %p and GL id %d).\n", surf, private, private->tex_name);
+	} else {
+	    private->tex_name = ((IDirect3DTextureGLImpl *) (main->tex_private))->tex_name;
+	    TRACE(" GL texture created for surface %p (private data at %p and GL id reusing id %d from surface %p (%p)).\n",
+		  surf, private, private->tex_name, main, main->tex_private);
+	}
 
-    ENTER_GL();
-    if (mipmap_level == 0) {
-	glGenTextures(1, &(private->tex_name));
-	if (private->tex_name == 0) ERR("Error at creation of OpenGL texture ID !\n");
-	TRACE(" GL texture created for surface %p (private data at %p and GL id %d).\n", surf, private, private->tex_name);
-    } else {
-        private->tex_name = ((IDirect3DTextureGLImpl *) (main->tex_private))->tex_name;
-	TRACE(" GL texture created for surface %p (private data at %p and GL id reusing id %d from surface %p (%p)).\n",
-	      surf, private, private->tex_name, main, main->tex_private);
-    }
-
-    if ((at_creation == FALSE) &&
-	((surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ALLOCONLOAD) == 0))
-    {
-        gltex_upload_texture(surf, TRUE);
+	if ((at_creation == FALSE) &&
+	    ((surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ALLOCONLOAD) == 0))
+	{
+	    gltex_upload_texture(surf, TRUE);
+	}
+	LEAVE_GL();
     }
-    LEAVE_GL();
 
     return D3D_OK;
 }
--- /home/ulmer/Wine/wine_base//dlls/ddraw/ddraw_private.h	2002-12-22 12:06:18.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/ddraw_private.h	2002-12-24 15:26:21.000000000 +0100
@@ -297,6 +297,9 @@
     HRESULT (WINAPI *SetColorKey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ;
     /* This is to get the D3DDevice object associated to this surface */
     struct IDirect3DDeviceImpl *d3ddevice;
+    /* This is for texture */
+    IDirectDrawSurfaceImpl *mip_main;
+    int mipmap_level;
     LPVOID tex_private;
 };
 
--- /home/ulmer/Wine/wine_base//dlls/ddraw/mesa_private.h	2002-12-24 15:17:49.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/mesa_private.h	2002-12-24 15:47:05.000000000 +0100
@@ -78,6 +78,9 @@
     struct IDirect3DImpl parent;
     int free_lights;
     void (*light_released)(IDirect3DImpl *, GLenum light_num);
+
+    /* This is needed for delayed texture creation */
+    struct IDirect3DDeviceImpl *current_device;
 } IDirect3DGLImpl;
 
 typedef struct IDirect3DLightGLImpl
@@ -92,7 +95,6 @@
     GLuint tex_name;
     BOOLEAN loaded; /* For the moment, this is here.. Should be part of surface management though */
     BOOLEAN first_unlock;
-    DWORD mipmap_level;
     /* This is for now used to override 'standard' surface stuff to be as transparent as possible */
     void (*final_release)(struct IDirectDrawSurfaceImpl *This);
     void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
@@ -123,7 +125,7 @@
 
 /* All non-static functions 'exported' by various sub-objects */
 extern HRESULT direct3d_create(IDirect3DImpl **obj, IDirectDrawImpl *ddraw);
-extern HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf, DWORD mipmap_level);
+extern HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
 extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirect3DImpl *d3d, GLenum light_num);
 extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirect3DImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
 extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirect3DImpl *d3d);
--- /home/ulmer/Wine/wine_base//dlls/ddraw/ddraw/main.c	2002-12-24 12:42:21.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/ddraw/main.c	2002-12-24 15:31:39.000000000 +0100
@@ -359,7 +359,7 @@
     if (FAILED(hr)) return hr;
 
     if (This->d3d) This->d3d->create_texture(This->d3d, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), TRUE, 
-					     ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), mipmap_level);
+					     ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf));
 
     /* Create attached mipmaps if required. */
     if (more_mipmaps(&ddsd))
@@ -375,8 +375,9 @@
 
 	while (more_mipmaps(&mipmap_surface_desc))
 	{
+	    IDirectDrawSurfaceImpl *mipmap_impl;
+	    
 	    mipmap_level++;
-
 	    mipmap_surface_desc.u2.dwMipMapCount--;
 
 	    if (mipmap_surface_desc.dwWidth > 1)
@@ -397,8 +398,14 @@
 		IDirectDrawSurface7_Release(*ppSurf);
 		return hr;
 	    }
+	    
+	    /* This is needed for delayed mipmap creation */
+	    mipmap_impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, mipmap);
+	    mipmap_impl->mip_main = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf);
+	    mipmap_impl->mipmap_level = mipmap_level;
+
 	    if (This->d3d) This->d3d->create_texture(This->d3d, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, mipmap), TRUE,
-						     ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), mipmap_level);
+						     ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf));
 
 	    IDirectDrawSurface7_AddAttachedSurface(prev_mipmap, mipmap);
 	    IDirectDrawSurface7_Release(prev_mipmap);
--- /home/ulmer/Wine/wine_base//dlls/ddraw/direct3d/mesa.c	2002-12-24 15:17:49.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/direct3d/mesa.c	2002-12-24 15:37:03.000000000 +0100
@@ -377,6 +377,38 @@
 #undef XCAST
 #endif
 
+static HRESULT d3d_add_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device)
+{
+    IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This;
+ 
+    if  (glThis->current_device == NULL) {
+        /* Create delayed textures now that we have an OpenGL context...
+	   For that, go through all surface attached to our DDraw object and create
+	   OpenGL textures for all textures.. */
+        IDirectDrawSurfaceImpl *surf = This->ddraw->surfaces;
+
+	while (surf != NULL) {
+	    if (surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) {
+	        /* Found a texture.. Now create the OpenGL part */
+	        d3dtexture_create(This, surf, FALSE, surf->mip_main);
+	    }
+	    surf = surf->next_ddraw;
+	}
+    }
+    /* For the moment, only one device 'supported'... */
+    glThis->current_device = device;
+
+    return DD_OK;
+}
+
+static HRESULT d3d_remove_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device)
+{
+    IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This;
+
+    glThis->current_device = NULL;
+    return DD_OK;
+}
+
 HRESULT direct3d_create(IDirect3DImpl **obj, IDirectDrawImpl *ddraw)
 {
     IDirect3DImpl *object;
@@ -388,7 +420,9 @@
     object->ref = 1;
     object->ddraw = ddraw;
     object->create_texture = d3dtexture_create;
-    
+    object->added_device = d3d_add_device;
+    object->removed_device = d3d_remove_device;
+
     ICOM_INIT_INTERFACE(object, IDirect3D,  VTABLE_IDirect3D);
     ICOM_INIT_INTERFACE(object, IDirect3D2, VTABLE_IDirect3D2);
     ICOM_INIT_INTERFACE(object, IDirect3D3, VTABLE_IDirect3D3);
--- /home/ulmer/Wine/wine_base//dlls/ddraw/dsurface/main.c	2002-12-24 15:17:49.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/dsurface/main.c	2002-12-24 15:28:59.000000000 +0100
@@ -193,22 +193,16 @@
     {
 	HRESULT ret_value = S_OK;
 
-	/* In case the texture surface was created before the D3D creation */
 	if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) == 0) return E_NOINTERFACE;
-	/* Create a 'delayed' private field only if it is not an offscreen texture... */
+
+	/* In case the texture surface was created before the D3D creation */
 	if (This->tex_private == NULL) {
    	    if (This->ddraw_owner->d3d == NULL) {
 	        ERR("Texture created with no D3D object yet.. Not supported !\n");
 		return E_NOINTERFACE;
 	    }
 
-	    if (((This->surface_desc.dwFlags & DDSD_MIPMAPCOUNT) &&
-		 (This->surface_desc.u2.dwMipMapCount > 1)) ||
-		(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL)) {
-	        ERR(" need to fix mipmaping in this case !!\n");
-	    }
-
-	    ret_value = This->ddraw_owner->d3d->create_texture(This->ddraw_owner->d3d, This, FALSE, NULL, 0);
+	    ret_value = This->ddraw_owner->d3d->create_texture(This->ddraw_owner->d3d, This, FALSE, This->mip_main);
 	    if (FAILED(ret_value)) return ret_value;
 	}
 	if (IsEqualGUID( &IID_IDirect3DTexture, riid )) {

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

  Powered by Linux