Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

84
Visualizações
Wait until WebGL has drawn onto screen

I switched from using 2D context to using WebGL context. I'm trying to figure out a way to wait until pixels have been drawn onto the screen.

With 2D context I would do something like this

const handlePaintFrame = () => {
  const ctx: CanvasRenderingContext2D | any = videoCanvasRef?.current?.getContext("2d");

  if (video.current && videoCanvasRef.current && ctx) {
    if (chroma?.keyColor) {
      drawChromaFrame(ctx, width, height);
    } else {
      ctx.drawImage(video.current, 0, 0, width, height);
    }

    const rendered = () => {
      setTimeout(() => {
        onReady("video");
      }, 20);
    };

    const startRender = () => {
      requestAnimationFrame(rendered);
    };

    const img = new Image();

    img.onload = () => {
      requestAnimationFrame(startRender);
    };

    img.onerror = (e: any) => {
      console.log("Image error:", { e });
    };

    img.src = videoCanvasRef.current.toDataURL();
  }
};

Currently my draw code for the WebGL context is something like this

const drawTexture = () => {
  // render
  if (gl && video.current) {
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, video.current);
    drawScene(locationRef.current, buffersRef.current);
  }
};

const handlePaintFrame = () => {
  if (video.current) {
    if (chroma?.keyColor) {
      // drawChromaFrame(ctx, width, height);
    } else {
      drawTexture();

      // TODO: We need to wait until texture is drawn
      setTimeout(() => {
        onReady("video");
      }, 100);
    }
  }
};
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda