free opengl resources

This commit is contained in:
2025-04-28 18:23:29 +02:00
parent 0fb24263e0
commit ec98b05d61
12 changed files with 113 additions and 33 deletions

View File

@@ -1,10 +1,13 @@
package chess.view.DDDrender.opengl;
import java.io.Closeable;
import java.io.IOException;
import org.lwjgl.opengl.GL30;
public class ElementBuffer {
private int id;
private int indiciesCount;
public class ElementBuffer implements Closeable {
private final int id;
private final int indiciesCount;
public ElementBuffer(int[] indicies) {
this.indiciesCount = indicies.length;
@@ -15,10 +18,6 @@ public class ElementBuffer {
Unbind();
}
public void Destroy() {
GL30.glDeleteBuffers(this.id);
}
public void Bind() {
GL30.glBindBuffer(GL30.GL_ELEMENT_ARRAY_BUFFER, this.id);
}
@@ -30,4 +29,9 @@ public class ElementBuffer {
public int GetIndiciesCount() {
return this.indiciesCount;
}
@Override
public void close() throws IOException {
GL30.glDeleteBuffers(this.id);
}
}