Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
add framebuffer clear
Browse files Browse the repository at this point in the history
  • Loading branch information
slmjkdbtl committed Dec 28, 2023
1 parent 0429bae commit c4d0215
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gfx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ export class FrameBuffer {
return canvas.toDataURL()
}

clear() {
const gl = this.ctx.gl
gl.clear(gl.COLOR_BUFFER_BIT)
}

draw(action: () => void) {
this.bind()
action()
Expand Down Expand Up @@ -435,6 +440,7 @@ export class Mesh {

function genStack<T>(setFunc: (item: T) => void) {
const stack: T[] = []
// TODO: don't do anything if pushed item is the same as the one on top?
const push = (item: T) => {
stack.push(item)
setFunc(item)
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3219,6 +3219,7 @@ export declare class FrameBuffer {
height: number
toImageData(): ImageData
toDataURL(): string
clear(): void
draw(action: () => void): void
bind(): void
unbind(): void
Expand Down

0 comments on commit c4d0215

Please sign in to comment.