Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

gajraaj

Alternative to D3DXSaveTextureToFile?

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

I am trying to save a VolumeTexture to a file that has been created with the memory pool set to D3DPOOL_DEFAULT.According to the documentation, this will obviously fail.The alternatives listed are: CopyRects and UpdateTexture. I have the following problem with CopyRects(): I have only the pointer to the IDirect3DVolumeTexture8 interface, how do I get a surface to supply as the first argument to the CopyRects() method?
if( m_usage == 0 && m_pool == D3DPOOL_DEFAULT )
    {
        IDirect3DSurface8* pDestSurf = 0;                            
        
        hr = pDevice->CreateImageSurface( m_width, m_height, m_format, &pDestSurf );
        
        if( FAILED( hr ) )
        {
            //Throw error : "CreateImageSurface() failed" 

        }        
           
        
        hr = pDevice->CopyRects( ????, NULL, 0, pDestSurf, NULL );
        
        if( FAILED( hr ) )
        {
            //Throw Error : "CopyRects() failed"

        }

        hr = D3DXSaveSurfaceToFile(
            fullPath.c_str(), D3DXIFF_DDS, pDestSurf, NULL, NULL );
    }
    else
    { 
        hr = D3DXSaveTextureToFile(
            fullPath.c_str(), D3DXIFF_DDS, m_successor, NULL );
    }
Im debugging some DirectX code and Im quite new to the API. Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
That, and the reason you can''t save in the first place: D3D can''t lock those texture pieces in memory.

For an app that wants to save texture data, have the user cretae textures as managed. That''s really the best idea.

I like pie.

Share this post


Link to post
Share on other sites
quote:
Original post by RenderTarget
That, and the reason you can't save in the first place: D3D can't lock those texture pieces in memory.

For an app that wants to save texture data, have the user cretae textures as managed. That's really the best idea.

I like pie.



But Im a bit confused by this: If textures that are placed in memory cannot be locked then why would the SDK Documentation suggest that they can indeed be accessed and I quote here:
quote:

Textures placed in the D3DPOOL_DEFAULT pool cannot be locked unless they are dynamic textures or they are private (FOURCC) driver formats. To access unlockable textures, you must use functions such as IDirect3DDevice8::CopyRects and IDirect3DDevice8::UpdateTexture.



So this obviously means that there is some way to access the texture data.

[edited by - gajraaj on April 12, 2004 9:30:11 PM]

Share this post


Link to post
Share on other sites
Yes. If the usage is D3DUSAGE_DYNAMIC, and not zero, as the documentation says. D3DUSAGE_DYNAMIC specifies the texture be placed in AGP memory, which is still accessible by the CPU. Usage of 0 tells the driver to go ahead and put it onto the video card, with no system memory backing it. Those can''t be locked.


I like pie.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!