stanoddly / DotnetRaylibWasm

Prototype for .NET 7 with Raylib compiled into WebAssembly (wasm)
MIT License
61 stars 8 forks source link

Shader examples don't work #9

Closed stanoddly closed 1 year ago

stanoddly commented 1 year ago

Any example using demo shaders is failing, I suspect that the demo examples don't include the GLES shaders, but didn't really have time to take a look.

See for example: https://disketteman.github.io/DotnetRaylibWasm/raylib.html?arg=TextureWaves

WARNING: SHADER: [ID 13] Failed to compile fragment shader code
dotnet.js:14 WARNING: SHADER: [ID 13] Compile error: ERROR: 0:1: '
dotnet.js:14 ' : invalid version directive
dotnet.js:14 ERROR: 0:4: 'in' : storage qualifier supported in GLSL ES 3.00 and above only
dotnet.js:14 ERROR: 0:4: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:5: 'in' : storage qualifier supported in GLSL ES 3.00 and above only
dotnet.js:14 ERROR: 0:5: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:9: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:12: 'out' : storage qualifier supported in GLSL ES 3.00 and above only
dotnet.js:14 ERROR: 0:12: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:14: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:16: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:18: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:19: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:20: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:21: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:22: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:23: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:26: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:27: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:28: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:29: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:30: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:32: '' : No precision specified for (float)
dotnet.js:14 ERROR: 0:36: 'texture' : no matching overloaded function found
dotnet.js:14 
dotnet.js:14 WARNING: SHADER: [ID 14] Failed to link shader program
dotnet.js:14 WARNING: SHADER: [ID 14] Link error: Fragment shader is not compiled.
stanoddly commented 1 year ago

Yes, I was correct. The original raylib examples uses this:

#if defined(PLATFORM_DESKTOP)
    #define GLSL_VERSION            330
#else   // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
    #define GLSL_VERSION            100
#endif

The examples from ChrisDill/Raylib-cs-Examples have hardcoded version of shaders which isn't compatible with WebGl. For example: https://github.com/ChrisDill/Raylib-cs-Examples/blob/master/Examples/Shaders/BasicLighting.cs#L68