Skip to content

Commit 039ad0a

Browse files
committed
refactor(OpenGL/Texture): use named parameters
The create* methods have enough parameters to warrant using named parameters. BREAKING CHANGE: the create* methods now use named parameters rather than positional parameters.
1 parent d15d50f commit 039ad0a

File tree

12 files changed

+462
-382
lines changed

12 files changed

+462
-382
lines changed

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
@@ -212,13 +212,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
212212
model.context.getExtension('EXT_texture_norm16')
213213
);
214214
model.volumeTexture.resetFormatAndType();
215-
model.volumeTexture.create3DFilterableFromDataArray(
216-
dims[0],
217-
dims[1],
218-
dims[2],
219-
scalars,
220-
model.renderable.getPreferSizeOverAccuracy()
221-
);
215+
model.volumeTexture.create3DFilterableFromDataArray({
216+
width: dims[0],
217+
height: dims[1],
218+
depth: dims[2],
219+
dataArray: scalars,
220+
preferSizeOverAccuracy: model.renderable.getPreferSizeOverAccuracy(),
221+
});
222222
model._openGLRenderWindow.setGraphicsResourceForObject(
223223
scalars,
224224
model.volumeTexture,
@@ -245,14 +245,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
245245
model.renderable.setUpdatedExtents([]);
246246

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

258257
// Rebuild the color texture if needed
@@ -302,27 +301,27 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
302301
}
303302
}
304303
model.colorTexture.resetFormatAndType();
305-
model.colorTexture.create2DFromRaw(
306-
cWidth,
307-
textureHeight,
308-
3,
309-
VtkDataTypes.UNSIGNED_CHAR,
310-
cTable
311-
);
304+
model.colorTexture.create2DFromRaw({
305+
width: cWidth,
306+
height: textureHeight,
307+
numComps: 3,
308+
dataType: VtkDataTypes.UNSIGNED_CHAR,
309+
data: cTable,
310+
});
312311
} else {
313312
for (let i = 0; i < cWidth * 3; ++i) {
314313
cTable[i] = (255.0 * i) / ((cWidth - 1) * 3);
315314
cTable[i + 1] = (255.0 * i) / ((cWidth - 1) * 3);
316315
cTable[i + 2] = (255.0 * i) / ((cWidth - 1) * 3);
317316
}
318317
model.colorTexture.resetFormatAndType();
319-
model.colorTexture.create2DFromRaw(
320-
cWidth,
321-
1,
322-
3,
323-
VtkDataTypes.UNSIGNED_CHAR,
324-
cTable
325-
);
318+
model.colorTexture.create2DFromRaw({
319+
width: cWidth,
320+
height: 1,
321+
numComps: 3,
322+
dataType: VtkDataTypes.UNSIGNED_CHAR,
323+
data: cTable,
324+
});
326325
}
327326

328327
if (colorTransferFunc) {
@@ -392,24 +391,24 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
392391
}
393392
}
394393
model.pwfTexture.resetFormatAndType();
395-
model.pwfTexture.create2DFromRaw(
396-
pwfWidth,
397-
textureHeight,
398-
1,
399-
VtkDataTypes.FLOAT,
400-
pwfFloatTable
401-
);
394+
model.pwfTexture.create2DFromRaw({
395+
width: pwfWidth,
396+
height: textureHeight,
397+
numComps: 1,
398+
dataType: VtkDataTypes.FLOAT,
399+
data: pwfFloatTable,
400+
});
402401
} else {
403402
// default is opaque
404403
pwfTable.fill(255.0);
405404
model.pwfTexture.resetFormatAndType();
406-
model.pwfTexture.create2DFromRaw(
407-
pwfWidth,
408-
1,
409-
1,
410-
VtkDataTypes.UNSIGNED_CHAR,
411-
pwfTable
412-
);
405+
model.pwfTexture.create2DFromRaw({
406+
width: pwfWidth,
407+
height: 1,
408+
numComps: 1,
409+
dataType: VtkDataTypes.UNSIGNED_CHAR,
410+
data: pwfTable,
411+
});
413412
}
414413
if (pwFunc) {
415414
model._openGLRenderWindow.setGraphicsResourceForObject(

Sources/Rendering/OpenGL/ImageMapper/index.js

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,26 +1003,26 @@ function vtkOpenGLImageMapper(publicAPI, model) {
10031003
}
10041004
}
10051005
model.colorTexture.resetFormatAndType();
1006-
model.colorTexture.create2DFromRaw(
1007-
cWidth,
1008-
textureHeight,
1009-
3,
1010-
VtkDataTypes.UNSIGNED_CHAR,
1011-
cTable
1012-
);
1006+
model.colorTexture.create2DFromRaw({
1007+
width: cWidth,
1008+
height: textureHeight,
1009+
numComps: 3,
1010+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1011+
data: cTable,
1012+
});
10131013
} else {
10141014
for (let i = 0; i < cWidth * 3; ++i) {
10151015
cTable[i] = (255.0 * i) / ((cWidth - 1) * 3);
10161016
cTable[i + 1] = (255.0 * i) / ((cWidth - 1) * 3);
10171017
cTable[i + 2] = (255.0 * i) / ((cWidth - 1) * 3);
10181018
}
1019-
model.colorTexture.create2DFromRaw(
1020-
cWidth,
1021-
1,
1022-
3,
1023-
VtkDataTypes.UNSIGNED_CHAR,
1024-
cTable
1025-
);
1019+
model.colorTexture.create2DFromRaw({
1020+
width: cWidth,
1021+
height: 1,
1022+
numComps: 3,
1023+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1024+
data: cTable,
1025+
});
10261026
}
10271027

10281028
if (colorTransferFunc) {
@@ -1103,23 +1103,23 @@ function vtkOpenGLImageMapper(publicAPI, model) {
11031103
}
11041104
}
11051105
model.pwfTexture.resetFormatAndType();
1106-
model.pwfTexture.create2DFromRaw(
1107-
pwfWidth,
1108-
textureHeight,
1109-
1,
1110-
VtkDataTypes.FLOAT,
1111-
pwfFloatTable
1112-
);
1106+
model.pwfTexture.create2DFromRaw({
1107+
width: pwfWidth,
1108+
height: textureHeight,
1109+
numComps: 1,
1110+
dataType: VtkDataTypes.FLOAT,
1111+
data: pwfFloatTable,
1112+
});
11131113
} else {
11141114
// default is opaque
11151115
pwfTable.fill(255.0);
1116-
model.pwfTexture.create2DFromRaw(
1117-
pwfWidth,
1118-
1,
1119-
1,
1120-
VtkDataTypes.UNSIGNED_CHAR,
1121-
pwfTable
1122-
);
1116+
model.pwfTexture.create2DFromRaw({
1117+
width: pwfWidth,
1118+
height: 1,
1119+
numComps: 1,
1120+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1121+
data: pwfTable,
1122+
});
11231123
}
11241124

11251125
if (pwFunc) {
@@ -1338,15 +1338,16 @@ function vtkOpenGLImageMapper(publicAPI, model) {
13381338
// Don't share this resource as `scalars` is created in this function
13391339
// so it is impossible to share
13401340
model.openGLTexture.resetFormatAndType();
1341-
model.openGLTexture.create2DFilterableFromRaw(
1342-
dims[0],
1343-
dims[1],
1344-
numComp,
1345-
imgScalars.getDataType(),
1346-
scalars,
1347-
model.renderable.getPreferSizeOverAccuracy?.(),
1348-
ranges
1349-
);
1341+
model.openGLTexture.create2DFilterableFromRaw({
1342+
width: dims[0],
1343+
height: dims[1],
1344+
numComps: numComp,
1345+
dataType: imgScalars.getDataType(),
1346+
data: scalars,
1347+
preferSizeOverAccuracy:
1348+
!!model.renderable.getPreferSizeOverAccuracy?.(),
1349+
ranges,
1350+
});
13501351
model.openGLTexture.activate();
13511352
model.openGLTexture.sendParameters();
13521353
model.openGLTexture.deactivate();
@@ -1433,13 +1434,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
14331434
model.labelOutlineThicknessTexture.setMagnificationFilter(Filter.NEAREST);
14341435

14351436
// Create a 2D texture (acting as 1D) from the raw data
1436-
model.labelOutlineThicknessTexture.create2DFromRaw(
1437-
lWidth,
1438-
lHeight,
1439-
1,
1440-
VtkDataTypes.UNSIGNED_CHAR,
1441-
lTable
1442-
);
1437+
model.labelOutlineThicknessTexture.create2DFromRaw({
1438+
width: lWidth,
1439+
height: lHeight,
1440+
numComps: 1,
1441+
dataType: VtkDataTypes.UNSIGNED_CHAR,
1442+
data: lTable,
1443+
});
14431444

14441445
if (labelOutlineThicknessArray) {
14451446
model._openGLRenderWindow.setGraphicsResourceForObject(

0 commit comments

Comments
 (0)