Skip to content

fix: Update GPU instantiation to use GPU.GPU() in example files #843

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/fluid.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
this.keys = {};

this.canvas = document.createElement('canvas');
const gpu = this.gpu = new GPU({
const gpu = this.gpu = new GPU.GPU({
canvas: this.canvas,
mode: 'gpu'
});
Expand Down
2 changes: 1 addition & 1 deletion examples/internal-variable-precision.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h2>GPU.js Internal variable precision: <span id="ivp"></span></h2>
<script src="../dist/gpu-browser.min.js"></script>
<script>
const ivp = document.getElementById('ivp');
const gpu = new GPU();
const gpu = new GPU.GPU();
const startSize = 10;
const fullSize = window.innerWidth;
const kernel = gpu.createKernel(function() {
Expand Down
2 changes: 1 addition & 1 deletion examples/mandelbrot-set.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
return Math.sqrt(vector[0]*vector[0]+vector[1]*vector[1]);
}

const gpu = new GPU();
const gpu = new GPU.GPU();

gpu
.addFunction(f)
Expand Down
2 changes: 1 addition & 1 deletion examples/mandelbulb.html
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ <h1>Mandelbulb - Real-time 3d fractal<br> in Javascript</h1>
document.addEventListener('pointerlockchange', lockChange, false);

const gl = canvas.getContext('webgl2', { premultipliedAlpha: false });
const gpu = new GPU({ canvas, webGl: gl })
const gpu = new GPU.GPU({ canvas, webGl: gl })
.addFunction(sdPlane)
.addFunction(mandelbulb)
.addFunction(distScene)
Expand Down
2 changes: 1 addition & 1 deletion examples/parallel-raytracer.html
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ <h3>Benchmark</h3>
LIGHTSPHERE: Entity.Type.LIGHTSPHERE
}
};
var gpu = new GPU({ mode });
var gpu = new GPU.GPU({ mode });
addFunctions(gpu, vectorFunctions);
addFunctions(gpu, utilityFunctions);
return gpu.createKernel(function(camera, lights, entities, eyeVector, vpRight, vpUp, canvasHeight, canvasWidth, fovRadians, heightWidthRatio, halfWidth, halfHeight, cameraWidth, cameraHeight, pixelWidth, pixelHeight, xOffset, yOffset) {
Expand Down
6 changes: 3 additions & 3 deletions examples/random.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ <h2>WebGL2 Random</h2>
<script>
let cpu, webGL, webGL2;

cpu = new GPU({
cpu = new GPU.GPU({
mode: 'cpu',
canvas: document.getElementById('cpu-random-output')
});
try {
webGL = new GPU({
webGL = new GPU.GPU({
mode: 'webgl',
canvas: document.getElementById('web-gl-random-output')
});
} catch (e) {}
try {
webGL2 = new GPU({
webGL2 = new GPU.GPU({
mode: 'webgl2',
canvas: document.getElementById('web-gl2-random-output')
});
Expand Down
4 changes: 2 additions & 2 deletions examples/raytracer.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
tactic: 'precision',
};
};
const gpu = new GPU();
const cpu = new GPU({ mode: 'cpu'});
const gpu = new GPU.GPU();
const cpu = new GPU.GPU({ mode: 'cpu'});
function vectorDotProduct(V1x, V1y, V1z, V2x, V2y, V2z) {
return (V1x * V2x) + (V1y * V2y) + (V1z * V2z);
}
Expand Down
4 changes: 1 addition & 3 deletions examples/simple-javascript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { GPU } = require('../src');

const gpu = new GPU({ mode: 'gpu' });

const gpu = new GPU();
// Look ma! I can javascript on my GPU!
function kernelFunction(anInt, anArray, aNestedArray) {
const x = .25 + anInt + anArray[this.thread.x] + aNestedArray[this.thread.x][this.thread.y];
Expand Down
2 changes: 1 addition & 1 deletion examples/slow-fade.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>Slow Fade</h1>
<script src="../dist/gpu-browser.min.js"></script>
<script>
const canvas = document.getElementById('c');
const gpu = new GPU({
const gpu = new GPU.GPU({
canvas: canvas,
mode: 'gpu'
});
Expand Down