Skip to main content
gamedev.net
🔒 Locked

D3DXLoadSurfaceFromFile Question

Started by BrianMJC 6 replies 1.4k views
Original Post
BrianMJC
BrianMJC
Hi all, Does anyone know if the DX9 version of the D3DXLoadSurfaceFromFile function sets alpha to 0xff or 0x00 by default in the destination image surface? Thanks. :)
DrunkenHyena
DrunkenHyena
Assuming you're loading it into an ARGB surface and the image has no alpha of its own, then the alpha will be set to 0xFF.
Stay Casual,KenDrunken Hyena</FON
BrianMJC
BrianMJC
Thanks Ken,

That's what I thought.

I'm trying to load a D3D cursor, but it fails to appear onscreen, even though it's obviously "there" (menu choices respond to roll-over and clicks, and so forth). It worked fine in DX8 but not in DX9 (I just updated it). It's 32x32, and I created it as A8R8G8B8, as per D3D cursor requirements.

Any ideas are appreciated, thanks. :)
circlesoft
circlesoft
(1) Can you post some of your code? (Pertaining to texture loading, IDirect3DDevice9::SetCursorProperties(), ect...)

(2) Are you getting any debug output? If you don't know what that is, read this FAQ section.
BrianMJC
BrianMJC
circlesoft - Thanks:

(1) - Here it is. I call SetCursor after all other graphics functions are called every main loop iteration.

// L O A D   C U R S O R ///////////////////////////////////////////////////////// Loads an image surface as a display adapter managed cursor.//// return value - success or failure// szFilename - filename of cursor image file// xHot - hot spot x coordinate// yHot - hot spot y coordinate// nSize - pixel dimensions of cursor//estate csurface::LoadCursor (char *szFilename, uint xHot, uint yHot, int nSize)    {        // Begin with a clean slate.    if (pd3dSurface)        {        pd3dSurface->Release ();        pd3dSurface = NULL;        }        // Create surface.    hr = g_pd3dDev->CreateOffscreenPlainSurface (nSize, nSize, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pd3dSurface, NULL);    if (FAILED (hr))        {        sReport = "csurface::LoadCursor -- Failed to create image surface: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }    // Load file into surface.    hr = D3DXLoadSurfaceFromFile (pd3dSurface, NULL, NULL, szFilename, NULL, D3DX_FILTER_NONE, g_cdwcBlack, NULL);    if (FAILED (hr))        {        sReport = "csurface::LoadCursor -- Failed to load file \"";        sReport += szFilename;        sReport += "\" into image surface: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }    // Setup cursor properties.    hr = g_pd3dDev->SetCursorProperties (xHot, yHot, pd3dSurface);    if (FAILED (hr))        {        sReport = "csurface::LoadCursor -- Failed to set cursor properties: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }    // Show the cursor    g_pd3dDev->ShowCursor (true);    return g_eState;    }// S E T   C U R S O R ///////////////////////////////////////////////////////inline void csurface::SetCursor (uint xPos, uint yPos)    {    g_pd3dDev->SetCursorPosition (xPos, yPos, D3DCURSOR_IMMEDIATE_UPDATE);    }


(2) - The following are the only errors & warnings I get in the debug output window:

Quote:

Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (INFO) :======================= Hal SWVP device selected

Direct3D9: (INFO) :HalDevice Driver style 9

Direct3D9: :Subclassing window 00010540
Direct3D9: :StartExclusiveMode
Direct3D9: :WM_DISPLAYCHANGE: 800x600x32
Direct3D9: (INFO) :Failed to create driver indexbuffer
Direct3D9: (INFO) :Using X3D PSGP

D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 2.4975e-316f. This is ok.
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[0] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[1] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[2] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[3] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[4] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[5] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[6] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[7] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[8] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[9] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[10] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[11] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[12] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[13] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[14] is incorrect. Expected 0x100, Returned 0x0
D3D9 Helper: Error: Default value for D3DSAMP_DMAPOFFSET[15] is incorrect. Expected 0x100, Returned 0x0


I don't touch any sample settings in my code, and am not sure if these latter errors mean anything relevant. I'm using an ATI Radeon 9500 Pro, btw, and have DX9.0c (October 2004) on my system & the latest adapter drivers installed.
BrianMJC
BrianMJC
Anyone?
code4fun
code4fun
I seem to be having a very similar problem as well. And my code looks very much the same, essentially, so it's probably the same issue. I assume you're catching the windows cursor in the windows message proc (only thing I could think of that you haven't posted as far as code, though doing so hasn't seemed to work for me either). If you find anything I wouldn't mind hearing about it, however :) I'll keep looking and drop something here if I figure out the problem as well.

Edit: nevermind, my call to device->Present(...) wasn't in the right place.. sorry I can't help you more with the problems you're having.

[Edited by - code4fun on November 24, 2004 1:49:53 PM]
BrianMJC
BrianMJC
code4fun - Thanks anyway. :)

I am NOT using the window proc to set and update the cursor. But got it to work in DX 8 without it. I call a GetInput function first thing every game loop iteration to receive mouse and key input, and update accordingly. It worked in 8, and 9 hasn't changed anything for DirectInput, so I didn't imagine that would do anything... but just to be sure, I tried doing it in the window proc, but it still didn't work.

Topic Locked

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

Sign in to reply to this topic.