@@ -612,10 +612,19 @@ function vtkOpenGLTexture(publicAPI, model) {
612
612
}
613
613
} ;
614
614
615
- //----------------------------------------------------------------------------
616
- function updateArrayDataType ( dataType , data , depth = false ) {
615
+ /**
616
+ * Updates the data array to match the required data type for OpenGL.
617
+ *
618
+ * This function takes the input data and converts it to the appropriate
619
+ * format required by the OpenGL texture, based on the specified data type.
620
+ *
621
+ * @param {string } dataType - The original data type of the input data.
622
+ * @param {Array } data - The input data array that needs to be updated.
623
+ * @param {boolean } [depth=false] - Indicates whether the data is a 3D array.
624
+ * @returns {Array } The updated data array that matches the OpenGL data type.
625
+ */
626
+ publicAPI . updateArrayDataTypeForGL = ( dataType , data , depth = false ) => {
617
627
const pixData = [ ] ;
618
-
619
628
let pixCount = model . width * model . height * model . components ;
620
629
if ( depth ) {
621
630
pixCount *= model . depth ;
@@ -693,7 +702,7 @@ function vtkOpenGLTexture(publicAPI, model) {
693
702
}
694
703
695
704
return pixData ;
696
- }
705
+ } ;
697
706
698
707
//----------------------------------------------------------------------------
699
708
function scaleTextureToHighestPowerOfTwo ( data ) {
@@ -856,7 +865,7 @@ function vtkOpenGLTexture(publicAPI, model) {
856
865
857
866
// Create an array of texture with one texture
858
867
const dataArray = [ data ] ;
859
- const pixData = updateArrayDataType ( dataType , dataArray ) ;
868
+ const pixData = publicAPI . updateArrayDataTypeForGL ( dataType , dataArray ) ;
860
869
const scaledData = scaleTextureToHighestPowerOfTwo ( pixData ) ;
861
870
862
871
// Source texture data from the PBO.
@@ -944,7 +953,7 @@ function vtkOpenGLTexture(publicAPI, model) {
944
953
publicAPI . createTexture ( ) ;
945
954
publicAPI . bind ( ) ;
946
955
947
- const pixData = updateArrayDataType ( dataType , data ) ;
956
+ const pixData = publicAPI . updateArrayDataTypeForGL ( dataType , data ) ;
948
957
const scaledData = scaleTextureToHighestPowerOfTwo ( pixData ) ;
949
958
950
959
// invert the data because opengl is messed up with cube maps
@@ -1364,7 +1373,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1364
1373
publicAPI . create2DFromRaw ( width , height , numComps , dataType , data ) ;
1365
1374
} ;
1366
1375
1367
- publicAPI . updateVolumeScaleForOpenGL = ( dataType , numComps ) => {
1376
+ publicAPI . updateVolumeInfoForGL = ( dataType , numComps ) => {
1368
1377
let isScalingApplied = false ;
1369
1378
1370
1379
// Initialize volume info if it doesn't exist
@@ -1438,7 +1447,10 @@ function vtkOpenGLTexture(publicAPI, model) {
1438
1447
let dataTypeToUse = dataType ;
1439
1448
let dataToUse = data ;
1440
1449
1441
- if ( ! publicAPI . updateVolumeScaleForOpenGL ( dataTypeToUse , numComps ) ) {
1450
+ if (
1451
+ ! publicAPI . updateVolumeInfoForGL ( dataTypeToUse , numComps ) &&
1452
+ dataToUse
1453
+ ) {
1442
1454
const numPixelsIn = width * height * depth ;
1443
1455
const scaleOffsetsCopy = structuredClone ( model . volumeInfo ) ;
1444
1456
// otherwise convert to float
@@ -1484,7 +1496,11 @@ function vtkOpenGLTexture(publicAPI, model) {
1484
1496
// Create an array of texture with one texture
1485
1497
const dataArray = [ dataToUse ] ;
1486
1498
const is3DArray = true ;
1487
- const pixData = updateArrayDataType ( dataTypeToUse , dataArray , is3DArray ) ;
1499
+ const pixData = publicAPI . updateArrayDataTypeForGL (
1500
+ dataTypeToUse ,
1501
+ dataArray ,
1502
+ is3DArray
1503
+ ) ;
1488
1504
const scaledData = scaleTextureToHighestPowerOfTwo ( pixData ) ;
1489
1505
1490
1506
// Source texture data from the PBO.
0 commit comments