XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

whats the best way to load in and out lots of small textures at runtime

Last post 04/07/2009 8:10 by Mithra. 6 replies.
  • 04/07/2009 2:42

    whats the best way to load in and out lots of small textures at runtime

    well i hope i can make clear my question

    this is for the pc

    ive got in excess of thousands of fairly small bitmaps say 720x50 images
    at real time i maybe useing differing ones depending on the situation i have no idea what the limitations are
    across different pc's to like how xna deals with memory limitations or speed of swapping
    i do know that loading images that arent already turned into xnb files is slow so i cant simply load them in and out
    like that

    worse im not sure in what way i should load unload images 
    since i ran into this particular problem i just put the whole project on the backburner

    in short im looking for advice from anyone who's already dealt with this similar issue
    could point me in the way of a good tutorial on it or any advice at all on this subject as im in unfamiliar territory
    with no lightbulbs going off so to speak
  • 04/07/2009 4:16 In reply to

    Re: whats the best way to load in and out lots of small textures at runtime

    I'm curious about this too.

    I can't update the tiles.tga texture in my strategy game without recompiling the project.

    I'd like to load this resource manually on launch if I can.
  • 04/07/2009 4:17 In reply to

    Re: whats the best way to load in and out lots of small textures at runtime

    use a sprite sheet?
  • 04/07/2009 5:46 In reply to

    Re: whats the best way to load in and out lots of small textures at runtime

    Mithra:
    I'm curious about this too.

    I can't update the tiles.tga texture in my strategy game without recompiling the project.

    I'd like to load this resource manually on launch if I can.


    For this situation it can be useful to create a 2nd project, just for content you are currently working on. If you are working on a handful of textures or w/e, move them into this project, make the changes, and rebuild the 2nd project, you won't have to rebuild the main project. Once done with the changes, move the content back to the main project.
    Game hobbyist hell-bent on coding a diabolical Matrix
  • 04/07/2009 5:49 In reply to

    Re: whats the best way to load in and out lots of small textures at runtime

    xlightwavex:
    ive got in excess of thousands of fairly small bitmaps say 720x50 images
    at real time i maybe useing differing ones depending on the situation i have no idea what the limitations are


    Do you mean depending on the situation, some content will never be drawn? Lazy loading might be a good option for that situation. And you can manage separate ContentManagers for targeted unloading when you know that content won't be needed/drawn again for awhile.
    Game hobbyist hell-bent on coding a diabolical Matrix
  • 04/07/2009 8:02 In reply to

    Re: whats the best way to load in and out lots of small textures at runtime

    For my game I currently load the compiled .XNB files at startup, and support loading the original PNG/TGA textures at runtime if the user presses a button. This allows me to make quick tweaks and iterate without a build, but still get the benefit of the content pipeline's texture compression and keep my game working on the 360.

    If managing the individual assets is becoming a pain, I strongly suggest creating a custom content pipeline type that bundles together groups of related textures into a single .XNB. This will simplify working with the content pipeline without preventing you from doing asset reloading at runtime, since you'll still have knowledge of all the source filenames/paths, which will let you swap new Texture2D instances into your 'texture bundle' asset at runtime on-demand.

    At a bare minimum, you can load individual textures on-demand when needed during the process of loading a level or region of your game world. Ideally, however, if you bundle your textures together properly, you can just load specific bundles for specific levels and only keep those in memory. If you build your content such that certain areas of a level use certain assets, you could even aggressively unload textures that aren't onscreen, and background load textures as soon as they become close to the camera's viewport, so that they're ready before the player sees them. I don't suggest trying anything complicated unless you start running out of memory on the 360 or PC, though. In my experience it's quite hard to run out of memory unless your game has a tremendous amount of textures and assets in use at once (I haven't personally seen any XNA games that come near this threshold yet).
    Kevin Gadd, Squared Interactive
    Development Blog | Twitter
    Help playtest my game, Inferus!
  • 04/07/2009 8:10 In reply to

    Re: whats the best way to load in and out lots of small textures at runtime

    Craig Martin:
    For this situation it can be useful to create a 2nd project, just for content you are currently working on. If you are working on a handful of textures or w/e, move them into this project, make the changes, and rebuild the 2nd project, you won't have to rebuild the main project. Once done with the changes, move the content back to the main project.


    That would be a good idea, but the problem isn't that my project takes forever to compile.

    I'd like to be able to send my artist a compiled executable that will simply load and use the tga files he's working on right out of the game's installation folder.  Obviously my artist shouldn't have to compile the game to see how his art looks.

    I also want my game to support user-created scenarios and user-customized tiles as well, and I can't hardly expect the player to recompile the game.  ;)

    Surely there is some method for loading a Texture2D straight from disk at runtime?

    Kevin Gadd:
    For my game I currently load the compiled .XNB files at startup, and support loading the original PNG/TGA textures at runtime if the user presses a button.


    Kevin, would you mind sharing exactly whatever method it is to load and create a texture from file?  Thanks!
Page 1 of 1 (7 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG