Skip to main content
gamedev.net
🔒 Locked

D3DXLoadSurfaceFromFile problem

Started by Emil_Halim 6 replies 3.1k views
Original Post
Emil_Halim
Emil_Halim
Hi All i have a problem using D3DXLoadSurfaceFromFile function, my program crash when it come to execute this function, i really do not know why ? i call it as follow HRESULT rslt; LPDIRECT3DSURFACE9 MySrf; rslt=D3DXLoadSurfaceFromFile(MySrf,"logo.pmb",NULL,D3DX_DEFAULT,0xFF000000,NULL); is there any thing wrong with this call thanks For any help.
Trip99
Trip99
You have to create a surface in advance. You are passing a pointer to nothing at the moment.
------------------------See my games programming site at: www.toymaker.info
Evil Steve
Evil Steve
MySrf isn't created yet. D3DXLoadSurfaceFromFile() requires that the first parameter points to a created surface, which is then filled with the image (And there's no D3DXCreateSurfaceFromFile() which is odd).

Why do you want a surface rather than a texture anyway? Give D3DXCreateTextureFromFile() a look, that might be what you want.
Emil_Halim
Emil_Halim
hi

thanks for all of you.

actually i have a very big text that i scroll in the Screen,so load this
big text in textur make DirectX crash,so i can load it in Surface and
ofcourse mske it resident in system memory.

again thank you very much for helping.
opendx
opendx
I was trying to use D3DXLoadSurfaceFromFile today as well, but it seems like creation of surface prior to loading require knowing the image dimentions, format and probably other info (I gave up after former two). So I use D3DXCreateTextureFromFile() and after obtaining image data simply release that object. Not neat but it work...
Evil Steve
Evil Steve
Quote:
Original post by opendx
I was trying to use D3DXLoadSurfaceFromFile today as well, but it seems like creation of surface prior to loading require knowing the image dimentions, format and probably other info (I gave up after former two). So I use D3DXCreateTextureFromFile() and after obtaining image data simply release that object. Not neat but it work...
I guess that D3DXLoadSurfaceFromFile is useful if you don't want to keep re-creating the surface, e.g. if you're loading different images, but the same size over and over. But I still think the function is a bit stupid.
Emil_Halim
Emil_Halim
you can know the size of your image that you want to load by

D3DXIMAGE_INFO SrcInfo;
D3DXGetImageInfoFromFile(yourFilename,&SrcInfo);

then create the surface as

D3D_Device->CreateOffscreenPlainSurface(SrcInfo.Width,SrcInfo.Height,D3DFMT_X8R8G8B8,D3DPOOL_MANAGED ,&MySrf,NULL);

and finally

D3DXLoadSurfaceFromFile(MySrf,NULL,NULL,yourFilename,NULL,D3DX_FILTER_NONE,NULL,NULL);

this work with me.

thanks

Topic Locked

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

Sign in to reply to this topic.