* Forgot to commit this quite crucial class ..
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9619 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
b0286ae5ff
commit
896c0d31a5
engine/src/core/com/jme3/texture
@ -325,9 +325,53 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
||||
protected int multiSamples = 1;
|
||||
// protected int mipOffset = 0;
|
||||
|
||||
// attributes relating to GL object
|
||||
protected boolean mipsWereGenerated = false;
|
||||
protected boolean needGeneratedMips = false;
|
||||
|
||||
/**
|
||||
* Internal use only.
|
||||
* The renderer marks which images have generated mipmaps in VRAM
|
||||
* and which do not, so it can generate them as needed.
|
||||
*
|
||||
* @param generated If mipmaps were generated or not.
|
||||
*/
|
||||
public void setMipmapsGenerated(boolean generated) {
|
||||
this.mipsWereGenerated = generated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use only.
|
||||
* Check if the renderer has generated mipmaps for this image in VRAM
|
||||
* or not.
|
||||
*
|
||||
* @return If mipmaps were generated already.
|
||||
*/
|
||||
public boolean isMipmapsGenerated() {
|
||||
return mipsWereGenerated;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Package private) Called by {@link Texture} when
|
||||
* {@link #isMipmapsGenerated() } is false in order to generate
|
||||
* mipmaps for this image.
|
||||
*/
|
||||
void setNeedGeneratedMipmaps() {
|
||||
needGeneratedMips = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the image needs to have mipmaps generated
|
||||
* for it (as requested by the texture).
|
||||
*/
|
||||
public boolean isGeneratedMipmapsRequired() {
|
||||
return needGeneratedMips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetObject() {
|
||||
this.id = -1;
|
||||
this.mipsWereGenerated = false;
|
||||
setUpdateNeeded();
|
||||
}
|
||||
|
||||
|
@ -339,6 +339,9 @@ public abstract class Texture implements CloneableSmartAsset, Savable, Cloneable
|
||||
"minificationFilter can not be null.");
|
||||
}
|
||||
this.minificationFilter = minificationFilter;
|
||||
if (minificationFilter.usesMipMapLevels() && image != null && !image.isGeneratedMipmapsRequired()) {
|
||||
image.setNeedGeneratedMipmaps();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,6 +396,9 @@ public abstract class Texture implements CloneableSmartAsset, Savable, Cloneable
|
||||
*/
|
||||
public void setImage(Image image) {
|
||||
this.image = image;
|
||||
|
||||
// Test if mipmap generation required.
|
||||
setMinFilter(getMinFilter());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -474,22 +480,23 @@ public abstract class Texture implements CloneableSmartAsset, Savable, Cloneable
|
||||
* the anisotropic filtering level for this texture.
|
||||
*/
|
||||
public void setAnisotropicFilter(int level) {
|
||||
if (level < 1)
|
||||
if (level < 1) {
|
||||
anisotropicFilter = 1;
|
||||
else
|
||||
} else {
|
||||
anisotropicFilter = level;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append("[name=").append(name);
|
||||
if (image != null)
|
||||
if (image != null) {
|
||||
sb.append(", image=").append(image.toString());
|
||||
}
|
||||
|
||||
sb.append("]");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user