I’m new to DirectX and C++ programming, but need to for a homework assignment (I’ve already completed the actual assignment but can’t get my code to run post-compile). I’ve stepped into my program and have found the problem to be my D3DXLoadSurfaceFromFile call. The actual code is
//load m_Surface from file into newly created m_Surface
result = D3DXLoadSurfaceFromFile(
m_Surface,
NULL,
NULL,
m_BackgroundFile,
NULL,
D3DX_DEFAULT,
0,
NULL);
Where ‘result’ is:
HRESULT result = m_d3ddev->CreateOffscreenPlainSurface(
SCREENW, //An int set to 640
SCREENH, //An int set to 480
D3DFMT_X8R8G8B8, //m_Surface's format
D3DPOOL_DEFAULT, //Memory pool
&m_Surface, //Pointer to m_Surface
NULL); //Reserved
m_Surface is an LPDIRECT3DSURFACE9 initially set to NULL.
m_BackgroundFile is set to “filename.bmp” (a 24-bit bitmap)
and (I think/hope) everything else is self-explanatory.
If it helps, right before I check (which is the check that causes the program to close)
if (!SUCCEEDED(result))
return false;
result is set to S_OK, and then -200559767
From your code, I didn’t see anything wrong, but I guess you pass in a wrong file to parameter m_BackgroundFile, either the program can not find the file or the file was not in a acceptable format.