Skip to main content
gamedev.net
🔒 Locked

Custom Cursor Problem [FIXED]

Started by necreia 0 replies 700+ views
Original Post
necreia
necreia
Hello, been doing good so far on this DirectX 8 - > DirectX 9 changeover... but ran into a snag. I'm trying to get the custom cursor to work. The mouse itself works (did point tests), however the custom cursor will not display. The mouse position only works if I comment out the last line of this source, otherwise with it in it will not update the mouse and will fail at the same line.. here's the relevent code (error testing code was removed):


(protected member variable)
...
  LPDIRECT3DSURFACE9 m_pCursorSurf;     // the main cursor surface
  LPDIRECTINPUTDEVICE8 m_pMouseDev;     // DirectInput device pointer
...

(inside init member function)
...
HRESULT r;

g_pDI->CreateDevice(GUID_SysMouse, &m_pMouseDev, NULL);
m_pMouseDev->SetDataFormat(&c_dfDIMouse);
m_pMouseDev->SetCooperativeLevel(g_hmain_window,DISCL_BACKGROUND|DISCL_NONEXCLUSIVE);
m_pMouseDev->Acquire();
g_pDevice->CreateOffscreenPlainSurface(20,20,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&m_pCursorSurf,NULL);
D3DXLoadSurfaceFromFile(m_pCursorSurf,0,0,"images\\cursors\\testcursor3.dds",0,D3DX_FILTER_NONE,0,0);

// here is where I get the error
r = g_pDevice->SetCursorProperties(0,0,m_pCursorSurf);
    if(FAILED(r))
        return E_FAIL;




I fail on the line "g_pDevice->SetCursorProperties", r is equal to -2005530516 (or D3DERR_INVALIDCALL). I did HRESULT tests on all the lines above it, and all of them came back as S_OK. I know a cursor surface is highly sensitive in what format it can be, the image is A8R8G8B8 .dds surface 32x32 (built by the texture tool). It seems that surface creation in DX9 is a little different than DX8, did I miss a step? Thanks in advanced [Edited by - necreia on September 5, 2005 6:09:45 PM]
necreia
necreia
Fix it myself, I did a typo:

Broken:
g_pDevice->CreateOffscreenPlainSurface(20,20,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&m_pCursorSurf,NULL);

Fixed:
g_pDevice->CreateOffscreenPlainSurface(32,32,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&m_pCursorSurf,NULL);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.