Yeah, that would make more sense wouldn't it :) Please see attached patch.
Erich Hoover
[EMAIL PROTECTED]
On 3/11/07, H. Verbeet <[EMAIL PROTECTED]> wrote:
On 11/03/07, Erich Hoover <[EMAIL PROTECTED]> wrote:
> So, which change exactly are you concerned about? Changes are:
> 1) The removal of "glDeleteTextures(1, &This->cursorTexture);" in
device.c
> This change should just keep SetCursorProperties from deleting the gl
> texture. By removing this call an application can set the cursor to A,
> change the cursor to B, then change the cursor back to A without having
the
> texture deleted.
> 2) The temporary allocation of This->glDescription.textureName in
surface.c
> This change should allow SetCursorProperties to retrieve "cursor A" the
> second time in the "A, B, A" sequence. Without this change,
> SetCursorProperties gets back a texture of "0" from the
> IWineD3DSurface_PreLoad call. This allocation is temporary since
> SetCursorProperties immediately resets that value:
> This->cursorTexture = pSur-> glDescription.textureName;
> ...
> pSur->glDescription.textureName = 0; /* Prevent the texture from being
> changed or deleted */
>
> I don't think I'm missing anything here... However, the implementation
of
> item #2 could be changed around by using flags, as you discussed in a
> previous email, and this would seem more consistent with the intent of
> SFLAG_FORCELOAD (see the attached patch).
>
> Erich Hoover
> [EMAIL PROTECTED]
You're trying to solve the wrong problem :-) The problem is that when
we set the textureName to 0 we essentially kick the GL texture out of
the surface which is then left in a somewhat inconsistent state.
Calling SetCursorProperties again with the same surface will then fail
because the surface no longer has a GL texture associated with it. The
proper way to fix this is to make a copy of the GL texture rather than
playing tricks with the surface loading code.
From bf93490beba1129d2772c2396f293bfe7ea06ec9 Mon Sep 17 00:00:00 2001
From: Erich Hoover <[EMAIL PROTECTED](none)>
Date: Sun, 11 Mar 2007 14:04:51 -0600
Subject: wined3d: Allow SetCursorProperties on existing cursor
---
dlls/wined3d/device.c | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 0998eec..46efb1a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5239,10 +5239,41 @@ static HRESULT WINAPI IWineD3DDeviceIm
* it after setting the cursor image. Windows doesn't addref the set
surface, so we can't
* do this either without creating circular refcount dependencies.
Copy out the gl texture instead.
*/
- This->cursorTexture = pSur->glDescription.textureName;
This->cursorWidth = pSur->currentDesc.Width;
This->cursorHeight = pSur->currentDesc.Height;
- pSur->glDescription.textureName = 0; /* Prevent the texture from being
changed or deleted */
+ if (pSur->glDescription.textureName && pSur->glDescription.level == 0
+ && pSur->glDescription.target == GL_TEXTURE_2D) {
+ BOOL texEnabled = glIsEnabled(GL_TEXTURE_2D);
+ GLint format = pSur->glDescription.glFormat;
+ GLint type = pSur->glDescription.glType;
+ INT width = This->cursorWidth;
+ INT height = This->cursorHeight;
+ void *mem;
+
+ mem = HeapAlloc(GetProcessHeap(), 0, width * height * 4);
+ ENTER_GL();
+ glEnable(GL_TEXTURE_2D);
+ /* Copy the surface texture into memory */
+ glGetTexImage(GL_TEXTURE_2D, 0, format, type, mem);
+ checkGLcall("glGetTexImage");
+ /* Create a new cursor texture */
+ glGenTextures(1, &This->cursorTexture);
+ checkGLcall("glGenTextures");
+ glBindTexture(GL_TEXTURE_2D, This->cursorTexture);
+ checkGLcall("glBindTexture");
+ /* Copy the memory (surface texture copy) into the cursor texture
*/
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format,
type, mem);
+ checkGLcall("glTexImage2D");
+ if(!texEnabled)
+ glDisable(GL_TEXTURE_2D);
+ LEAVE_GL();
+ HeapFree(GetProcessHeap(), 0, mem);
+ }
+ else
+ {
+ FIXME("A cursor texture was not returned.\n");
+ This->cursorTexture = 0;
+ }
}
This->xHotSpot = XHotSpot;
--
1.4.1