opera-romana-pellegrinaggi / geography-of-the-faith

An interactive website, presenting the Geography of the Catholic Faith throughout different countries
0 stars 0 forks source link

check for webgl support #45

Open JohnRDOrazio opened 3 days ago

JohnRDOrazio commented 3 days ago

I recently came across a situation where a PC did not have support for webgl (either webgl wasn't enabled in the browser, or the PC didn't have a graphics card that supports webgl).

Rather than seeing a big red error that makes it look like the codebase has errors, we should do a check for webgl support, and only continue if webgl is supported. If it's not, show a message indicating that webgl support is required for this project to function correctly.

Example check for WebGL support:

      // Get WebGLRenderingContext from canvas element.
      const gl =
        canvas.getContext("webgl") || canvas.getContext("experimental-webgl");

      // Report the result.
      const webglSupportMessage =
        gl instanceof WebGLRenderingContext
          ? "Congratulations! Your browser supports WebGL."
          : "Failed. Your browser or device may not support WebGL.";
JohnRDOrazio commented 3 days ago

Actually we're not directly initializing the WebGL context, Cesium JS is. See here how to handle this:

https://community.cesium.com/t/webgl-troubleshooting/2366/5

JohnRDOrazio commented 3 days ago

We could have a 2d version of the application that would be useable on machines that don't have WebGL support. Then we would redirect to the 2d version when WebGL is not supported.