Skip to main content
GameDev.net gamedev.net
🔒 Locked

slimdx/directshow.net - Custom allocator porting problem

Started by Michael Tanczos Jun 6, 2009 at 9:23 PM 2 replies 2.4k views
Original Post
Michael Tanczos
Michael Tanczos
Hey all, I'm trying to port the directshow.net custom allocator example to us vb.net and slimdx.. but I'm not entirely sure how to port one line of code. Notes: - the unmanagedSurfaces array is an array of Int32's - 85C31227-3DE5-4f00-9B3A-F11AC38C18B5 is the GUID for IDirect3DTexture9 - the line confusing me is Dim text As Texture = DirectCast(surf.GetContainer((New Guid("85C31227-3DE5-4f00-9B3A-F11AC38C18B5")), Texture)

surfaces = New Hashtable(unmanagedSurfaces.Length)
textures = New Hashtable(unmanagedSurfaces.Length)

For i As Integer = 0 To lpNumBuffers - 1
   Dim surf As Surface = Surface.FromPointer(unmanagedSurfaces(i))

   ' How do I convert this line to work with slimDX?
   Dim text As Texture = DirectCast(surf.GetContainer((New Guid("85C31227-3DE5-4f00-9B3A-F11AC38C18B5")), Texture)

   surfaces.Add(unmanagedSurfaces(i), surf)
   textures.Add(unmanagedSurfaces(i), text)
Next


This line of code seems to be attempting to obtain the reference for a texture associated with the original surface based on the surface itself. It is backwards from creating a texture and referencing one of the texture surfaces. The slimDX version would require "Public Function GetContainer(Of TContainer As ComObject) As TContainer" (member function of the Surface class) but IDirect3DTexture seems to be undefined. Any ideas on how to get this texture? Thanks so much. - Michael Tanczos
Mike.Popoloski
Mike.Popoloski
I don't know VB, but in C# you could just do Texture texture = surface.GetContainer() and be done with it. All ComObjects know their native interface and GUID so you don't have to worry about it.
Mike Popoloski | Journal | SlimDX
Michael Tanczos
Michael Tanczos
Oh nice.. the solution then is:
Dim text As Texture = DirectCast(surf.GetContainer(Of Texture)(), Texture)

Thanks.
Promit
Promit
Just do:
text = surf.GetContainer(Of Texture)()
Assuming I've got the VB syntax right. SlimDX knows to do the rest on its own.

[EDIT] Beaten [sad] But you don't need the DirectCast, either! Pretty slick, huh?

P.S. GetContainer is not a fast function. Keep that in mind.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

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

Sign in to reply to this topic.