Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DLoadSurfaceFromFileInMemory error

Started by mystb Jan 1, 2009 at 2:52 AM 1 replies 600+ views
Original Post
mystb
mystb
Happy new year!!! I'm just trying to display a texture on screen with StretchRect, but failed miserably in any attempt till now. some related code:

....
int len= FS_GetBinaryFile(filename, buf, buflen);
surfaceid=VIDTEXTURE_CreateSurface(size, cachetype); 

LPDIRECT3DSURFACE9 surface=VIDTEX_GetSurface(surfaceid);

if(FAILED(D3DXLoadSurfaceFromFileInMemory(surface, 
                   NULL, NULL, buf, len, NULL, D3DX_DEFAULT, 0, NULL))){
    throw(ERR_VIDLOADSURFACE);
}


....

int VIDTEXTURE_CreateSurface(unsigned int size, int type){
   ...
   get a pointer to a surface cache
   ...
   if(FAILED(device->CreateOffScreenPlainSurface(size, size, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surfacecache[type][index], NULL)))
      throw(ERR_VIDCREATESURFACE);
   return index+type * CACHE_ROW_SIZE;
}

I tried loading a dds file, but moved to a simpler 24 bits bmp done with paint. The image is 512x512, the correct size is received from FS_GetBinaryFile, but D3DLoadSurfaceFromFileInMemory always fail. What is wrong here ? :(
mystb
mystb
thank you very very much for the help [smile].
With that I was able to isolate a memory problem, although the dx error was "filetype not supported", but helped me look for the error.

Topic Locked

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

Sign in to reply to this topic.