Using D3DXGetImageInfoFromFile() function gives me this:
Unhandled exception at 0x004114d4 in SAMPLE.exe: 0xC0000005: Access violation reading location 0x00000000.
Here is the piece of code that contains error:
// ...
WCHAR *Path = L"./LIFE.bmp";
D3DXIMAGE_INFO *Info;
IDirect3DSurface9 *Surface = NULL;
LPDIRECT3DDEVICE9 pd3dDevice;
// ...
D3DXGetImageInfoFromFile(Path, Info); // everything is fine here, unless i do the following:
pd3dDevice -> CreateOffscreenPlainSurface(Info->Width, Info->Height, Info->Format, D3DPOOL_SYSTEMMEM, &Surface, NULL);
So, what is happening here? And when I type in numbers instead of Info->..., everything works fine…
You pass uninitialized pointer
Infoand when method tries to access you get the exception. What you need is the following:Also, I’d recommend you handling result codes of any function that returns HRESULT. Like:
If you use DXUT.h then
V()orV_RESULTmacros are your best friends:OR