FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gpu.js/examples/random.html at develop · gpujs/gpu.js · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
gpujs
/
gpu.js
Public
Notifications
You must be signed in to change notification settings
Fork
663
Star
15.4k
Code
Issues
64
Pull requests
2
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
gpu.js
/
examples
/
random.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (58 loc) · 1.46 KB
Breadcrumbs
gpu.js
/
examples
/
random.html
Copy path
File metadata and controls
66 lines (58 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!DOCTYPE html
>
<
html
lang
="
en
"
>
<
head
>
<
meta
charset
="
utf-8
"
>
<
title
>
GPU.js Random Examples
</
title
>
</
head
>
<
body
>
<
h2
>
CPU Random
</
h2
>
<
canvas
id
="
cpu-random-output
"
>
</
canvas
>
<
h2
>
WebGL1 Random
</
h2
>
<
canvas
id
="
web-gl-random-output
"
>
</
canvas
>
<
h2
>
WebGL2 Random
</
h2
>
<
canvas
id
="
web-gl2-random-output
"
>
</
canvas
>
</
body
>
<
script
src
="
../dist/gpu-browser.min.js
"
>
</
script
>
<
script
>
let
cpu
,
webGL
,
webGL2
;
cpu
=
new
GPU
(
{
mode
:
'cpu'
,
canvas
:
document
.
getElementById
(
'cpu-random-output'
)
}
)
;
try
{
webGL
=
new
GPU
(
{
mode
:
'webgl'
,
canvas
:
document
.
getElementById
(
'web-gl-random-output'
)
}
)
;
}
catch
(
e
)
{
}
try
{
webGL2
=
new
GPU
(
{
mode
:
'webgl2'
,
canvas
:
document
.
getElementById
(
'web-gl2-random-output'
)
}
)
;
}
catch
(
e
)
{
}
function
drawRandomFunction
(
)
{
this
.
color
(
Math
.
random
(
)
,
Math
.
random
(
)
,
Math
.
random
(
)
)
;
}
const
cpuDrawRandom
=
cpu
.
createKernel
(
drawRandomFunction
)
.
setGraphical
(
true
)
.
setOutput
(
[
100
,
100
]
)
;
const
webGLDrawRandom
=
webGL
?
webGL
.
createKernel
(
drawRandomFunction
)
.
setGraphical
(
true
)
.
setOutput
(
[
100
,
100
]
)
:
(
)
=>
{
}
;
const
webGL2DrawRandom
=
webGL2
?
webGL2
.
createKernel
(
drawRandomFunction
)
.
setGraphical
(
true
)
.
setOutput
(
[
100
,
100
]
)
:
(
)
=>
{
}
;
function
draw
(
)
{
cpuDrawRandom
(
)
;
webGLDrawRandom
(
)
;
webGL2DrawRandom
(
)
;
requestAnimationFrame
(
draw
)
;
}
requestAnimationFrame
(
draw
)
;
</
script
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL