Results 1 to 4 of 4

Thread: Render texture to other webgl canvas element

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    4

    Render texture to other webgl canvas element

    Hi,

    Does anyone know what the fastest/most efficient way is of getting a displayed texture from webgl canvas A and copy/display it onto webgl canvas B? (Canvas B needs to be dynamically updated with the changes made in canvas A)

    I'm trying to do this with a framebuffer object and rendering it to a texture, but I get an error in canvas B : WebGL bind texture: Object from different webgl context (or older generation of this one) passed as argument.

    any idea's are welcome

    thanks,

  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    4

    Re: Render texture to other webgl canvas element

    The way I'm fixing it now is by using the .toDataURL() method. It works, but it's really slow. Anyone another idea?

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Location
    Kingston, Ontario, Canada
    Posts
    29

    Re: Render texture to other webgl canvas element

    I am not sure why you are trying copy Canvas A to Canvas B. Why not just render your image to both Canvases? i.e. Rerender instead of copy?
    "We often compare ourselves to the U.S.
    and often they come out the best,
    but they only have the right to bear arms
    while we have the right to bare breasts"
    Song "Busting The Breast" by Bowser & Blue

  4. #4
    Junior Member
    Join Date
    Jan 2012
    Posts
    2

    Re: Render texture to other webgl canvas element

    In canvas B you can use canvas A as texture input and display that texture. texImage2D accepts HTMLCanvasElement as parameter :

    Code :
    var canvasA = document.getElementById('canvasA');
    ...
    gl.texImage2D(gl.TEXTURE_2D, ..., canvasA);

    If you want automatically update the output in canvas B you can use texSubImage2D. See the specs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •