|
|
@@ -1385,7 +1385,7 @@ public class LwjglRenderer implements Renderer {
|
|
|
Texture tex = rb.getTexture();
|
|
|
Image image = tex.getImage();
|
|
|
if (image.isUpdateNeeded()) {
|
|
|
- updateTexImageData(image, tex.getType(), tex.getMinFilter().usesMipMapLevels(), 0);
|
|
|
+ updateTexImageData(image, tex.getType(), 0);
|
|
|
|
|
|
// NOTE: For depth textures, sets nearest/no-mips mode
|
|
|
// Required to fix "framebuffer unsupported"
|
|
|
@@ -1775,7 +1775,15 @@ public class LwjglRenderer implements Renderer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void updateTexImageData(Image img, Texture.Type type, boolean mips, int unit) {
|
|
|
+ /**
|
|
|
+ * Uploads the given image to the GL driver.
|
|
|
+ *
|
|
|
+ * @param img The image to upload
|
|
|
+ * @param type How the data in the image argument should be interpreted.
|
|
|
+ * @param updateMipsOnly If true, then texture data is already updated for this image, only
|
|
|
+ * @param unit The texture slot to be used to upload the image, not important
|
|
|
+ */
|
|
|
+ public void updateTexImageData(Image img, Texture.Type type, int unit) {
|
|
|
int texId = img.getId();
|
|
|
if (texId == -1) {
|
|
|
// create texture
|
|
|
@@ -1800,13 +1808,15 @@ public class LwjglRenderer implements Renderer {
|
|
|
statistics.onTextureUse(img, true);
|
|
|
}
|
|
|
|
|
|
- if (!img.hasMipmaps() && mips) {
|
|
|
+ if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) {
|
|
|
// No pregenerated mips available,
|
|
|
// generate from base level if required
|
|
|
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);
|
|
|
@@ -1871,21 +1881,22 @@ public class LwjglRenderer implements Renderer {
|
|
|
}
|
|
|
|
|
|
if (GLContext.getCapabilities().OpenGL30) {
|
|
|
- if (!img.hasMipmaps() && mips && img.getData() != null) {
|
|
|
+ if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired() && img.getData() != null) {
|
|
|
// XXX: Required for ATI
|
|
|
glEnable(target);
|
|
|
glGenerateMipmapEXT(target);
|
|
|
glDisable(target);
|
|
|
+ img.setMipmapsGenerated(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
img.clearUpdateNeeded();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void setTexture(int unit, Texture tex) {
|
|
|
Image image = tex.getImage();
|
|
|
- if (image.isUpdateNeeded()) {
|
|
|
- updateTexImageData(image, tex.getType(), tex.getMinFilter().usesMipMapLevels(), unit);
|
|
|
+ if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated()) ) {
|
|
|
+ updateTexImageData(image, tex.getType(), unit);
|
|
|
}
|
|
|
|
|
|
int texId = image.getId();
|