Jump to content
  • Advertisement
Sign in to follow this  
Michael Tanczos

slimdx/directshow.net - Custom allocator porting problem

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

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

Share this post


Link to post
Share on other sites
Advertisement
I don't know VB, but in C# you could just do Texture texture = surface.GetContainer<Texture>() and be done with it. All ComObjects know their native interface and GUID so you don't have to worry about it.

Share this post


Link to post
Share on other sites
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.

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!