patriciogonzalezvivo / glslCanvas

Simple tool to load GLSL shaders on HTML Canvas using WebGL
http://patriciogonzalezvivo.github.io/glslCanvas/
MIT License
1.99k stars 183 forks source link

Load and render a single frame may fall into a blank #79

Open o-tantk opened 2 years ago

o-tantk commented 2 years ago

I tested very simple html page(below) as local file, and it shows nothing.

<html>
    <head>
        <script type="text/javascript" src="https://rawgit.com/patriciogonzalezvivo/glslCanvas/master/dist/GlslCanvas.js"></script>
    </head>
    <body>
        <canvas class="glslCanvas" data-fragment="
void main() {
    gl_FragColor = vec4(1, 0, 0, 1);
}
            " width="500" height="500"></canvas>
    </body>
</html>

It seems an instant render overwritten or ignored if render timing is too fast. Adding a line that ~postpones rendering~ render once more at the next frame, It works fine.

// glslCanvas.js: 179L
setTimeout(() => { this.forceRender = true; }, 1);

Thanks.