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

LF in getProgramInfoLog #50

Open
AlexVestin opened this issue Aug 13, 2019 · 1 comment
Open

LF in getProgramInfoLog #50

AlexVestin opened this issue Aug 13, 2019 · 1 comment

Comments

@AlexVestin
Copy link
Contributor

AlexVestin commented Aug 13, 2019

A (very) minor issue, but there is a linefeed in the getProgramInfoLog after it has been linked
Edit: Also when created it should yield a 0 length string, but instead there is a 1 length string,
with a null char. So maybe double null characters have been added?

const nodeGles = require("node-gles");
const gl = nodeGles.binding.createWebGLRenderingContext();
var program = gl.createProgram();
let log = gl.getProgramInfoLog(program);

console.log(log.length, log.charCodeAt(0));

const vs = `// Vertex Shader
void main() {
  gl_Position = vec4(1.);
}`

const fs = `// Fragment shader
void main() {
  gl_FragColor = vec4(1.);
}`

function loadShader(gl, type, source) {
    const shader = gl.createShader(type);  
    gl.shaderSource(shader, source);  
    gl.compileShader(shader);  
    if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
      gl.deleteShader(shader);
      return null;
    }
    return shader;
}

gl.attachShader(program, loadShader(gl, gl.VERTEX_SHADER, vs));
gl.attachShader(program, loadShader(gl, gl.FRAGMENT_SHADER, fs));
gl.linkProgram(program);

if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
    console.error('Unable to initialize the shader program: ' + gl.getProgramInfoLog(program));
}

log = gl.getProgramInfoLog(program);
console.log(log.length, log.charCodeAt(0))

yields

1 0
2 10

Which makes checks for if (log === "") fail

@AlexVestin
Copy link
Contributor Author

AlexVestin commented Aug 15, 2019

Actually getProgramInfoLog doesn't return the log-string when the shaders fail
That was just the error popping up in shaders instead, my bad

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