textures and memory

textures and the loading of um… if i have loads of
textures they seem to have hassle loading dynamicly
into the scene. like if i have 50 odd 1024*1024
textured .png shapes (all different textures).

am i just being mad in hoping it would be ok to
handle that?

you so crazy…

Not gonna be much help here… you could preload them, but that would take a lot of memory. ???

Hi,

As of memory requirements for texture loading, few revisions ago I added to DirectBufferedImage a method that can take existing byte[] of image data and construct an image basing on it.

Also to minimize memory usage you have to implement your own image loading mechanism instead of loading image in BufferedImage and after copying it into DirectBufferedImage like TextureLoader does:

BufferedImage bi;
InputStream imgData;

ImageInputStream stream = ImageIO.createImageInputStream(imgData);
Iterator iter = ImageIO.getImageReaders(stream);
if (iter.hasNext()) 
{
  ImageReader reader = (ImageReader)iter.next();
  ImageReadParam param = reader.getDefaultReadParam();
  reader.setInput(stream, true, true);
  int iw = reader.getWidth(0);
  int ih = reader.getHeight(0);
  BufferedImage dst = DirectBufferedImage.getDirectImageRGBA(iw, ih);
  param.setDestination(dst);
  bi = reader.read(0, param);
  stream.close();
  reader.dispose();
}
else
  stream.close(); 

This code is supposed to save for you up to twice memory during image loading procedure.

Also I am thinking about adding lazy texture loading to the core and renderer, so textures will reside only in video memory rather than in both video and system memory. This sometimes may reduce performance, but in other cases will reduce runtime memory usage.

Yuri

thanks dude- thats world be tops.

i will give your example loader a try… im loading
around 1000 textures (1024*1024). so maybe im being abit overkill. and ive not even started playing with shaders.

looking at halfing the size of a texture and using more then one
texture on my objects.

all fun stuff