Browse Source

clearing the image when going to edit mode

master
Inderjit Gill 1 month ago
parent
commit
3e511bb464
2 changed files with 18 additions and 6 deletions
  1. +6
    -0
      typescript/src/App.ts
  2. +12
    -6
      typescript/src/Renderer.ts

+ 6
- 0
typescript/src/App.ts View File

@@ -288,6 +288,12 @@ async function renderEditorScript(state: State) {
// function that takes a read-only state and updates the UI
//
async function updateUI(state: State) {
if (state.currentMode === SeniMode.edit) {
// clear the buffer so that the previous piece isn't shown whilst the new piece is being rendered
gGLRenderer.clearBuffer();
await gGLRenderer.copyImageDataTo(gUI.renderImage);
}

showCurrentMode(state);

switch (state.currentMode) {

+ 12
- 6
typescript/src/Renderer.ts View File

@@ -591,14 +591,20 @@ class GLRenderer2 {
}
}

public renderTextureToScreen(meta: any, canvasWidth: number, canvasHeight: number) {
if (this.gl === null) {
public clearBuffer() {
if (!this.gl) {
return;
}
if (this.framebuffer === null) {
return;
}
if (this.blitShader === null) {

const gl = this.gl;

gl.bindFramebuffer(gl.FRAMEBUFFER, null);
// gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
}

public renderTextureToScreen(meta: any, canvasWidth: number, canvasHeight: number) {
if (!this.gl || !this.framebuffer || !this.blitShader) {
return;
}


Loading…
Cancel
Save