Skip to content

Commit e1b732e

Browse files
authored
feat: Vertex Array Objects (#20)
1 parent ec8c9d4 commit e1b732e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/byegl/src/attribute.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,10 @@ export class ByeGLVertexArrayObject {
3030
};
3131
}
3232
}
33+
34+
export function destroyVAO(vao: ByeGLVertexArrayObject) {
35+
const internal = vao[$internal];
36+
internal.boundElementArrayBuffer = null;
37+
internal.enabledVertexAttribArrays.clear();
38+
internal.vertexBufferSegments = [];
39+
}

packages/byegl/src/byegl-context.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { TgpuRoot } from 'typegpu';
2-
import { AttributeState, ByeGLVertexArrayObject } from './attribute.ts';
2+
import {
3+
AttributeState,
4+
ByeGLVertexArrayObject,
5+
destroyVAO,
6+
} from './attribute.ts';
37
import { ByeGLBuffer, VertexBufferSegment } from './buffer.ts';
48
import {
59
blendEquationMap,
@@ -543,6 +547,10 @@ export class ByeGLContext {
543547
}
544548
}
545549

550+
deleteVertexArray(vao: ByeGLVertexArrayObject | null): void {
551+
vao && destroyVAO(vao);
552+
}
553+
546554
depthFunc(func: GLenum): void {
547555
// TODO: Do something with this value
548556
this.#parameters.set(gl.DEPTH_FUNC, func);

0 commit comments

Comments
 (0)