wined3d: Allow SetCursorProperties on existing cursor

Erich Hoover ehoover at mines.edu
Sun Mar 11 15:08:01 CDT 2007


Skipped content of type multipart/alternative-------------- next part --------------
From bf93490beba1129d2772c2396f293bfe7ea06ec9 Mon Sep 17 00:00:00 2001
From: Erich Hoover <ehoover at mediaserver.(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


More information about the wine-devel mailing list