[LWJGL] Best way to handle resizing textures

Hi!

In my engine, I’m starting to battle with load times. This is due to how textures are loaded. Currently, when I load a texture I use a nice image loading library called Thumbnails. It takes in many image formats, handles resizing, and outputs a bufferedImage. This is useful for having a “Texture Quality” setting in the game, as I can use thumbnails to easily resize the buffered image before it is packed into a buffer and sent to the GPU.

This, however, is a little costly. So my question is how do most 3d games handle texture quality settings? Are the texture sizes pre-generated? Are they resized using FBO’s? I would like to move away from BufferedImages, as they seem to be slow to load and take up a lot of memory.

Generating mipmaps live is way too costly, especially if you want to compress them as well. All major engines, especially the ones that do texture streaming, store all mipmaps precomputed in file(s). Therefore, it’s relatively trivial to choose which mipmap levels to load at all when loading them in.

If you’re using LWJGL3, look into using the STBimage. It’s much faster, threadsafe (so you can load multiple images in parallel, which ImageIO can’t), uses less memory that is explicitly allocated by you (so no garbage collection whatsoever), handles sRGB correctly, etc.

1 How many pixels are drawn
2 How many calculations on pixels drawn
3 Downscale resolution of image

@Hydroque

  1. Irrelevant, nothing is draw.
  2. Irrelevant, nothing is drawn.
  3. Irrelevant, the point is to improve relative performance.