Advertisement Jump to content
Sign in to follow this  

Delphi/D3D9: D3DXLoadSurfaceFromFile fails

This topic is 4962 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

var sBackBuffer, sLoadScreen: IDirect3DSurface9;
    pDestLoadscreen: pRECT;
    res: HRESULT;
    path: string;

  res := d3dmgr.pD3DDevice.CreateOffscreenPlainSurface(1024, 768, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, sloadscreen, nil);
  if failed(res) then logfile.MessOut('pD3DDevice.CreateOffscreenPlainSurface failed');

  path := apppath+'data\loadscreen.bmp';
  res := D3DXLoadSurfaceFromFile(sLoadScreen, nil, nil, @path, nil, D3DX_DEFAULT, 0, nil);
  if res=D3D_OK then begin
    pdestloadscreen.Left := 0;
    pdestloadscreen.Top := 0;
    pdestloadscreen.Right := 0;
    pdestloadscreen.Bottom := 0;
    d3dmgr.pD3DDevice.StretchRect(sLoadScreen, nil, sBackBuffer, pdestloadscreen, D3DTEXF_NONE);
    res := d3dmgr.pD3DDevice.Present(nil, nil, 0, nil);
    if failed(res) then
      logfile.MessOut('Loadscreen present failed');
  end else case res of
    D3DERR_INVALIDCALL: logfile.MessOut('Cant load loadscreen-image: D3DERR_INVALIDCALL');
    D3DXERR_INVALIDDATA: logfile.MessOut('Cant load loadscreen-image: D3DERR_INVALIDDATA');
I become D3DERR_INVALIDDATA in the log file. What's wrong in the code? Thanks [Edited by - Maverick89 on June 19, 2005 4:34:40 AM]

Share this post

Link to post
Share on other sites
It seems like D3DXLoadSurfaceFromFile has problems recognizing the data in the file you specified. Check the following:

- Is the path expressed correctly?
- Does the image file exist at the specified location?
- Is the image file valid/nondamaged?

I'm not very familiar with delphi but as far as I can see your code seems fine. In C/C++ you have to use double backslash characters (\\) in paths. I don't know if this goes for delphi too.

Stay sharp.

Share this post

Link to post
Share on other sites
I used debugger to save the variable's value into event log, then copied this value in explorer - it showed the image, so looks like the path is right.
I used fotoshop to convert the image between jpg and bmp - both were not working.

So, I'm now unsure if i transfer the value of "path" correctly: i give a pointer to a string to the LPCTSTR value. The question is, if the pascal-formated string is comaptible.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!