Skip to content

Commit cdc1fe3

Browse files
committed
Update docs for luma.gl v9 and API changes
Revised documentation to reflect luma.gl v9 updates, including changes to GPU parameter handling, device initialization, and usage of string constants over WebGL constants.
1 parent 75dd4f3 commit cdc1fe3

File tree

3 files changed

+123
-15
lines changed

3 files changed

+123
-15
lines changed

docs/api-reference/core/deck.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,35 +147,40 @@ Note:
147147

148148
#### `parameters` (object) {#parameters}
149149

150-
Expects an object with GPU parameters. Before each frame is rendered, this object will be passed to luma.gl's `setParameters` function to reset the GPU context parameters, e.g. to disable depth testing, change blending modes etc. The default parameters set by `Deck` on initialization are the following:
150+
Expects an object with GPU parameters. Before each frame is rendered, this object will be passed to luma.gl's `RenderPass` to reset the GPU context parameters, e.g. to disable depth testing, change blending modes etc. The default parameters set by `Deck` on initialization are the following:
151151

152152
```js
153153
{
154154
blend: true,
155-
blendFunc: [GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA, GL.ONE, GL.ONE_MINUS_SRC_ALPHA],
155+
blendColorSrcFactor: 'src-alpha',
156+
blendColorDstFactor: 'one-minus-src-alpha',
157+
blendAlphaSrcFactor: 'one',
158+
blendAlphaDstFactor: 'one-minus-src-alpha'
156159
polygonOffsetFill: true,
157-
depthTest: true,
158-
depthFunc: GL.LEQUAL
160+
depthWriteEnabled: true,
161+
depthCompare: 'less-equal'
159162
}
160163
```
161164

162-
Refer to the luma.gl [setParameters](https://github.com/visgl/luma.gl/blob/8.5-release/modules/gltools/docs/api-reference/parameter-setting.md) API for documentation on supported parameters and values.
165+
Refer to the luma.gl [GPU parameters](https://luma.gl/docs/api-reference/core/parameters) API for documentation on supported parameters and values.
163166

164167
```js
165-
import GL from '@luma.gl/constants';
166168
new Deck({
167169
// ...
168170
parameters: {
169-
blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],
170-
depthTest: false
171+
blendColorSrcFactor: 'one',
172+
blendColorDstFactor: 'one',
173+
blendAlphaSrcFactor: 'one',
174+
blendAlphaDstFactor: 'one'
175+
depthWriteEnabled: false
171176
}
172177
});
173178
```
174179

175180
Notes:
176181

177182
- Any GPU `parameters` prop supplied to individual layers will still override the global `parameters` when that layer is rendered.
178-
- An alternative way to set `parameters` is to instead define the `onWebGLInitialized` callback (it receives the `gl` context as parameter) and call the luma.gl `setParameters` method inside it.
183+
- An alternative way to set `parameters` is to instead define the `onDeviceInitialized` callback (it receives the `device.handle` context as parameter) and call the luma.gl `setParameters` method inside it.
179184

180185
#### `layers` (LayersList) {#layers}
181186

docs/api-reference/mesh-layers/simple-mesh-layer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import TabItem from '@theme/TabItem';
1616
```js
1717
import {Deck} from '@deck.gl/core';
1818
import {SimpleMeshLayer} from '@deck.gl/mesh-layers';
19-
import {OBJLoader} from '@deck.gl/obj';
19+
import {OBJLoader} from '@loaders.gl/obj';
2020

2121
const layer = new SimpleMeshLayer({
2222
id: 'SimpleMeshLayer',
@@ -49,7 +49,7 @@ new Deck({
4949
```ts
5050
import {Deck, PickingInfo} from '@deck.gl/core';
5151
import {SimpleMeshLayer} from '@deck.gl/mesh-layers';
52-
import {OBJLoader} from '@deck.gl/obj';
52+
import {OBJLoader} from '@loaders.gl/obj';
5353

5454
type BartStation = {
5555
name: string;
@@ -90,7 +90,7 @@ new Deck({
9090
import React from 'react';
9191
import {DeckGL} from '@deck.gl/react';
9292
import {SimpleMeshLayer} from '@deck.gl/mesh-layers';
93-
import {OBJLoader} from '@deck.gl/obj';
93+
import {OBJLoader} from '@loaders.gl/obj';
9494
import type {PickingInfo} from '@deck.gl/core';
9595

9696
type BartStation = {

docs/upgrade-guide.md

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,122 @@ The following issues are known and can be expected to resolve in a 9.0 patch:
7272

7373
### Typescript
7474

75-
Typescript is now enabled on all modules. The `'@deck.gl/xxx/typed'` packages are removed.
75+
Typescript is now enabled on all modules. The `'@deck.gl/xxx/typed'` packages are removed.
76+
77+
```ts
78+
// deck.gl v9
79+
import {Deck} from '@deck.gl/core'
80+
81+
// deck.gl v8
82+
import {Deck} from '@deck.gl/core/typed'
83+
```
7684

7785
### luma.gl v9 Updates
7886

7987
The biggest changes in deck.gl v9 are due to the upgrade to the luma.gl v9 API. Fortunately, deck.gl encapsulates most of the luma.gl API so the changes to deck.gl applications should be limited, in particular if the application does not directly interact with GPU resources.
8088

89+
For more information read the [luma v9 porting guide](https://luma.gl/docs/legacy/porting-guide)
90+
8191
Quick summary:
8292

8393
- `DeckProps.gl (WebGLRenderingContext)` should be replaced with `device`: [Device](https://luma.gl/docs/api-reference/core/device).
84-
- `DeckProps.glOptions (WebGLContextAttributes)` should be replaced with `DeckProps.deviceProps.webgl`: `deviceProps: {type: 'webgl', webgl: ...glOptions}`: [WebGLDeviceProps](https://luma.gl/docs/api-reference/webgl/#webgldeviceprops)
94+
95+
```ts
96+
// deck.gl v9
97+
import {Deck} from '@deck.gl/core'
98+
import {luma} from '@luma.gl/core'
99+
import {webgl2Adapter}'@luma.gl/webgl'
100+
101+
new Deck({
102+
device: await luma.createDevice({adapters: [webgl2Adapter]})
103+
});
104+
105+
// deck.gl v8
106+
import {Deck} from '@deck.gl/core/typed'
107+
108+
const canvas = document.getElementById('myCanvas');
109+
110+
new Deck({
111+
gl: canvas.getContext('webgl2')
112+
});
113+
```
114+
115+
- `DeckProps.glOptions (WebGLContextAttributes)` should be replaced with `DeckProps.deviceProps.webgl`: [WebGLContextAttributes](https://luma.gl/docs/api-reference/core/device#webglcontextattributes)
85116
- `DeckProps.glOptions.preserveDrawingBuffers` is now set by default, and does not need to be overridden.
117+
- `DeckProps.glOptions.powerPreference` is now set to `'high-performance'` by default, and does not need to be overridden.
86118
- `DeckProps.onWebGLInitialized` callback is now `DeckProps.onDeviceInitialized`.
87-
- `LayerProps.parameters` and `LayerProps.textureParameters` no longer use WebGL constants, but instead use (WebGPU style) [string constants](https://luma.gl/docs/api-reference/core/parameters/).
119+
120+
```ts
121+
// deck.gl v9
122+
import {Deck} from '@deck.gl/core'
123+
124+
new Deck({
125+
deviceProps: {
126+
type: 'webgl',
127+
// powerPreference: 'high-performance' is now set by default
128+
webgl: {
129+
stencil: true
130+
// preserveDrawingBuffers: true is now set by default
131+
}
132+
},
133+
onDeviceInitialized: (device) => {
134+
const gl = device.handle // WebGL2RenderingContext when using a webgl device
135+
}
136+
});
137+
138+
// deck.gl v8
139+
import {Deck} from '@deck.gl/core/typed'
140+
141+
new Deck({
142+
glOptions: {
143+
stencil: true,
144+
preserveDrawingBuffers: true,
145+
powerPreference: 'high-performance'
146+
},
147+
onWebGLInitialized: (gl) => {}
148+
});
149+
```
150+
151+
- `DeckProps.parameters`, `LayerProps.parameters`, and `LayerProps.textureParameters` no longer use WebGL constants, but instead use (WebGPU style) [string constants](https://luma.gl/docs/api-reference/core/parameters/).
152+
153+
```ts
154+
// deck.gl v9 using string constants
155+
import {Deck} from '@deck.gl/core'
156+
new Deck({
157+
parameters: {
158+
blendColorOperation: 'add',
159+
blendColorSrcFactor: 'src-alpha',
160+
blendColorDstFactor: 'one',
161+
blendAlphaOperation: 'add',
162+
blendAlphaSrcFactor: 'one-minus-dst-alpha',
163+
blendAlphaDstFactor: 'one'
164+
}
165+
})
166+
167+
// deck.gl v9 using GL constants
168+
// The constant module remains but is now considered an internal luma.gl module, and is no longer intended to be imported by applications.
169+
import {Deck} from '@deck.gl/core'
170+
import {GL} from '@luma.gl/constants' // Note the ESM import
171+
172+
new Deck({
173+
parameters: {
174+
blendEquation: [GL.ADD, GL.ADD],
175+
blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],
176+
}
177+
})
178+
179+
// deck.gl v8
180+
import {Deck} from '@deck.gl/core/typed'
181+
import GL from '@luma.gl/constants';
182+
183+
new Deck({
184+
parameters: {
185+
blendEquation: [GL.ADD, GL.ADD],
186+
blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],
187+
}
188+
})
189+
```
190+
88191
- When providing [binary data attributes](./api-reference/core/layer.md#data), `type` is now a WebGPU-style [string format](https://luma.gl/docs/api-guide/gpu/gpu-attributes#vertexformat) instead of a GL constant.
89192
- GPU resources should no longer be created by directly instantiating classes. For example, instead of `new Buffer(gl)` use `device.createBuffer()`, instead of `new Texture()` use `device.createTexture()`. See [Device methods](https://luma.gl/docs/api-reference/core/device#methods).
90193

0 commit comments

Comments
 (0)