corvid
corvid

Reputation: 11197

detecting compatible webgl browsers with flask

to begin, I am not sure if this is viable. However, in many Three.js examples I see something like this:

if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

this works well on the front end, but I was wondering if there was a way to do this in flask. Eg,

@app.route('/webgl/<example>')
def webgl_example(example='sphere.html')
  # if no webgl: return redirect(url_for('get_webgl'))
  return render_template(example)

Upvotes: 0

Views: 536

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1124110

You cannot detect this reliably by User-Agent alone, no. It could not work on Firefox for example, because the graphics driver the user uses is blocked, or it was specifically disabled.

The JS capability test is still the best way to detect if WebGL is supported. Detect it in the browser and use an AJAX request to communicate this with your server, or set a cookie with JS that your server can look for.

Upvotes: 1

Related Questions