Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

80
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda