-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwgl.jl
82 lines (70 loc) · 2 KB
/
wgl.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
### A Pluto.jl notebook ###
# v0.17.7
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
end
end
# ╔═╡ 5ae60086-7fb3-11ec-259d-a1dd2769199a
begin
import Pkg
Pkg.activate(Base.current_project())
using Images, Colors, Lazy, PlutoUI, HypertextLiteral
end
# ╔═╡ 82ab7cd4-8ec8-4b01-a5d7-d7c82b0d1080
@bind color Slider(0:.01:1.0)
# ╔═╡ 68fd8813-c5ba-488e-b020-2c72cc35aea4
@htl("""
<script src="https://npmcdn.com/regl/dist/regl.min.js"></script>
<script id="foo">
//# sourceURL=foo.js
const node = this ?? document.createElement("div")
if (this == null) {
node.style.width = "600px"
node.style.height = "400px"
console.log("Setup")
node.regl = createREGL(node)
node.drawTriangle = node.regl({
frag: `
void main() {
gl_FragColor = vec4(1, 0, 0, 1);
}`,
vert: `
attribute vec2 position;
void main() {
gl_Position = vec4(position, 0, 1);
}`,
attributes: {
position: [[0, -1], [-1, 0], [1, 1]]
},
count: 3
})
}
console.log("Main body")
node.regl.clear({
color: [0, $(color), 1, 1]
})
node.drawTriangle()
return node
</script>
""")
# ╔═╡ 05e21459-9e0e-4671-9848-c032e58cb0b1
md"""
TODO
-----------
- Understand regl
- frame function
- picogl
- pure webgl
"""
# ╔═╡ Cell order:
# ╠═5ae60086-7fb3-11ec-259d-a1dd2769199a
# ╠═82ab7cd4-8ec8-4b01-a5d7-d7c82b0d1080
# ╠═68fd8813-c5ba-488e-b020-2c72cc35aea4
# ╠═05e21459-9e0e-4671-9848-c032e58cb0b1