free opengl resources
This commit is contained in:
@@ -2,15 +2,17 @@ package chess.view.DDDrender.opengl;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
public class VertexBuffer {
|
||||
private int id;
|
||||
private int dataStride;
|
||||
List<VertexAttribPointer> vertexAttribs;
|
||||
public class VertexBuffer implements Closeable {
|
||||
private final int id;
|
||||
private final int dataStride;
|
||||
private final List<VertexAttribPointer> vertexAttribs;
|
||||
|
||||
public VertexBuffer(float[] data, int stride) {
|
||||
this.id = GL30.glGenBuffers();
|
||||
@@ -28,10 +30,6 @@ public class VertexBuffer {
|
||||
Unbind();
|
||||
}
|
||||
|
||||
public void Destroy() {
|
||||
GL30.glDeleteBuffers(id);
|
||||
}
|
||||
|
||||
public void Bind() {
|
||||
GL30.glBindBuffer(GL30.GL_ARRAY_BUFFER, this.id);
|
||||
}
|
||||
@@ -52,4 +50,9 @@ public class VertexBuffer {
|
||||
this.dataStride * 4, vertexAttribPointer.offset());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
GL30.glDeleteBuffers(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user