Jump to content
  • Advertisement
Sign in to follow this  
GoodFun

[SlimDX] Write textures to disk

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

Heya, is there a way in SlimDX to write DirectX 10 textures to disk after they have been created? My textures are all 16 and 32 bit floats (not RGB, even though internally that is just value mapping). Any help would be greatly appreciated. Thanks Marcel

Share this post


Link to post
Share on other sites
Advertisement
Use D3D10.Texture.ToFile(), as sirob said (e.g., the base class method not the derived class method).

Share this post


Link to post
Share on other sites
I see, it's a static... I assume I would need DDS format to store the data exactly the way it exists in memory, right?

Share this post


Link to post
Share on other sites
DDS will pretty much dump the texture as it exists in memory* verbatim onto disk. Of course, any non lossy format (PNG, BMP, etc) will preserve the data as long as it can handle the pixel format.
*May not be strictly true due to drivers messing with data format, but is close enough to reality.

Share this post


Link to post
Share on other sites
Thanks guys, got it to work... now, would it be possible to add a ToStream() method to the Texture class? The texture in raw format are a tad large in dds format, and so I would like to run the stream through a gzip to compress the data. Unfortunately I can't use png which is compressed as my texture format is 16 bit floats and png doesn't seem to support that texture format.

I know this is a pretty rare request, though maybe some other people might find it useful too if they can get ToStream, and maybe even ToMemory, i.e. the same methods as the ones used to load a texture map.

Thanks
Marcel

Share this post


Link to post
Share on other sites
Quote:

now, would it be possible to add a ToStream()

Unlikely. If you file a bug report I can look into it, but my guess is that there isn't any way we can do that and still have reasonable performance -- our FromStream methods are already a hidden performance pitfall, ToStream would engender even worse performance since we'd need to readback the data to get it into memory (not always doable) or write to disk and read into a stream.

The issue is that there is no native method to do this.

What's wrong with locking the texture? It produces a DataStream, which models System.IO.Stream.

Share this post


Link to post
Share on other sites
well, my system will create the textures dynamically on one server, store them gzipped in dds format on the disk and then load them on multiple other servers for rendering.

I guess I'll have to write the dds to disk and then gzip it there... shouldn't be a problem, I was just hoping I could do it straight in the program without having to do a 'two-step'

Thanks for the insight though

Marcel

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
The issue is that there is no native method to do this.

That's not entirely accurate. Texture.ToFile just calls D3DX10SaveTextureToFile. A ToFileInMemory method could simply call D3DX10SaveTextureToMemory.

Share this post


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

  • 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!