Skip to content
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

Examples removed WebGL1 option #6307

Merged
merged 4 commits into from
Apr 29, 2024
Merged
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
1 change: 0 additions & 1 deletion examples/iframe/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function getDeviceType() {
case 'webgpu':
console.warn('Picked WebGPU but example is not supported on WebGPU, defaulting to WebGL2');
return 'webgl2';
case 'webgl1':
case 'webgl2':
return savedDevice;
default:
Expand Down
30 changes: 9 additions & 21 deletions examples/src/app/components/DeviceSelector.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Don't include all of 'playcanvas' for these defines, it just
// causes bigger bundles and prolongs the build time by ~3s.
import {
DEVICETYPE_WEBGL1,
DEVICETYPE_WEBGL2,
DEVICETYPE_WEBGPU,
DEVICETYPE_NULL
Expand All @@ -13,9 +12,8 @@ import { jsx } from '../jsx.mjs';
import '../events.js';

const deviceTypeNames = {
[DEVICETYPE_WEBGL1]: 'WebGL 1',
[DEVICETYPE_WEBGL2]: 'WebGL 2',
[DEVICETYPE_WEBGPU]: 'WebGPU',
[DEVICETYPE_WEBGL2]: 'WebGL 2',
[DEVICETYPE_NULL]: 'Null'
};

Expand Down Expand Up @@ -91,28 +89,19 @@ class DeviceSelector extends TypedComponent {
/**
* If our preferred device was e.g. WebGPU, but our active device is suddenly e.g. WebGL 2,
* then we basically infer that WebGPU wasn't supported and mark it like that.
* @param {string} preferredDevice - The preferred device.
* @param {string} activeDevice - The active device reported from the example iframe.
* @param {DEVICETYPE_WEBGPU | DEVICETYPE_WEBGL2} preferredDevice - The preferred device.
* @param {DEVICETYPE_WEBGPU | DEVICETYPE_WEBGL2} activeDevice - The active device reported from
* the example iframe.
*/
setDisabledOptions(preferredDevice = 'webgpu', activeDevice) {
if (
(preferredDevice === DEVICETYPE_WEBGL2 || preferredDevice === DEVICETYPE_WEBGPU) &&
activeDevice === DEVICETYPE_WEBGL1
) {
const fallbackOrder = [DEVICETYPE_WEBGPU, DEVICETYPE_WEBGL2, DEVICETYPE_WEBGL1];
setDisabledOptions(preferredDevice = DEVICETYPE_WEBGPU, activeDevice) {
if (preferredDevice === DEVICETYPE_WEBGL2 && activeDevice !== DEVICETYPE_WEBGL2) {
const fallbackOrder = [DEVICETYPE_WEBGL2];
const disabledOptions = {
[DEVICETYPE_WEBGPU]: 'WebGPU (not supported)',
[DEVICETYPE_WEBGL2]: 'WebGL 2 (not supported)'
};
this.mergeState({ fallbackOrder, disabledOptions, activeDevice });
} else if (preferredDevice === DEVICETYPE_WEBGL1 && activeDevice === DEVICETYPE_WEBGL2) {
const fallbackOrder = [DEVICETYPE_WEBGL1, DEVICETYPE_WEBGL2, DEVICETYPE_WEBGPU];
const disabledOptions = {
[DEVICETYPE_WEBGL1]: 'WebGL 1 (not supported)'
};
this.mergeState({ fallbackOrder, disabledOptions, activeDevice });
} else if (preferredDevice === DEVICETYPE_WEBGPU && activeDevice !== DEVICETYPE_WEBGPU) {
const fallbackOrder = [DEVICETYPE_WEBGPU, DEVICETYPE_WEBGL2, DEVICETYPE_WEBGL1];
const fallbackOrder = [DEVICETYPE_WEBGPU, DEVICETYPE_WEBGL2];
const disabledOptions = {
[DEVICETYPE_WEBGPU]: 'WebGPU (not supported)'
};
Expand Down Expand Up @@ -161,9 +150,8 @@ class DeviceSelector extends TypedComponent {
return jsx(SelectInput, {
id: 'deviceTypeSelectInput',
options: [
{ t: deviceTypeNames[DEVICETYPE_WEBGL1], v: DEVICETYPE_WEBGL1 },
{ t: deviceTypeNames[DEVICETYPE_WEBGL2], v: DEVICETYPE_WEBGL2 },
{ t: deviceTypeNames[DEVICETYPE_WEBGPU], v: DEVICETYPE_WEBGPU },
{ t: deviceTypeNames[DEVICETYPE_WEBGL2], v: DEVICETYPE_WEBGL2 },
{ t: deviceTypeNames[DEVICETYPE_NULL], v: DEVICETYPE_NULL }
],
value: activeDevice,
Expand Down
17 changes: 0 additions & 17 deletions examples/src/examples/misc/multi-app/controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,6 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
value: observer.get('webgl2')
})
),
jsx(
Panel,
{ headerText: 'WebGL 1' },
jsx(Button, {
text: 'Add',
onClick: () => observer.emit('add:webgl1')
}),
jsx(Button, {
text: 'Remove',
onClick: () => observer.emit('remove:webgl1')
}),
jsx(Label, {
binding: new BindingTwoWay(),
link: { observer, path: 'webgl1' },
value: observer.get('webgl1')
})
),
jsx(
Panel,
{ headerText: 'Null' },
Expand Down
5 changes: 2 additions & 3 deletions examples/src/examples/misc/multi-app/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const createApp = async function (deviceType) {
if (deviceType === 'webgpu') {
device = new pc.WebgpuGraphicsDevice(canvas, {});
await device.initWebGpu(rootPath + '/static/lib/glslang/glslang.js', rootPath + '/static/lib/twgsl/twgsl.js');
} else if (deviceType === 'webgl1' || deviceType === 'webgl2') {
} else if (deviceType === 'webgl2') {
device = new pc.WebglGraphicsDevice(canvas);
} else {
device = new pc.NullGraphicsDevice(canvas, {});
Expand Down Expand Up @@ -93,7 +93,7 @@ const createApp = async function (deviceType) {
app.root.addChild(screen);

// device type as text
const text = app.graphicsDevice.isWebGL1 ? 'WebGL 1' : app.graphicsDevice.isWebGL2 ? 'WebGL 2' : 'WebGPU';
const text = app.graphicsDevice.isWebGL2 ? 'WebGL 2' : 'WebGPU';

// Text with outline to identify the platform
const textOutline = new pc.Entity();
Expand Down Expand Up @@ -124,7 +124,6 @@ const createApp = async function (deviceType) {
const apps = {
webgpu: [],
webgl2: [],
webgl1: [],
null: []
};

Expand Down