39 lines
701 B
Java
39 lines
701 B
Java
package speiger.src.coreengine.rendering.textures.base;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
|
|
|
public abstract class BaseTexture implements ITexture {
|
|
protected int id;
|
|
|
|
protected BaseTexture() {
|
|
this(GL11.glGenTextures());
|
|
}
|
|
|
|
protected BaseTexture(int id) {
|
|
this.id = id;
|
|
track();
|
|
}
|
|
|
|
protected void track() {
|
|
GLStateTracker.TEXTURE_TRACKER.registerTexture(this);
|
|
}
|
|
|
|
@Override
|
|
public int id() {
|
|
return id;
|
|
}
|
|
|
|
@Override
|
|
public void bind(int unit) {
|
|
GLStateTracker.TEXTURES.bind(unit, id);
|
|
}
|
|
|
|
@Override
|
|
public void delete() {
|
|
GL11.glDeleteTextures(id);
|
|
GLStateTracker.TEXTURE_TRACKER.deleteTexture(this);
|
|
}
|
|
}
|