Detect WebGL availability?

Get help using Construct 2

Post » Sun Aug 10, 2014 11:07 pm

Is there a way to detect WebGL availability?

I'm working on a game that requires WebGL.
I would like to be able to detect a lack of WebGL support, and display a, "This game requires WebGL", notice.

--- Edit:
I just thought of a workaround.
I can make my "WebGL Required" notice cover the game's title screen, and then place a WebGL shader on it that makes it transparent. If WebGL is working, then you won't see the notice. If WebGL is not working then the notice will show up.

I'm still interested to know if there is an event condition that can check for WebGL support, if anyone knows of one.
Thanks. :)
B
27
S
18
G
8
Posts: 331
Reputation: 6,164

Post » Sun Aug 10, 2014 11:54 pm

@fisholith You can display on screen if you game is currently using Canvas/WebGL.

I made you a Capx check it out and let me know if this is what you are looking for.

https://www.dropbox.com/s/kbf03l3vq84yf ... nning.capx


Edit to your Edit: In that Capx is a Expression/Event that checks if WebGL is working!
B
16
S
2
Posts: 34
Reputation: 914

Post » Mon Aug 11, 2014 12:59 am

can i for example check device in order to enable or desable webgl ?

for exemple ... detect if its iphone 4 then disable webgl else activate it ???
B
46
S
16
G
8
Posts: 794
Reputation: 8,335

Post » Mon Aug 11, 2014 2:18 pm

The system condition 'Effects are supported' is true when WebGL is supported, and the system expression 'renderer' returns "webgl" in WebGL mode (else "canvas2d").
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Wed Aug 13, 2014 1:53 pm

Wow, very helpful replies. :)

Thanks Ashley, "Effects are supported" sounds like exactly what I'm looking for.

Likewise SHG, thanks for making a demo cap. That's awesome.
B
27
S
18
G
8
Posts: 331
Reputation: 6,164


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 9 guests