• Advertisement
Sign in to follow this  

[.net] Texture loading in .NET 2.0

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

Hi. I just recently started to switch my game over to Managed DirectX 2.0 and I noticed there is no TextureLoader class. This has become quite an issue for a couple of reasons. 1. Loading by using Texture.FromBitmap is incredibly slow 2. Most of my textures don't even load correctly and when my Sprite objects goto draw them I see nothing All my textures are saved as either 24 or 32 bit PNG files.Can anyone please tell me how I can load my textures properly? Here is the code I am using now:
        public static Texture LoadTexture(Device device, string filepath)
        {
            if (File.Exists(filepath))
            {
                ImageInformation info = Texture.GetImageInformationFromFile(filepath);

                return new Texture(device, filepath, info.Width, info.Height, 1, Usage.None, info.Format, Pool.Managed,
                    Filter.None, Filter.None, 0, false, null);
            }
            else
            {
                EngineState.State = EngineStates.Closing;
                return null;
            }
        }

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I guess you just overlooked the other overloads of the Texture constructor. You can easily load textures:

texture = new Texture(device, filePath);




It seems they have removed all Loaders and replaced it either with an appropriate overload of the constructor or a static method (like Effect.FromFile). Nevertheless I can't find some saving methods (maybe they forgot it: http://exdream.dyn.ee/blog/CommentView.aspx?guid=2811ff76-f35a-4a8c-add1-9a7adff54180)

[Edited by - SlimTimmy on December 31, 2005 10:11:03 AM]

Share this post


Link to post
Share on other sites
I tried that already, and most of my textures don't load properly like that. Out of the 8 textures I load, only 1 loads properly. It's unfortunate that the TextureLoader is gone becuase it used to work perfectly.

Share this post


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

  • Advertisement