Sign in to follow this  

[.net] [SlimDX]Sorting textures

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

While trying to create a sprite rendering class, I found that grouping the sprites based on texture gained a nice speed improvement. However, I am currently sorting the sprites on an ID given to them when I load them, which isn't very practical. How can I sort them on the internal texture pointer they have? I tried modifying slimdx to make the internal pointer public, but I couldn't see it since I don't reference the directx sdk in my game.

Share this post


Link to post
Share on other sites
You can't, really, without building some machinery yourself.

One option is to maintain a Dictionary<int,Texture> mapping the IDs you already give your sprite to textures they use. Another option is to map from texture file name to Texture object.

The internal pointer is intentional not exposed; you can't usefully do anything with it, as you discovered. There is some talk of possibily exposing underlying pointers as a CLI compatible IntPtr type, but I don't know what the status of that is.

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
There is some talk of possibily exposing underlying pointers as a CLI compatible IntPtr type, but I don't know what the status of that is.
We've decided to do it, it just hasn't been done yet. By exposing an IntPtr, you're able to at least compare it, pass it to other libraries, etc. You can do more with unsafe code, but it's a lot of work. Anyway, it will look like this:

property IntPtr NativePointer
{
IntPtr get() { return IntPtr( m_Pointer ); }
}

Share this post


Link to post
Share on other sites
Thanks, comparing the IntPtr's is a nice solution!

This will also work with textures that aren't loaded from a file, so I think it's the cleanest. The only ugly part is having to convert the pointers to a int, but that's how the framework is set up, I suppose..

Share this post


Link to post
Share on other sites

This topic is 3727 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this