* 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()) {
|
if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) {
|
||||||
// No pregenerated mips available,
|
// Image does not have mipmaps, but they are required.
|
||||||
// generate from base level if required
|
// Generate from base level.
|
||||||
|
|
||||||
if (!GLContext.getCapabilities().OpenGL30) {
|
if (!GLContext.getCapabilities().OpenGL30) {
|
||||||
glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
|
glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||||
img.setMipmapsGenerated(true);
|
img.setMipmapsGenerated(true);
|
||||||
|
} else {
|
||||||
|
// 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 {
|
} else {
|
||||||
// Image already has mipmaps or no mipmap generation desired.
|
// Image does not have mipmaps and they are not required.
|
||||||
// glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0 );
|
// Specify that that the texture has no mipmaps.
|
||||||
if (img.getMipMapSizes() != null) {
|
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int imageSamples = img.getMultiSamples();
|
int imageSamples = img.getMultiSamples();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user