Skip to content

Commit 74b3a79

Browse files
authored
Merge pull request #3224 from Kitware/opengltexture-named-parameters
refactor(OpenGL/Texture): use named parameters
2 parents 24a81a9 + ab63d35 commit 74b3a79

File tree

13 files changed

+463
-375
lines changed

13 files changed

+463
-375
lines changed

BREAKING_CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## From 32.x to 33
22

33
- **vtkMapper**: many properties have moved to `vtkVolumeProperty`. The full list of changed methods is: `getAnisotropy`, `getComputeNormalFromOpacity`, `getFilterMode`, `getFilterModeAsString`, `getGlobalIlluminationReach`, `getIpScalarRange`, `getIpScalarRangeByReference`, `getLAOKernelRadius`, `getLAOKernelSize`, `getLocalAmbientOcclusion`, `getPreferSizeOverAccuracy`, `getVolumetricScatteringBlending`, `setAnisotropy`, `setAverageIPScalarRange`, `setComputeNormalFromOpacity`, `setFilterMode`, `setFilterModeToNormalized`, `setFilterModeToOff`, `setFilterModeToRaw`, `setGlobalIlluminationReach`, `setIpScalarRange`, `setIpScalarRangeFrom`, `setLAOKernelRadius`, `setLAOKernelSize`, `setLocalAmbientOcclusion`, `setPreferSizeOverAccuracy`, `setVolumetricScatteringBlending`.
4+
- **vtkOpenGLTexture**: The public `create2D*` and `create3D*` methods used to have positional parameters. These methods now use named parameters via passing in an object record.
5+
46
## From 31.x to 32
57

68
- **vtkMapper**: remove `mapScalarsToTexture` from the public API. The function becomes protected and its API changes. This shouldn't cause any issue in most cases.

Sources/Rendering/OpenGL/Framebuffer/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,13 @@ function vtkFramebuffer(publicAPI, model) {
244244
texture.setOpenGLRenderWindow(model._openGLRenderWindow);
245245
texture.setMinificationFilter(Filter.LINEAR);
246246
texture.setMagnificationFilter(Filter.LINEAR);
247-
texture.create2DFromRaw(
248-
model.glFramebuffer.width,
249-
model.glFramebuffer.height,
250-
4,
251-
VtkDataTypes.UNSIGNED_CHAR,
252-
null
253-
);
247+
texture.create2DFromRaw({
248+
width: model.glFramebuffer.width,
249+
height: model.glFramebuffer.height,
250+
numComps: 4,
251+
dataType: VtkDataTypes.UNSIGNED_CHAR,
252+
data: null,
253+
});
254254
publicAPI.setColorBuffer(texture);
255255

256256
// for now do not count on having a depth buffer texture

Sources/Rendering/OpenGL/ImageCPRMapper/index.js

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
213213
model.context.getExtension('EXT_texture_norm16')
214214
);
215215
model.volumeTexture.resetFormatAndType();
216-
model.volumeTexture.create3DFilterableFromDataArray(
217-
dims[0],
218-
dims[1],
219-
dims[2],
220-
scalars,
221-
model.renderable.getPreferSizeOverAccuracy()
222-
);
216+
model.volumeTexture.create3DFilterableFromDataArray({
217+
width: dims[0],
218+
height: dims[1],
219+
depth: dims[2],
220+
dataArray: scalars,
221+
preferSizeOverAccuracy: model.renderable.getPreferSizeOverAccuracy(),
222+
});
223223
model._openGLRenderWindow.setGraphicsResourceForObject(
224224
scalars,
225225
model.volumeTexture,
@@ -246,14 +246,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
246246
property.setUpdatedExtents([]);
247247

248248
const dims = image.getDimensions();
249-
model.volumeTexture.create3DFilterableFromDataArray(
250-
dims[0],
251-
dims[1],
252-
dims[2],
253-
scalars,
254-
false,
255-
updatedExtents
256-
);
249+
model.volumeTexture.create3DFilterableFromDataArray({
250+
width: dims[0],
251+
height: dims[1],
252+
depth: dims[2],
253+
dataArray: scalars,
254+
updatedExtents,
255+
});
257256
}
258257

259258
// Rebuild the color texture if needed
@@ -309,27 +308,27 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
309308
}
310309
}
311310
model.colorTexture.resetFormatAndType();
312-
model.colorTexture.create2DFromRaw(
313-
cWidth,
314-
textureHeight,
315-
3,
316-
VtkDataTypes.UNSIGNED_CHAR,
317-
cTable
318-
);
311+
model.colorTexture.create2DFromRaw({
312+
width: cWidth,
313+
height: textureHeight,
314+
numComps: 3,
315+
dataType: VtkDataTypes.UNSIGNED_CHAR,
316+
data: cTable,
317+
});
319318
} else {
320319
for (let i = 0; i < cWidth * 3; ++i) {
321320
cTable[i] = (255.0 * i) / ((cWidth - 1) * 3);
322321
cTable[i + 1] = (255.0 * i) / ((cWidth - 1) * 3);
323322
cTable[i + 2] = (255.0 * i) / ((cWidth - 1) * 3);
324323
}
325324
model.colorTexture.resetFormatAndType();
326-
model.colorTexture.create2DFromRaw(
327-
cWidth,
328-
1,
329-
3,
330-
VtkDataTypes.UNSIGNED_CHAR,
331-
cTable
332-
);
325+
model.colorTexture.create2DFromRaw({
326+
width: cWidth,
327+
height: 1,
328+
numComps: 3,
329+
dataType: VtkDataTypes.UNSIGNED_CHAR,
330+
data: cTable,
331+
});
333332
}
334333

335334
if (firstColorTransferFunc) {
@@ -407,24 +406,24 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
407406
}
408407
}
409408
model.pwfTexture.resetFormatAndType();
410-
model.pwfTexture.create2DFromRaw(
411-
pwfWidth,
412-
textureHeight,
413-
1,
414-
VtkDataTypes.FLOAT,
415-
pwfFloatTable
416-
);
409+
model.pwfTexture.create2DFromRaw({
410+
width: pwfWidth,
411+
height: textureHeight,
412+
numComps: 1,
413+
dataType: VtkDataTypes.FLOAT,
414+
data: pwfFloatTable,
415+
});
417416
} else {
418417
// default is opaque
419418
pwfTable.fill(255.0);
420419
model.pwfTexture.resetFormatAndType();
421-
model.pwfTexture.create2DFromRaw(
422-
pwfWidth,
423-
1,
424-
1,
425-
VtkDataTypes.UNSIGNED_CHAR,
426-
pwfTable
427-
);
420+
model.pwfTexture.create2DFromRaw({
421+
width: pwfWidth,
422+
height: 1,
423+
numComps: 1,
424+
dataType: VtkDataTypes.UNSIGNED_CHAR,
425+
data: pwfTable,
426+
});
428427
}
429428
if (firstPwFunc) {
430429
model._openGLRenderWindow.setGraphicsResourceForObject(

Sources/Rendering/OpenGL/ImageMapper/index.js

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,26 +1001,26 @@ function vtkOpenGLImageMapper(publicAPI, model) {
10011001
}
10021002
}
10031003
model.colorTexture.resetFormatAndType();
1004-
model.colorTexture.create2DFromRaw(
1005-
cWidth,
1006-
textureHeight,
1007-
3,
1008-
VtkDataTypes.UNSIGNED_CHAR,
1009-
cTable
1010-
);
1004+
model.colorTexture.create2DFromRaw({
1005+
width: cWidth,
1006+
height: textureHeight,
1007+
numComps: 3,
1008+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1009+
data: cTable,
1010+
});
10111011
} else {
10121012
for (let i = 0; i < cWidth * 3; ++i) {
10131013
cTable[i] = (255.0 * i) / ((cWidth - 1) * 3);
10141014
cTable[i + 1] = (255.0 * i) / ((cWidth - 1) * 3);
10151015
cTable[i + 2] = (255.0 * i) / ((cWidth - 1) * 3);
10161016
}
1017-
model.colorTexture.create2DFromRaw(
1018-
cWidth,
1019-
1,
1020-
3,
1021-
VtkDataTypes.UNSIGNED_CHAR,
1022-
cTable
1023-
);
1017+
model.colorTexture.create2DFromRaw({
1018+
width: cWidth,
1019+
height: 1,
1020+
numComps: 3,
1021+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1022+
data: cTable,
1023+
});
10241024
}
10251025

10261026
if (firstColorTransferFunc) {
@@ -1109,23 +1109,23 @@ function vtkOpenGLImageMapper(publicAPI, model) {
11091109
}
11101110
}
11111111
model.pwfTexture.resetFormatAndType();
1112-
model.pwfTexture.create2DFromRaw(
1113-
pwfWidth,
1114-
textureHeight,
1115-
1,
1116-
VtkDataTypes.FLOAT,
1117-
pwfFloatTable
1118-
);
1112+
model.pwfTexture.create2DFromRaw({
1113+
width: pwfWidth,
1114+
height: textureHeight,
1115+
numComps: 1,
1116+
dataType: VtkDataTypes.FLOAT,
1117+
data: pwfFloatTable,
1118+
});
11191119
} else {
11201120
// default is opaque
11211121
pwfTable.fill(255.0);
1122-
model.pwfTexture.create2DFromRaw(
1123-
pwfWidth,
1124-
1,
1125-
1,
1126-
VtkDataTypes.UNSIGNED_CHAR,
1127-
pwfTable
1128-
);
1122+
model.pwfTexture.create2DFromRaw({
1123+
width: pwfWidth,
1124+
height: 1,
1125+
numComps: 1,
1126+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1127+
data: pwfTable,
1128+
});
11291129
}
11301130

11311131
if (firstPwFunc) {
@@ -1344,15 +1344,16 @@ function vtkOpenGLImageMapper(publicAPI, model) {
13441344
// Don't share this resource as `scalars` is created in this function
13451345
// so it is impossible to share
13461346
model.openGLTexture.resetFormatAndType();
1347-
model.openGLTexture.create2DFilterableFromRaw(
1348-
dims[0],
1349-
dims[1],
1350-
numComp,
1351-
imgScalars.getDataType(),
1352-
scalars,
1353-
model.renderable.getPreferSizeOverAccuracy?.(),
1354-
ranges
1355-
);
1347+
model.openGLTexture.create2DFilterableFromRaw({
1348+
width: dims[0],
1349+
height: dims[1],
1350+
numComps: numComp,
1351+
dataType: imgScalars.getDataType(),
1352+
data: scalars,
1353+
preferSizeOverAccuracy:
1354+
!!model.renderable.getPreferSizeOverAccuracy?.(),
1355+
ranges,
1356+
});
13561357
model.openGLTexture.activate();
13571358
model.openGLTexture.sendParameters();
13581359
model.openGLTexture.deactivate();
@@ -1439,13 +1440,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
14391440
model.labelOutlineThicknessTexture.setMagnificationFilter(Filter.NEAREST);
14401441

14411442
// Create a 2D texture (acting as 1D) from the raw data
1442-
model.labelOutlineThicknessTexture.create2DFromRaw(
1443-
lWidth,
1444-
lHeight,
1445-
1,
1446-
VtkDataTypes.UNSIGNED_CHAR,
1447-
lTable
1448-
);
1443+
model.labelOutlineThicknessTexture.create2DFromRaw({
1444+
width: lWidth,
1445+
height: lHeight,
1446+
numComps: 1,
1447+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1448+
data: lTable,
1449+
});
14491450

14501451
if (labelOutlineThicknessArray) {
14511452
model._openGLRenderWindow.setGraphicsResourceForObject(

0 commit comments

Comments
 (0)