PDA

View Full Version : D3DXLoadSurfaceFromFile doesn't work? *solved*



FusionWolf
30-01-2005, 01:27 AM
Hi,

I'm trying to load bitmap (.bmp) to a surface with DirectX 9 D3DXLoadSurfaceFromFile() function. It doesn't matter how I try I get D3DERR_INVALIDCALL all the time. Where might be the problem?


function LoadSurfaceFromFile(var Surface: IDirect3DSurface9; FileName: pchar): HRESULT;
var
ImageInfo: TD3DXImageInfo;
begin
Result := D3DXLoadSurfaceFromFile(Surface, nil, nil, FileName, nil, D3DX_DEFAULT, $FFFF00FF, @ImageInfo);
end;


After a call, surface is nil, ImageInfo contains random data (checked in debug mode) and result is D3DERR_INVALIDCALL. I have tried to call the function in different parts of my (game) application (even in my mainloop), but that doesn't help. Any help is welcome - thank you.

edit: Just popped into my mind. Do I have to create that surface first somehow or does D3DXLoadSurfaceFormFile() create it?

edit2: I just tried to create surface first with CreateOffscreenPlainSurface() function but, that fails too.

edit3: SOLVED. The problem was the bitmap itself. It didn't have alpha channel at all and when I tried to create offscreen plain surface I used the information which I got from the image with D3DXGetImageInfoFromFile() function.