• Advertisement
Sign in to follow this  

what is the different?

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

D3DXLoadSurfaceFromMemory D3DXLoadSurfaceFromSurface they seem to do the same job,.

Share this post


Link to post
Share on other sites
Advertisement
another question:

D3DXLoadSurfaceFromMemory load texture surface(in memory) to another surface by GetSurfaceLevel() something like this.

what does D3DXLoadSurfaceFromFileInMemory load? a data that use io file function(like FILE* or fstream)? is not it a memory block that get by GetSurfaceLevel?

Share this post


Link to post
Share on other sites
D3DXLoadSurfaceFromMemory will load the data for a surface from memory pixel data. D3DXLoadSurfaceFromSurface will load the data for a surface from pixel data contained in another surface, or rect in the surface (It duplicates the surface).

Quote:
what does D3DXLoadSurfaceFromFileInMemory load? a data that use io file function(like FILE* or fstream)? is not it a memory block that get by GetSurfaceLevel?
Yup. It will read the file header, and decompress the data (So you can pass in PNG, JPEG data, etc). D3DXLoadSurfaceFromMemory expects the data to already be compressed and in the same format as the surface.

Basically; D3DXLoadSurfaceFrom*() [not InMemory] wants the input data in pixel-information, so it can just convert colour depth (I don't even know if it does that, the docs don't specify).
D3DXLoadSurfaceFromFile*() expects you to pass it the actual file data, which may be compressed. D3DX will uncompress the data and load it into the surface.

Share this post


Link to post
Share on other sites
Quote:

D3DXLoadSurfaceFromMemory will load the data for a surface from memory pixel data. D3DXLoadSurfaceFromSurface will load the data for a surface from pixel data contained in another surface, or rect in the surface (It duplicates the surface).


I mean in D3DXLoadSurfaceFromMemory , the memory must be from a surface. something like lock a surface,and get a pointer to surface data, and the pointer is actually what does D3DXLoadSurfaceFromMemory need. if the pointer is not point to a surface, it point a common memory block,D3DXLoadSurfaceFromMemory will fail. am I right?

so D3DXLoadSurfaceFromSurface just do a little more work than D3DXLoadSurfaceFromMemory , if you use D3DXLoadSurfaceFromMemory ,you must lock surface and get a pointer. if you use D3DXLoadSurfaceFromSurface ,you just pass a surface pointer.

Share this post


Link to post
Share on other sites
Nope. The data passed to D3DXLoadSurfaceFromMemory can be any data, it doesn't have to be from a surface. A good example would be if you write your own image format - You'd decompress the image into a memory buffer, and then use D3DXLoadSurfaceFromMemory to load that into a surface.

D3DXLoadSurfaceFromSurface is useful if you want to duplicate a surface, or if you want to do a sort of "copy and paste" operation between two surfaces. In this case, the source has to be a surface.

Share this post


Link to post
Share on other sites
'Memory' can be any memory at all, for example you could use data that you've loaded from a file, or data that you've produced with some procedural algorithm. It doesn't have to be within a surface.

~phil

Share this post


Link to post
Share on other sites


HRESULT hr_getbuffer = d->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
if(FAILED(hr_getbuffer))
{
MessageBox(0,"fail to load",0,0);
}



HRESULT hr = D3DXLoadSurfaceFromMemory(backbuffer, 0, 0, (void*)pl,D3DFMT_X8R8G8B8, width * 4, 0, 0, D3DX_FILTER_NONE, 0xff000000);
if(FAILED(hr))
{
MessageBox(0,"fail to load",0,0);
}




it popup fail to load. ; errorName: D3DERR_INVALIDCALL.

what may lead to the error?
1.parameter passed is bad.
2.backbuffer is locked before.

give me some clue about it. thanks.

Share this post


Link to post
Share on other sites
another queston: what are different between D3DXLoadSurfaceFromMemory and IDirect3DDevice9::GetRenderTargetData ?

it seem to GetRenderTargetData optimize to get card memory to system memory ,it can not copy any surface to each other.and D3DXLoadSurfaceFromMemory can copy any surface to each other. right?

Share this post


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

  • Advertisement