mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-20 20:32:14 +00:00
32 lines
526 B
Java
32 lines
526 B
Java
package net.coderbot.iris.gl;
|
|
|
|
public abstract class GlResource {
|
|
private final int id;
|
|
private boolean isValid;
|
|
|
|
protected GlResource(int id) {
|
|
this.id = id;
|
|
isValid = true;
|
|
}
|
|
|
|
public final void destroy() {
|
|
if (!isValid) return;
|
|
destroyInternal();
|
|
isValid = false;
|
|
}
|
|
|
|
protected abstract void destroyInternal();
|
|
|
|
protected void assertValid() {
|
|
if (!isValid) {
|
|
throw new IllegalStateException("Tried to use a destroyed GlResource");
|
|
}
|
|
}
|
|
|
|
protected int getGlId() {
|
|
assertValid();
|
|
|
|
return id;
|
|
}
|
|
}
|