Skip to content

Commit d765de4

Browse files
fix: Upgrade remaining non-javascript like types
To be referenced in same way. Simplify FunctionNode. Update documentation to be more straightforward. Remove code no longer needed from WebGL2 FunctionNode.
1 parent 2599966 commit d765de4

File tree

22 files changed

+285
-308
lines changed

22 files changed

+285
-308
lines changed

README.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,72 @@ const myFunc = gpu.createKernel(function() {
167167
myFunc();
168168
// Result: [0, 1, 2, 3, ... 99]
169169
```
170+
171+
### Declaring variables
172+
173+
GPU.js makes variable declaration inside kernel functions easy. Variable types supported are:
174+
Numbers
175+
Array(2)
176+
Array(3)
177+
Array(4)
178+
179+
Numbers example:
180+
```js
181+
const myFunc = gpu.createKernel(function() {
182+
const i = 1;
183+
const j = 0.89;
184+
return i + j;
185+
}).setOutput([100]);
186+
```
187+
188+
Array(2) examples:
189+
Using declaration
190+
```js
191+
const myFunc = gpu.createKernel(function() {
192+
const array2 = [0.08, 2];
193+
return array2;
194+
}).setOutput([100]);
195+
```
196+
197+
Directly returned
198+
```js
199+
const myFunc = gpu.createKernel(function() {
200+
return [0.08, 2];
201+
}).setOutput([100]);
202+
```
203+
204+
Array(3) example:
205+
Using declaration
206+
```js
207+
const myFunc = gpu.createKernel(function() {
208+
const array2 = [0.08, 2, 0.1];
209+
return array2;
210+
}).setOutput([100]);
211+
```
212+
213+
Directly returned
214+
```js
215+
const myFunc = gpu.createKernel(function() {
216+
return [0.08, 2, 0.1];
217+
}).setOutput([100]);
218+
```
219+
220+
Array(4) example:
221+
Using declaration
222+
```js
223+
const myFunc = gpu.createKernel(function() {
224+
const array2 = [0.08, 2, 0.1, 3];
225+
return array2;
226+
}).setOutput([100]);
227+
```
228+
229+
Directly returned
230+
```js
231+
const myFunc = gpu.createKernel(function() {
232+
return [0.08, 2, 0.1, 3];
233+
}).setOutput([100]);
234+
```
235+
170236
## Accepting Input
171237
### Supported Input Types
172238
* Numbers
@@ -368,15 +434,16 @@ To strongly type a function you may use options. Options take an optional hash
368434
`returnType`: optional, defaults to float, the value you'd like to return from the function
369435
`paramTypes`: optional, defaults to float for each param, a hash of param names with values of the return types
370436

371-
Types: that may be used for `returnType` or for each property of `paramTypes`:
437+
Types: that may be used for `returnType` or for each property of `paramTypes`:
372438
'Array'
373439
'Array(2)'
374440
'Array(3)'
375441
'Array(4)'
376-
'Integer'
377442
'HTMLImage'
378443
'HTMLImageArray'
379444
'Number'
445+
'NumberTexture'
446+
'ArrayTexture(4)'
380447

381448
Example:
382449
```js

bin/gpu-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 1.10.0
8-
* @date Sun Oct 28 2018 13:54:33 GMT-0400 (EDT)
8+
* @date Tue Oct 30 2018 07:33:44 GMT-0600 (MDT)
99
*
1010
* @license MIT
1111
* The MIT License

bin/gpu-core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)