Sign in to follow this  

Custom Cursor Problem [FIXED]

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this