Jump to content
  • Advertisement
Sign in to follow this  
decapod

[slimdx] Surface.FromMemory

This topic is 3605 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'm trying to read a custom texture format that supports DXT* (MS Flight Sim special BMP format) using Direct3D9 and VB.NET The file contains 32K of DXT1 data, 256x256 pixels br is a BinaryStream of the file w and h are 256 fmt is Format.Dxt1 size is 32K b() array of bytes b = br.ReadBytes(size) Dim tx As New Texture(d3dd, w, h, 0, Usage.None, fmt, Pool.Managed) s = tx.GetSurfaceLevel(0) ' the properties and surface description of s all seem correct at this point Surface.FromMemory(s, b, Filter.Default, 0) ' this falls over with invalid data error? Do I need to use a different overload to load DXT1 data? I've done this sort of thing many times in the past using DX8 and VB6 with the D3DXSurfaceLoad* methods - they use the pitch rather than the dimensions to load the data. Paul

Share this post


Link to post
Share on other sites
Advertisement
Nothing.
Full debug mode for D3D9, Slimdx ThrowOnError flase, watch added for invalid data.
I output ************ on the line before, it breaks there, F5 just continues with no loaded image.

Output window shows the following:
(The first 2 IO exceptions are from reading the MDL file)

A first chance exception of type 'System.IO.EndOfStreamException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.EndOfStreamException' occurred in Decapod.Mdl.dll
'MDLViewer.exe': Loaded 'C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Configuration\cb4cb21d14767292e079366a5d3d76cd\System.Configuration.ni.dll', No symbols loaded.
'MDLViewer.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MDLViewer.exe': Loaded 'C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Xml\36f3953f24d4f0b767bf172331ad6f3e\System.Xml.ni.dll', No symbols loaded.
'MDLViewer.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
************************************
(Pressed F5 to continue here)
Direct3D9: (WARN) :Ignoring redundant SetTextureStageState. Stage: 1, State: 1

Share this post


Link to post
Share on other sites
Ah - I notice you're using
D3DXLoadSurfaceFromFileInMemory instead of D3DXLoadSurfaceFromMemory
in Surface.cpp

So I would need to supply a surface description structure as part of the byte data (I would need to do something similar to use Texture.FromMemory)

That doesn't make slimdx too useful for loading custom texture formats.

Share this post


Link to post
Share on other sites
Gah. Everything always has to be so difficult...I'll take a look at straightening out the Surface creation functions.

Share this post


Link to post
Share on other sites
Thanks for that and indeed thanks for the whole of SlimDX.

I wouldn't have got this far if I had to use C++ :)

Share this post


Link to post
Share on other sites
Solved for now (I hope) I went back to basics - seems to work OK but needs a bit of refining...

Dim lrect As System.Drawing.Rectangle
Dim dRect As SlimDX.DataRectangle
Dim tx As New Texture(d3dd, w, h, 1, Usage.None, fmt, Pool.Managed)

s = tx.GetSurfaceLevel(0)
lrect.Width = w
lrect.Height = h
dRect = s.LockRectangle(lrect, LockFlags.None)
dRect.Data.Write(b, 0, b.Length)
s.UnlockRectangle()

Share this post


Link to post
Share on other sites
That's probably all D3DXLoadSurfaceFromMemory really does, although it's hard to say for sure. Glad to know you found a workaround though, because the next official release is a long ways out.

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!