Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG FOUND AND FIXED: dwgl.js bug in uniformT #22

Open
tomviolin opened this issue Jul 26, 2021 · 0 comments
Open

BUG FOUND AND FIXED: dwgl.js bug in uniformT #22

tomviolin opened this issue Jul 26, 2021 · 0 comments

Comments

@tomviolin
Copy link

In dwgl.js the uniformT function does not work when you try to pass more than 1 texture as uniforms to a fragment shader. I have discovered the fix. You need to make the texture active BEFORE you bind it. The fixed function is below. The two lines that need to be switched are the gl.activeTexture and gl.bindTexture lines, which currently are lines 630 and 631 in dwgl.js.

FIXED FUNCTION:

  uniformT(name, val){
    var gl = this.gl;
    var loc = this.uniformLoc(name);
    if(loc){
      gl.activeTexture(gl.TEXTURE0 + this.tex_loc);  // these are the two lines
      gl.bindTexture(gl.TEXTURE_2D, val);            // that needed to be switched 
      gl.uniform1i(loc, this.tex_loc);
      this.tex_loc++;
    } 
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant