Another new reason why your JavaScript doesn't work

When I released CopperLicht a few days ago, it didn't work on some Mac OS X systems, but this has been fixed now. So what could possible make a JavaScript library which works perfectly on Windows and Linux not work in the same browsers (Chrome, Safari, Firefox) on Mac OS X?

CopperLicht uses WebGL to render 3d graphics, and uses GLSL shaders to do this. GLSL shaders are simple programs which are sent to the graphics drivers, which then compiles these and runs them on the GPU. One of the major benefits of GLSL is, as quoted from the Wikipedia page:

Cross platform compatibility on multiple operating systems, including Linux, Mac OS and Windows.

But since I now found and fixed the bug which caused CopperLicht not to work on MacOSX, I can say this statement is not true. Different graphics driver, different shader features you can use. Appearently the compilers in different graphic drivers currently don't even agree if you can multiply a vec4 with an integer or not. Which caused CopperLicht to tragically fail on Mac OS X systems with a driver which didn't want you to multiply vec4's with integers.

Great, so I guess testing if your javaScript works on different browsers now has been taken to the next level. You also need to check operating systems and installed graphic drivers!

Anyway, so if you are going to write a game using WebGL in JavaScript, you can circumvent this by using a 3d engine like CopperLicht. The engine developers (== me) will be taking care of this :)

eleven comments, already:

It is completely normal to not allow multiplication vec4 with integer to vec4. GLSL 1.10.59 and 1.20.8 specifications doesn’t specify that implicit casting is allowed. It is bug in software if it assumes it can convert.
bubu () - 11 02 10 - 12:24

The difference is only between writing
x * 5
x * 5.0
so, it should be possible for the compiler to do this, without any side effects, i guess. not sure what the specification says, but on windows, all implementations allow that.
niko - 11 02 10 - 12:45

”... The engine developers (== me) will be taking care of this”

That’s what I want from a cross platform solution: Protect me from platform details. I’m appreciating this.
hermitC () (link) - 11 02 10 - 12:53

That’s one of the reasons why I once switched from GLSL to CG / DX and HLSL – because the GLSL compilers have to be built by the graphic card vendors and you can’t rely on the same behaviour across different vendors or even across different driver versions.
einWikinger (link) - 11 02 10 - 14:58

Yep, GLSL has easily the biggest variance across machines – compile and link errors and runtime behaviour can all change. nvidia are always more lenient than ati, for example allowing some Cg/HLSL constructs like mul() to work even though they’re not in the spec. Also conversions are more lenient so you can do “gl_FragColor = vec4(, 1);” on nvidia but you have to do “gl_FragColor = vec4(var_depth.x, var_depth.x, var_depth.x, 1);” on ati. I’ve talked to ati about it and they’re actually working on making their drivers a bit more forgiving too just to make developers lives easier when porting.
steve () (link) - 11 02 10 - 15:24

Just one question Niko…when do you sleep? Nice work again
Carlos () - 11 02 10 - 21:27

Are you using #version on your glsl shaders? Because on my pc everything worked without the glsl version declartion but on the mac it just exploaded. After reading a bit i realized that nv docs suggest you to use #version on glsl because than their compiler are more standard conform. Also using #version 120 would give you warnings when you compile x * 5 on the pc (at least mine does)
wolfmanfx () - 12 02 10 - 08:43

sleep? ha. :)
@wolmanfx: ah, that’s a good idea, I’ll try that out.
niko - 12 02 10 - 08:45

Float * integer is not allowed on my windows implementation. But just cast all the time and you’re fine!
xDan () (link) - 13 02 10 - 19:59

I am very disappointed how your new projects seem to abandon open source. Shame on you
moo - 17 02 10 - 12:04

so, moo, how many successful open source projects did you start? I guess niko did quite a few more than you.
dan - 17 02 10 - 13:26

Remember personal info?
Email (optional):
URL (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile

  ( Register your username / Log in )

Notify: Yes, send me email when someone replies.  

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.