Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding webgl2 support and other future releases. #71

Open
Larphoid opened this issue May 9, 2021 · 0 comments
Open

Adding webgl2 support and other future releases. #71

Larphoid opened this issue May 9, 2021 · 0 comments

Comments

@Larphoid
Copy link

Larphoid commented May 9, 2021

Let me start by complimenting on an awesome repository! It's what I was looking for, because I'm pretty sure I would have been trying to work out how to even get WebGL working in the first place.

When trying to prepend 'webgl2' to names[] in function create3DContext(), I kept getting the error "It does not appear your computer can support WebGL...". But I knew WebGL works in my browser, so after some trial and error I found that there was an itty-bitty bug in the code. It turns out that currently the 'experimental-webgl' is always selected, even if 'webgl' would return a valid context because the catch (e) is never reached to break out of the for loop.

Here's what I made of it:

function create3DContext(canvas, optAttribs)
{
var names = ['webgl2', 'webgl', 'experimental-webgl'];
var context = null;
for (var i = 0; i < names.length; ++i)
{
try
{
context = canvas.getContext(names[i], optAttribs);
if (context) break;
}
catch (e)
{
if (context) break; /// Can probably just leave this out all together.
}
}
return context;
}

Hope this helps.

Cheers.

PS: Wow, the code formatting (Insert code) realy made it unreadable 🤮. Have seen better on other sites.

@Larphoid Larphoid mentioned this issue May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant