Platform
Resources
Pricing
Sign in
Get started
Sean Kelley
Workspace
Fork
Published
By
Sean Kelley
Edited
Sep 4, 2020
Importers
Insert cell
Insert cell
Insert cell
gl
=
{
var
gl
;
const
canvas
=
document
.
createElement
(
'canvas'
)
;
try
{
gl
=
canvas
.
getContext
(
"webgl"
)
;
}
catch
(
x
)
{
gl
=
null
;
}
if
(
gl
==
null
)
{
try
{
gl
=
canvas
.
getContext
(
"experimental-webgl"
)
;
}
catch
(
x
)
{
gl
=
null
;
}
}
return
gl
;
}
Insert cell
webgl_supported
=
gl
?
true
:
false
Insert cell
function
extension_available
(
extension_string
)
{
if
(
webgl_supported
)
{
return
gl
.
getSupportedExtensions
(
)
.
includes
(
extension_string
)
}
}
Insert cell
mutable
has_webgl_context
=
true
;
Insert cell
function
add_context_listener
(
gl
)
{
gl
.
canvas
.
addEventListener
(
"webglcontextlost"
,
(
e
)
=>
{
mutable
has_webgl_context
=
false
;
}
,
false
)
;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gl
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
webgl_supported
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
extension_available
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
has_webgl_context
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
add_context_listener
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
webgl_not_supported_message
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
error_message
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML