openfl icon indicating copy to clipboard operation
openfl copied to clipboard

The word "uniform" in a comment in GLSL in a shader causes cast exception

Open 47rooks opened this issue 3 years ago • 1 comments

Describe the bug I have a comment with the word uniform in it in the GLSL code in @:glFragmentSource. Running the code generates this error trying to construct my shader:

Called from $Reflect.setField (D:\Programs Files\HaxeToolkit\haxe\std/hl/_std/Reflect.hx line 40) Called from openfl.display.Shader.__processGLData (openfl/display/Shader.hx line 673) Called from openfl.display.Shader.__initGL (openfl/display/Shader.hx line 472) Called from openfl.display.$GraphicsShader.constructor (openfl/display/GraphicsShader.hx line 104) Called from flixel.graphics.tile.$FlxGraphicsShader.constructor (flixel/graphics/tile/FlxGraphicsShader.hx line 76) Called from $LetterShader.constructor (LetterShader.hx line 283) ... ... ... Can't cast openfl.display.ShaderParameter_Bool to openfl.display.ShaderParameter_Float Uncaught exception: Can't cast openfl.display.ShaderParameter_Bool to openfl.display.ShaderParameter_Float

To Reproduce Create a FlxShader shader class. I used flixel not openfl but you could do it directly. In your @:glFragmentSource GLSL string include a comment like mine containing the word uniform:

        /**
         * Here we use the u_time uniform to change the letter
         * we display. u_time is the time in seconds since the shader
         * began running.
         */

lime test hl -debug

You'll get a stack and error like the above.

Expected behavior The shader should run without error.

Additional context Here is my haxelib list in case it helps: flixel-addons: [2.11.0] flixel-ui: [2.4.0] flixel: [4.11.0] lime: [7.9.0] openfl: [9.1.0]

47rooks avatar Apr 16 '22 17:04 47rooks

I guess it's because the parser is not smart enough. But I think there is few chances of fixing that.

loudoweb avatar Aug 14 '22 09:08 loudoweb