0

Some of my clients are failing to initialize a webGL program. I'm catching the error with

gl.linkProgram(program);

if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  throw new Error("Unable to initialize the shader program: " + gl.getProgramInfoLog(program));
}

The log I'm getting is

Unable to initialize the shader program:
C:\fakepath(72,30-133): error X3507: '_directionToColor':
  Not all control paths return a value

I've not been able to reproduce this error on my computer. Does anyone has an idea of what is going wrong? I'm happy to share more code if that's helpful :)

3
  • 1
    Well, it looks like the shader "_directionToColor" is to blame. Line 72, if i'm not mistaken. Can you share the source code of that shader? Commented Jul 1, 2016 at 21:25
  • I'll put the code in the comprehensible way and share it, but I'm not writing _directionToColor anywhere and I have no idea what _directionToColor is about neither does google.. Commented Jul 1, 2016 at 21:34
  • Search all your files for "_directionToColor". I think it's a method somewhere in your shader code. Commented Jul 1, 2016 at 22:52

1 Answer 1

1

Not all control paths return a value is an error that the compiler will throw if you're function looks like

if (...) {
  return ...
} else if (...) {
  return ...
}

Even if one of the two conditions will always be met, the compiler is not smart enough to know that and throws an error. So you have to either change else if to else or add a third return statement that, in practice, will never be used.

I've found that in some environments the shader would compile fine and that in some other (windows) it would fail.

I could not find _directionToColor in my code because the function name is directionToColor and somehow an underscore gets added.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.