* Make sure to set texture max level depending on whether mipmaps are to be generated, included in texture, or not required at all - this reduces memory allocated by GPU for textures that do not use mipmaps.
This commit is contained in:
parent
68cb1e900f
commit
465e2b2280
@ -1850,18 +1850,24 @@ public class LwjglRenderer implements Renderer {
|
||||
}
|
||||
|
||||
if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) {
|
||||
// No pregenerated mips available,
|
||||
// generate from base level if required
|
||||
// Image does not have mipmaps, but they are required.
|
||||
// Generate from base level.
|
||||
|
||||
if (!GLContext.getCapabilities().OpenGL30) {
|
||||
glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
img.setMipmapsGenerated(true);
|
||||
}
|
||||
} else {
|
||||
// Image already has mipmaps or no mipmap generation desired.
|
||||
// glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0 );
|
||||
if (img.getMipMapSizes() != null) {
|
||||
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
|
||||
// For OpenGL3 and up.
|
||||
// We'll generate mipmaps via glGenerateMipmapEXT (see below)
|
||||
}
|
||||
} else if (img.hasMipmaps()) {
|
||||
// Image already has mipmaps, set the max level based on the
|
||||
// number of mipmaps we have.
|
||||
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
|
||||
} else {
|
||||
// Image does not have mipmaps and they are not required.
|
||||
// Specify that that the texture has no mipmaps.
|
||||
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
}
|
||||
|
||||
int imageSamples = img.getMultiSamples();
|
||||
|
Loading…
x
Reference in New Issue
Block a user