twgl.js 6.2.0 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/{6.x → 7.x}/twgl-full.d.ts +20 -13
- package/dist/{6.x → 7.x}/twgl-full.js +692 -389
- package/dist/{6.x → 7.x}/twgl-full.module.js +256 -161
- package/dist/{6.x → 7.x}/twgl.d.ts +15 -6
- package/dist/{6.x → 7.x}/twgl.js +681 -376
- package/package.json +9 -9
package/dist/{6.x → 7.x}/twgl.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @license twgl.js
|
|
2
|
+
* @license twgl.js 7.0.3 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
|
|
3
3
|
* Available via the MIT license.
|
|
4
4
|
* see: http://github.com/greggman/twgl.js for details
|
|
5
5
|
*/
|
|
@@ -1093,6 +1093,8 @@ renderbufferFormats[RGB5_A1] = true;
|
|
|
1093
1093
|
renderbufferFormats[RGB565] = true;
|
|
1094
1094
|
renderbufferFormats[DEPTH_STENCIL] = true;
|
|
1095
1095
|
renderbufferFormats[DEPTH_COMPONENT16] = true;
|
|
1096
|
+
renderbufferFormats[DEPTH_COMPONENT24] = true;
|
|
1097
|
+
renderbufferFormats[DEPTH_COMPONENT32F] = true;
|
|
1096
1098
|
renderbufferFormats[STENCIL_INDEX] = true;
|
|
1097
1099
|
renderbufferFormats[STENCIL_INDEX8] = true;
|
|
1098
1100
|
function isRenderbufferFormat(format) {
|
|
@@ -4177,6 +4179,7 @@ var CLAMP_TO_EDGE = 0x812f;
|
|
|
4177
4179
|
/* TextureMagFilter */
|
|
4178
4180
|
var NEAREST = 0x2600;
|
|
4179
4181
|
var LINEAR = 0x2601;
|
|
4182
|
+
var NEAREST_MIPMAP_LINEAR = 0x2702;
|
|
4180
4183
|
|
|
4181
4184
|
/* TextureMinFilter */
|
|
4182
4185
|
// const NEAREST_MIPMAP_NEAREST = 0x2700;
|
|
@@ -4420,6 +4423,14 @@ var formatInfo = {};
|
|
|
4420
4423
|
};
|
|
4421
4424
|
}
|
|
4422
4425
|
|
|
4426
|
+
/**
|
|
4427
|
+
* @typedef {Object} BlockInfo
|
|
4428
|
+
* @property {number} bytes number of bytes in the block
|
|
4429
|
+
* @property {number} width width of the block
|
|
4430
|
+
* @property {number} height height of the block
|
|
4431
|
+
* @private
|
|
4432
|
+
*/
|
|
4433
|
+
|
|
4423
4434
|
/**
|
|
4424
4435
|
* @typedef {Object} TextureFormatDetails
|
|
4425
4436
|
* @property {number} textureFormat format to pass texImage2D and similar functions.
|
|
@@ -4427,7 +4438,7 @@ var formatInfo = {};
|
|
|
4427
4438
|
* @property {boolean} textureFilterable true if you can filter the texture, false if you can ony use `NEAREST`.
|
|
4428
4439
|
* @property {number[]} type Array of possible types you can pass to texImage2D and similar function
|
|
4429
4440
|
* @property {Object.<number,number>} [bytesPerElementMap] A map of types to bytes per element
|
|
4430
|
-
* @property {
|
|
4441
|
+
* @property {BlockInfo} [block] block size, only for compressed textures
|
|
4431
4442
|
* @private
|
|
4432
4443
|
*/
|
|
4433
4444
|
|
|
@@ -4868,321 +4879,514 @@ function getTextureInternalFormatInfo(internalFormat) {
|
|
|
4868
4879
|
info.bytesPerElementMap[type] = bytesPerElement;
|
|
4869
4880
|
});
|
|
4870
4881
|
});
|
|
4871
|
-
var
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
t[COMPRESSED_RGBA_ASTC_6x5_KHR] = {
|
|
5010
|
-
textureFormat: COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
5011
|
-
colorRenderable: false,
|
|
5012
|
-
textureFilterable: true
|
|
5013
|
-
};
|
|
5014
|
-
t[COMPRESSED_RGBA_ASTC_6x6_KHR] = {
|
|
5015
|
-
textureFormat: COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
5016
|
-
colorRenderable: false,
|
|
5017
|
-
textureFilterable: true
|
|
5018
|
-
};
|
|
5019
|
-
t[COMPRESSED_RGBA_ASTC_8x5_KHR] = {
|
|
5020
|
-
textureFormat: COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
5021
|
-
colorRenderable: false,
|
|
5022
|
-
textureFilterable: true
|
|
5023
|
-
};
|
|
5024
|
-
t[COMPRESSED_RGBA_ASTC_8x6_KHR] = {
|
|
5025
|
-
textureFormat: COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
5026
|
-
colorRenderable: false,
|
|
5027
|
-
textureFilterable: true
|
|
5028
|
-
};
|
|
5029
|
-
t[COMPRESSED_RGBA_ASTC_8x8_KHR] = {
|
|
5030
|
-
textureFormat: COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
5031
|
-
colorRenderable: false,
|
|
5032
|
-
textureFilterable: true
|
|
5033
|
-
};
|
|
5034
|
-
t[COMPRESSED_RGBA_ASTC_10x5_KHR] = {
|
|
5035
|
-
textureFormat: COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
5036
|
-
colorRenderable: false,
|
|
5037
|
-
textureFilterable: true
|
|
5038
|
-
};
|
|
5039
|
-
t[COMPRESSED_RGBA_ASTC_10x6_KHR] = {
|
|
5040
|
-
textureFormat: COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
5041
|
-
colorRenderable: false,
|
|
5042
|
-
textureFilterable: true
|
|
5043
|
-
};
|
|
5044
|
-
t[COMPRESSED_RGBA_ASTC_10x8_KHR] = {
|
|
5045
|
-
textureFormat: COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
5046
|
-
colorRenderable: false,
|
|
5047
|
-
textureFilterable: true
|
|
5048
|
-
};
|
|
5049
|
-
t[COMPRESSED_RGBA_ASTC_10x10_KHR] = {
|
|
5050
|
-
textureFormat: COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
5051
|
-
colorRenderable: false,
|
|
5052
|
-
textureFilterable: true
|
|
5053
|
-
};
|
|
5054
|
-
t[COMPRESSED_RGBA_ASTC_12x10_KHR] = {
|
|
5055
|
-
textureFormat: COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
5056
|
-
colorRenderable: false,
|
|
5057
|
-
textureFilterable: true
|
|
5058
|
-
};
|
|
5059
|
-
t[COMPRESSED_RGBA_ASTC_12x12_KHR] = {
|
|
5060
|
-
textureFormat: COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
5061
|
-
colorRenderable: false,
|
|
5062
|
-
textureFilterable: true
|
|
5063
|
-
};
|
|
5064
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR] = {
|
|
5065
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
5066
|
-
colorRenderable: false,
|
|
5067
|
-
textureFilterable: true
|
|
5068
|
-
};
|
|
5069
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR] = {
|
|
5070
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
5071
|
-
colorRenderable: false,
|
|
5072
|
-
textureFilterable: true
|
|
5073
|
-
};
|
|
5074
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR] = {
|
|
5075
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
5076
|
-
colorRenderable: false,
|
|
5077
|
-
textureFilterable: true
|
|
5078
|
-
};
|
|
5079
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR] = {
|
|
5080
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
5081
|
-
colorRenderable: false,
|
|
5082
|
-
textureFilterable: true
|
|
5083
|
-
};
|
|
5084
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR] = {
|
|
5085
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
5086
|
-
colorRenderable: false,
|
|
5087
|
-
textureFilterable: true
|
|
5088
|
-
};
|
|
5089
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR] = {
|
|
5090
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
5091
|
-
colorRenderable: false,
|
|
5092
|
-
textureFilterable: true
|
|
5093
|
-
};
|
|
5094
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR] = {
|
|
5095
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
5096
|
-
colorRenderable: false,
|
|
5097
|
-
textureFilterable: true
|
|
5098
|
-
};
|
|
5099
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR] = {
|
|
5100
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
5101
|
-
colorRenderable: false,
|
|
5102
|
-
textureFilterable: true
|
|
5103
|
-
};
|
|
5104
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR] = {
|
|
5105
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
5106
|
-
colorRenderable: false,
|
|
5107
|
-
textureFilterable: true
|
|
5108
|
-
};
|
|
5109
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR] = {
|
|
5110
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
5111
|
-
colorRenderable: false,
|
|
5112
|
-
textureFilterable: true
|
|
5113
|
-
};
|
|
5114
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR] = {
|
|
5115
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
5116
|
-
colorRenderable: false,
|
|
5117
|
-
textureFilterable: true
|
|
5118
|
-
};
|
|
5119
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR] = {
|
|
5120
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
5121
|
-
colorRenderable: false,
|
|
5122
|
-
textureFilterable: true
|
|
5123
|
-
};
|
|
5124
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR] = {
|
|
5125
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
5126
|
-
colorRenderable: false,
|
|
5127
|
-
textureFilterable: true
|
|
5128
|
-
};
|
|
5129
|
-
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR] = {
|
|
5130
|
-
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
5131
|
-
colorRenderable: false,
|
|
5132
|
-
textureFilterable: true
|
|
5133
|
-
};
|
|
5134
|
-
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_bptc.txt
|
|
5135
|
-
t[COMPRESSED_RGBA_BPTC_UNORM_EXT] = {
|
|
5136
|
-
textureFormat: COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
5137
|
-
colorRenderable: false,
|
|
5138
|
-
textureFilterable: true
|
|
5139
|
-
};
|
|
5140
|
-
t[COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT] = {
|
|
5141
|
-
textureFormat: COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
5142
|
-
colorRenderable: false,
|
|
5143
|
-
textureFilterable: true
|
|
5144
|
-
};
|
|
5145
|
-
t[COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT] = {
|
|
5146
|
-
textureFormat: COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
5147
|
-
colorRenderable: false,
|
|
5148
|
-
textureFilterable: true
|
|
5149
|
-
};
|
|
5150
|
-
t[COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT] = {
|
|
5151
|
-
textureFormat: COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
5152
|
-
colorRenderable: false,
|
|
5153
|
-
textureFilterable: true
|
|
5154
|
-
};
|
|
5155
|
-
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_rgtc.txt
|
|
5156
|
-
t[COMPRESSED_RED_RGTC1_EXT] = {
|
|
5157
|
-
textureFormat: COMPRESSED_RED_RGTC1_EXT,
|
|
5158
|
-
colorRenderable: false,
|
|
5159
|
-
textureFilterable: true
|
|
5160
|
-
};
|
|
5161
|
-
t[COMPRESSED_SIGNED_RED_RGTC1_EXT] = {
|
|
5162
|
-
textureFormat: COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
5163
|
-
colorRenderable: false,
|
|
5164
|
-
textureFilterable: true
|
|
5165
|
-
};
|
|
5166
|
-
t[COMPRESSED_RED_GREEN_RGTC2_EXT] = {
|
|
5167
|
-
textureFormat: COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
5168
|
-
colorRenderable: false,
|
|
5169
|
-
textureFilterable: true
|
|
5170
|
-
};
|
|
5171
|
-
t[COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT] = {
|
|
5172
|
-
textureFormat: COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
5173
|
-
colorRenderable: false,
|
|
5174
|
-
textureFilterable: true
|
|
5175
|
-
};
|
|
5176
|
-
for (var _i = 0, _Object$values = Object.values(t); _i < _Object$values.length; _i++) {
|
|
5177
|
-
var info = _Object$values[_i];
|
|
5178
|
-
info.compressed = true;
|
|
4882
|
+
var block8_4_4 = {
|
|
4883
|
+
bytes: 8,
|
|
4884
|
+
width: 4,
|
|
4885
|
+
height: 4
|
|
4886
|
+
};
|
|
4887
|
+
var block16_4_4 = {
|
|
4888
|
+
bytes: 16,
|
|
4889
|
+
width: 4,
|
|
4890
|
+
height: 4
|
|
4891
|
+
};
|
|
4892
|
+
|
|
4893
|
+
// compressed texture formats
|
|
4894
|
+
// s3tc:https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt
|
|
4895
|
+
t[COMPRESSED_RGB_S3TC_DXT1_EXT] = {
|
|
4896
|
+
textureFormat: COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
4897
|
+
colorRenderable: false,
|
|
4898
|
+
textureFilterable: true,
|
|
4899
|
+
block: block8_4_4
|
|
4900
|
+
};
|
|
4901
|
+
t[COMPRESSED_RGBA_S3TC_DXT1_EXT] = {
|
|
4902
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
4903
|
+
colorRenderable: false,
|
|
4904
|
+
textureFilterable: true,
|
|
4905
|
+
block: block8_4_4
|
|
4906
|
+
};
|
|
4907
|
+
t[COMPRESSED_RGBA_S3TC_DXT3_EXT] = {
|
|
4908
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
4909
|
+
colorRenderable: false,
|
|
4910
|
+
textureFilterable: true,
|
|
4911
|
+
block: block16_4_4
|
|
4912
|
+
};
|
|
4913
|
+
t[COMPRESSED_RGBA_S3TC_DXT5_EXT] = {
|
|
4914
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
4915
|
+
colorRenderable: false,
|
|
4916
|
+
textureFilterable: true,
|
|
4917
|
+
block: block16_4_4
|
|
4918
|
+
};
|
|
4919
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc_srgb.txt
|
|
4920
|
+
t[COMPRESSED_SRGB_S3TC_DXT1_EXT] = {
|
|
4921
|
+
textureFormat: COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
4922
|
+
colorRenderable: false,
|
|
4923
|
+
textureFilterable: true,
|
|
4924
|
+
block: block8_4_4
|
|
4925
|
+
};
|
|
4926
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = {
|
|
4927
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
4928
|
+
colorRenderable: false,
|
|
4929
|
+
textureFilterable: true,
|
|
4930
|
+
block: block8_4_4
|
|
4931
|
+
};
|
|
4932
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = {
|
|
4933
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
4934
|
+
colorRenderable: false,
|
|
4935
|
+
textureFilterable: true,
|
|
4936
|
+
block: block16_4_4
|
|
4937
|
+
};
|
|
4938
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = {
|
|
4939
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
4940
|
+
colorRenderable: false,
|
|
4941
|
+
textureFilterable: true,
|
|
4942
|
+
block: block16_4_4
|
|
4943
|
+
};
|
|
4944
|
+
// https://registry.khronos.org/OpenGL/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
|
|
4945
|
+
t[COMPRESSED_RGB_ETC1_WEBGL] = {
|
|
4946
|
+
textureFormat: COMPRESSED_RGB_ETC1_WEBGL,
|
|
4947
|
+
colorRenderable: false,
|
|
4948
|
+
textureFilterable: true,
|
|
4949
|
+
block: block8_4_4
|
|
4950
|
+
};
|
|
4951
|
+
t[COMPRESSED_R11_EAC] = {
|
|
4952
|
+
textureFormat: COMPRESSED_R11_EAC,
|
|
4953
|
+
colorRenderable: false,
|
|
4954
|
+
textureFilterable: true,
|
|
4955
|
+
block: block8_4_4
|
|
4956
|
+
};
|
|
4957
|
+
t[COMPRESSED_SIGNED_R11_EAC] = {
|
|
4958
|
+
textureFormat: COMPRESSED_SIGNED_R11_EAC,
|
|
4959
|
+
colorRenderable: false,
|
|
4960
|
+
textureFilterable: true,
|
|
4961
|
+
block: block8_4_4
|
|
4962
|
+
};
|
|
4963
|
+
t[COMPRESSED_RG11_EAC] = {
|
|
4964
|
+
textureFormat: COMPRESSED_RG11_EAC,
|
|
4965
|
+
colorRenderable: false,
|
|
4966
|
+
textureFilterable: true,
|
|
4967
|
+
block: block16_4_4
|
|
4968
|
+
};
|
|
4969
|
+
t[COMPRESSED_SIGNED_RG11_EAC] = {
|
|
4970
|
+
textureFormat: COMPRESSED_SIGNED_RG11_EAC,
|
|
4971
|
+
colorRenderable: false,
|
|
4972
|
+
textureFilterable: true,
|
|
4973
|
+
block: block16_4_4
|
|
4974
|
+
};
|
|
4975
|
+
t[COMPRESSED_RGB8_ETC2] = {
|
|
4976
|
+
textureFormat: COMPRESSED_RGB8_ETC2,
|
|
4977
|
+
colorRenderable: false,
|
|
4978
|
+
textureFilterable: true,
|
|
4979
|
+
block: block8_4_4
|
|
4980
|
+
};
|
|
4981
|
+
t[COMPRESSED_SRGB8_ETC2] = {
|
|
4982
|
+
textureFormat: COMPRESSED_SRGB8_ETC2,
|
|
4983
|
+
colorRenderable: false,
|
|
4984
|
+
textureFilterable: true,
|
|
4985
|
+
block: block8_4_4
|
|
4986
|
+
};
|
|
4987
|
+
t[COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
4988
|
+
textureFormat: COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
4989
|
+
colorRenderable: false,
|
|
4990
|
+
textureFilterable: true,
|
|
4991
|
+
block: block8_4_4
|
|
4992
|
+
};
|
|
4993
|
+
t[COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
4994
|
+
textureFormat: COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
4995
|
+
colorRenderable: false,
|
|
4996
|
+
textureFilterable: true,
|
|
4997
|
+
block: block8_4_4
|
|
4998
|
+
};
|
|
4999
|
+
t[COMPRESSED_RGBA8_ETC2_EAC] = {
|
|
5000
|
+
textureFormat: COMPRESSED_RGBA8_ETC2_EAC,
|
|
5001
|
+
colorRenderable: false,
|
|
5002
|
+
textureFilterable: true,
|
|
5003
|
+
block: block16_4_4
|
|
5004
|
+
};
|
|
5005
|
+
t[COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = {
|
|
5006
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
5007
|
+
colorRenderable: false,
|
|
5008
|
+
textureFilterable: true,
|
|
5009
|
+
block: block16_4_4
|
|
5010
|
+
};
|
|
5011
|
+
// https://registry.khronos.org/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt
|
|
5012
|
+
t[COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = {
|
|
5013
|
+
textureFormat: COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
5014
|
+
colorRenderable: false,
|
|
5015
|
+
textureFilterable: true,
|
|
5016
|
+
block: {
|
|
5017
|
+
bytes: 32,
|
|
5018
|
+
width: 8,
|
|
5019
|
+
height: 8
|
|
5179
5020
|
}
|
|
5180
|
-
return t;
|
|
5181
5021
|
};
|
|
5182
|
-
|
|
5022
|
+
t[COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = {
|
|
5023
|
+
textureFormat: COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
5024
|
+
colorRenderable: false,
|
|
5025
|
+
textureFilterable: true,
|
|
5026
|
+
block: {
|
|
5027
|
+
bytes: 32,
|
|
5028
|
+
width: 16,
|
|
5029
|
+
height: 8
|
|
5030
|
+
}
|
|
5031
|
+
};
|
|
5032
|
+
t[COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = {
|
|
5033
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
5034
|
+
colorRenderable: false,
|
|
5035
|
+
textureFilterable: true,
|
|
5036
|
+
block: {
|
|
5037
|
+
bytes: 32,
|
|
5038
|
+
width: 8,
|
|
5039
|
+
height: 8
|
|
5040
|
+
}
|
|
5041
|
+
};
|
|
5042
|
+
t[COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = {
|
|
5043
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
5044
|
+
colorRenderable: false,
|
|
5045
|
+
textureFilterable: true,
|
|
5046
|
+
block: {
|
|
5047
|
+
bytes: 32,
|
|
5048
|
+
width: 16,
|
|
5049
|
+
height: 8
|
|
5050
|
+
}
|
|
5051
|
+
};
|
|
5052
|
+
// https://registry.khronos.org/OpenGL/extensions/KHR/KHR_texture_compression_astc_hdr.txt
|
|
5053
|
+
t[COMPRESSED_RGBA_ASTC_4x4_KHR] = {
|
|
5054
|
+
textureFormat: COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
5055
|
+
colorRenderable: false,
|
|
5056
|
+
textureFilterable: true,
|
|
5057
|
+
block: {
|
|
5058
|
+
bytes: 16,
|
|
5059
|
+
width: 4,
|
|
5060
|
+
height: 4
|
|
5061
|
+
}
|
|
5062
|
+
};
|
|
5063
|
+
t[COMPRESSED_RGBA_ASTC_5x4_KHR] = {
|
|
5064
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
5065
|
+
colorRenderable: false,
|
|
5066
|
+
textureFilterable: true,
|
|
5067
|
+
block: {
|
|
5068
|
+
bytes: 16,
|
|
5069
|
+
width: 5,
|
|
5070
|
+
height: 4
|
|
5071
|
+
}
|
|
5072
|
+
};
|
|
5073
|
+
t[COMPRESSED_RGBA_ASTC_5x5_KHR] = {
|
|
5074
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
5075
|
+
colorRenderable: false,
|
|
5076
|
+
textureFilterable: true,
|
|
5077
|
+
block: {
|
|
5078
|
+
bytes: 16,
|
|
5079
|
+
width: 5,
|
|
5080
|
+
height: 5
|
|
5081
|
+
}
|
|
5082
|
+
};
|
|
5083
|
+
t[COMPRESSED_RGBA_ASTC_6x5_KHR] = {
|
|
5084
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
5085
|
+
colorRenderable: false,
|
|
5086
|
+
textureFilterable: true,
|
|
5087
|
+
block: {
|
|
5088
|
+
bytes: 16,
|
|
5089
|
+
width: 6,
|
|
5090
|
+
height: 5
|
|
5091
|
+
}
|
|
5092
|
+
};
|
|
5093
|
+
t[COMPRESSED_RGBA_ASTC_6x6_KHR] = {
|
|
5094
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
5095
|
+
colorRenderable: false,
|
|
5096
|
+
textureFilterable: true,
|
|
5097
|
+
block: {
|
|
5098
|
+
bytes: 16,
|
|
5099
|
+
width: 6,
|
|
5100
|
+
height: 6
|
|
5101
|
+
}
|
|
5102
|
+
};
|
|
5103
|
+
t[COMPRESSED_RGBA_ASTC_8x5_KHR] = {
|
|
5104
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
5105
|
+
colorRenderable: false,
|
|
5106
|
+
textureFilterable: true,
|
|
5107
|
+
block: {
|
|
5108
|
+
bytes: 16,
|
|
5109
|
+
width: 8,
|
|
5110
|
+
height: 5
|
|
5111
|
+
}
|
|
5112
|
+
};
|
|
5113
|
+
t[COMPRESSED_RGBA_ASTC_8x6_KHR] = {
|
|
5114
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
5115
|
+
colorRenderable: false,
|
|
5116
|
+
textureFilterable: true,
|
|
5117
|
+
block: {
|
|
5118
|
+
bytes: 16,
|
|
5119
|
+
width: 8,
|
|
5120
|
+
height: 6
|
|
5121
|
+
}
|
|
5122
|
+
};
|
|
5123
|
+
t[COMPRESSED_RGBA_ASTC_8x8_KHR] = {
|
|
5124
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
5125
|
+
colorRenderable: false,
|
|
5126
|
+
textureFilterable: true,
|
|
5127
|
+
block: {
|
|
5128
|
+
bytes: 16,
|
|
5129
|
+
width: 8,
|
|
5130
|
+
height: 8
|
|
5131
|
+
}
|
|
5132
|
+
};
|
|
5133
|
+
t[COMPRESSED_RGBA_ASTC_10x5_KHR] = {
|
|
5134
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
5135
|
+
colorRenderable: false,
|
|
5136
|
+
textureFilterable: true,
|
|
5137
|
+
block: {
|
|
5138
|
+
bytes: 16,
|
|
5139
|
+
width: 10,
|
|
5140
|
+
height: 5
|
|
5141
|
+
}
|
|
5142
|
+
};
|
|
5143
|
+
t[COMPRESSED_RGBA_ASTC_10x6_KHR] = {
|
|
5144
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
5145
|
+
colorRenderable: false,
|
|
5146
|
+
textureFilterable: true,
|
|
5147
|
+
block: {
|
|
5148
|
+
bytes: 16,
|
|
5149
|
+
width: 10,
|
|
5150
|
+
height: 6
|
|
5151
|
+
}
|
|
5152
|
+
};
|
|
5153
|
+
t[COMPRESSED_RGBA_ASTC_10x8_KHR] = {
|
|
5154
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
5155
|
+
colorRenderable: false,
|
|
5156
|
+
textureFilterable: true,
|
|
5157
|
+
block: {
|
|
5158
|
+
bytes: 16,
|
|
5159
|
+
width: 10,
|
|
5160
|
+
height: 8
|
|
5161
|
+
}
|
|
5162
|
+
};
|
|
5163
|
+
t[COMPRESSED_RGBA_ASTC_10x10_KHR] = {
|
|
5164
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
5165
|
+
colorRenderable: false,
|
|
5166
|
+
textureFilterable: true,
|
|
5167
|
+
block: {
|
|
5168
|
+
bytes: 16,
|
|
5169
|
+
width: 10,
|
|
5170
|
+
height: 10
|
|
5171
|
+
}
|
|
5172
|
+
};
|
|
5173
|
+
t[COMPRESSED_RGBA_ASTC_12x10_KHR] = {
|
|
5174
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
5175
|
+
colorRenderable: false,
|
|
5176
|
+
textureFilterable: true,
|
|
5177
|
+
block: {
|
|
5178
|
+
bytes: 16,
|
|
5179
|
+
width: 12,
|
|
5180
|
+
height: 10
|
|
5181
|
+
}
|
|
5182
|
+
};
|
|
5183
|
+
t[COMPRESSED_RGBA_ASTC_12x12_KHR] = {
|
|
5184
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
5185
|
+
colorRenderable: false,
|
|
5186
|
+
textureFilterable: true,
|
|
5187
|
+
block: {
|
|
5188
|
+
bytes: 16,
|
|
5189
|
+
width: 12,
|
|
5190
|
+
height: 12
|
|
5191
|
+
}
|
|
5192
|
+
};
|
|
5193
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR] = {
|
|
5194
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
5195
|
+
colorRenderable: false,
|
|
5196
|
+
textureFilterable: true,
|
|
5197
|
+
block: {
|
|
5198
|
+
bytes: 16,
|
|
5199
|
+
width: 4,
|
|
5200
|
+
height: 4
|
|
5201
|
+
}
|
|
5202
|
+
};
|
|
5203
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR] = {
|
|
5204
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
5205
|
+
colorRenderable: false,
|
|
5206
|
+
textureFilterable: true,
|
|
5207
|
+
block: {
|
|
5208
|
+
bytes: 16,
|
|
5209
|
+
width: 5,
|
|
5210
|
+
height: 4
|
|
5211
|
+
}
|
|
5212
|
+
};
|
|
5213
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR] = {
|
|
5214
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
5215
|
+
colorRenderable: false,
|
|
5216
|
+
textureFilterable: true,
|
|
5217
|
+
block: {
|
|
5218
|
+
bytes: 16,
|
|
5219
|
+
width: 5,
|
|
5220
|
+
height: 5
|
|
5221
|
+
}
|
|
5222
|
+
};
|
|
5223
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR] = {
|
|
5224
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
5225
|
+
colorRenderable: false,
|
|
5226
|
+
textureFilterable: true,
|
|
5227
|
+
block: {
|
|
5228
|
+
bytes: 16,
|
|
5229
|
+
width: 6,
|
|
5230
|
+
height: 5
|
|
5231
|
+
}
|
|
5232
|
+
};
|
|
5233
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR] = {
|
|
5234
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
5235
|
+
colorRenderable: false,
|
|
5236
|
+
textureFilterable: true,
|
|
5237
|
+
block: {
|
|
5238
|
+
bytes: 16,
|
|
5239
|
+
width: 6,
|
|
5240
|
+
height: 6
|
|
5241
|
+
}
|
|
5242
|
+
};
|
|
5243
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR] = {
|
|
5244
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
5245
|
+
colorRenderable: false,
|
|
5246
|
+
textureFilterable: true,
|
|
5247
|
+
block: {
|
|
5248
|
+
bytes: 16,
|
|
5249
|
+
width: 8,
|
|
5250
|
+
height: 5
|
|
5251
|
+
}
|
|
5252
|
+
};
|
|
5253
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR] = {
|
|
5254
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
5255
|
+
colorRenderable: false,
|
|
5256
|
+
textureFilterable: true,
|
|
5257
|
+
block: {
|
|
5258
|
+
bytes: 16,
|
|
5259
|
+
width: 8,
|
|
5260
|
+
height: 6
|
|
5261
|
+
}
|
|
5262
|
+
};
|
|
5263
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR] = {
|
|
5264
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
5265
|
+
colorRenderable: false,
|
|
5266
|
+
textureFilterable: true,
|
|
5267
|
+
block: {
|
|
5268
|
+
bytes: 16,
|
|
5269
|
+
width: 8,
|
|
5270
|
+
height: 8
|
|
5271
|
+
}
|
|
5272
|
+
};
|
|
5273
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR] = {
|
|
5274
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
5275
|
+
colorRenderable: false,
|
|
5276
|
+
textureFilterable: true,
|
|
5277
|
+
block: {
|
|
5278
|
+
bytes: 16,
|
|
5279
|
+
width: 10,
|
|
5280
|
+
height: 5
|
|
5281
|
+
}
|
|
5282
|
+
};
|
|
5283
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR] = {
|
|
5284
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
5285
|
+
colorRenderable: false,
|
|
5286
|
+
textureFilterable: true,
|
|
5287
|
+
block: {
|
|
5288
|
+
bytes: 16,
|
|
5289
|
+
width: 10,
|
|
5290
|
+
height: 6
|
|
5291
|
+
}
|
|
5292
|
+
};
|
|
5293
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR] = {
|
|
5294
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
5295
|
+
colorRenderable: false,
|
|
5296
|
+
textureFilterable: true,
|
|
5297
|
+
block: {
|
|
5298
|
+
bytes: 16,
|
|
5299
|
+
width: 10,
|
|
5300
|
+
height: 8
|
|
5301
|
+
}
|
|
5302
|
+
};
|
|
5303
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR] = {
|
|
5304
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
5305
|
+
colorRenderable: false,
|
|
5306
|
+
textureFilterable: true,
|
|
5307
|
+
block: {
|
|
5308
|
+
bytes: 16,
|
|
5309
|
+
width: 10,
|
|
5310
|
+
height: 10
|
|
5311
|
+
}
|
|
5312
|
+
};
|
|
5313
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR] = {
|
|
5314
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
5315
|
+
colorRenderable: false,
|
|
5316
|
+
textureFilterable: true,
|
|
5317
|
+
block: {
|
|
5318
|
+
bytes: 16,
|
|
5319
|
+
width: 12,
|
|
5320
|
+
height: 10
|
|
5321
|
+
}
|
|
5322
|
+
};
|
|
5323
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR] = {
|
|
5324
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
5325
|
+
colorRenderable: false,
|
|
5326
|
+
textureFilterable: true,
|
|
5327
|
+
block: {
|
|
5328
|
+
bytes: 16,
|
|
5329
|
+
width: 12,
|
|
5330
|
+
height: 12
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5333
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_bptc.txt
|
|
5334
|
+
t[COMPRESSED_RGBA_BPTC_UNORM_EXT] = {
|
|
5335
|
+
textureFormat: COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
5336
|
+
colorRenderable: false,
|
|
5337
|
+
textureFilterable: true,
|
|
5338
|
+
block: block16_4_4
|
|
5339
|
+
};
|
|
5340
|
+
t[COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT] = {
|
|
5341
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
5342
|
+
colorRenderable: false,
|
|
5343
|
+
textureFilterable: true,
|
|
5344
|
+
block: block16_4_4
|
|
5345
|
+
};
|
|
5346
|
+
t[COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT] = {
|
|
5347
|
+
textureFormat: COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
5348
|
+
colorRenderable: false,
|
|
5349
|
+
textureFilterable: true,
|
|
5350
|
+
block: block16_4_4
|
|
5351
|
+
};
|
|
5352
|
+
t[COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT] = {
|
|
5353
|
+
textureFormat: COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
5354
|
+
colorRenderable: false,
|
|
5355
|
+
textureFilterable: true,
|
|
5356
|
+
block: block16_4_4
|
|
5357
|
+
};
|
|
5358
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_rgtc.txt
|
|
5359
|
+
t[COMPRESSED_RED_RGTC1_EXT] = {
|
|
5360
|
+
textureFormat: COMPRESSED_RED_RGTC1_EXT,
|
|
5361
|
+
colorRenderable: false,
|
|
5362
|
+
textureFilterable: true,
|
|
5363
|
+
block: block8_4_4
|
|
5364
|
+
};
|
|
5365
|
+
t[COMPRESSED_SIGNED_RED_RGTC1_EXT] = {
|
|
5366
|
+
textureFormat: COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
5367
|
+
colorRenderable: false,
|
|
5368
|
+
textureFilterable: true,
|
|
5369
|
+
block: block8_4_4
|
|
5370
|
+
};
|
|
5371
|
+
t[COMPRESSED_RED_GREEN_RGTC2_EXT] = {
|
|
5372
|
+
textureFormat: COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
5373
|
+
colorRenderable: false,
|
|
5374
|
+
textureFilterable: true,
|
|
5375
|
+
block: block8_4_4
|
|
5376
|
+
};
|
|
5377
|
+
t[COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT] = {
|
|
5378
|
+
textureFormat: COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
5379
|
+
colorRenderable: false,
|
|
5380
|
+
textureFilterable: true,
|
|
5381
|
+
block: block8_4_4
|
|
5382
|
+
};
|
|
5183
5383
|
s_textureInternalFormatInfo = t;
|
|
5184
5384
|
}
|
|
5185
|
-
|
|
5385
|
+
var info = s_textureInternalFormatInfo[internalFormat];
|
|
5386
|
+
if (!info) {
|
|
5387
|
+
throw new Error("unknown internal format");
|
|
5388
|
+
}
|
|
5389
|
+
return info;
|
|
5186
5390
|
}
|
|
5187
5391
|
|
|
5188
5392
|
/**
|
|
@@ -5194,12 +5398,9 @@ function getTextureInternalFormatInfo(internalFormat) {
|
|
|
5194
5398
|
*/
|
|
5195
5399
|
function getBytesPerElementForInternalFormat(internalFormat, type) {
|
|
5196
5400
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5197
|
-
if (!info) {
|
|
5198
|
-
throw "unknown internal format";
|
|
5199
|
-
}
|
|
5200
5401
|
var bytesPerElement = info.bytesPerElementMap[type];
|
|
5201
5402
|
if (bytesPerElement === undefined) {
|
|
5202
|
-
throw "
|
|
5403
|
+
throw new Error("type not supported for internal format");
|
|
5203
5404
|
}
|
|
5204
5405
|
return bytesPerElement;
|
|
5205
5406
|
}
|
|
@@ -5225,7 +5426,7 @@ function getFormatAndTypeForInternalFormat(internalFormat) {
|
|
|
5225
5426
|
var _info$type$, _info$type;
|
|
5226
5427
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5227
5428
|
if (!info) {
|
|
5228
|
-
throw "unknown internal format";
|
|
5429
|
+
throw new Error("unknown internal format");
|
|
5229
5430
|
}
|
|
5230
5431
|
return {
|
|
5231
5432
|
format: info.textureFormat,
|
|
@@ -5240,10 +5441,30 @@ function getFormatAndTypeForInternalFormat(internalFormat) {
|
|
|
5240
5441
|
*/
|
|
5241
5442
|
function isCompressedInternalFormat(internalFormat) {
|
|
5242
5443
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5243
|
-
|
|
5244
|
-
|
|
5444
|
+
return !!info.block;
|
|
5445
|
+
}
|
|
5446
|
+
|
|
5447
|
+
/**
|
|
5448
|
+
* Gets the width, height, and bytes per block for the given internal format
|
|
5449
|
+
* @param {number} internalFormat
|
|
5450
|
+
* @param {number} type
|
|
5451
|
+
* @private
|
|
5452
|
+
*/
|
|
5453
|
+
function getBlockInfoForInternalFormat(internalFormat, type) {
|
|
5454
|
+
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5455
|
+
if (info.block) {
|
|
5456
|
+
return {
|
|
5457
|
+
blockWidth: info.block.width,
|
|
5458
|
+
blockHeight: info.block.height,
|
|
5459
|
+
bytesPerBlock: info.block.bytes
|
|
5460
|
+
};
|
|
5245
5461
|
}
|
|
5246
|
-
|
|
5462
|
+
var bytesPerBlock = getBytesPerElementForInternalFormat(internalFormat, type);
|
|
5463
|
+
return {
|
|
5464
|
+
blockWidth: 1,
|
|
5465
|
+
blockHeight: 1,
|
|
5466
|
+
bytesPerBlock: bytesPerBlock
|
|
5467
|
+
};
|
|
5247
5468
|
}
|
|
5248
5469
|
|
|
5249
5470
|
/**
|
|
@@ -5272,9 +5493,6 @@ function canGenerateMipmap(gl, width, height, internalFormat) {
|
|
|
5272
5493
|
return isPowerOf2(width) && isPowerOf2(height);
|
|
5273
5494
|
}
|
|
5274
5495
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5275
|
-
if (!info) {
|
|
5276
|
-
throw "unknown internal format";
|
|
5277
|
-
}
|
|
5278
5496
|
return info.colorRenderable && info.textureFilterable;
|
|
5279
5497
|
}
|
|
5280
5498
|
|
|
@@ -5286,9 +5504,6 @@ function canGenerateMipmap(gl, width, height, internalFormat) {
|
|
|
5286
5504
|
*/
|
|
5287
5505
|
function canFilter(internalFormat) {
|
|
5288
5506
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5289
|
-
if (!info) {
|
|
5290
|
-
throw "unknown internal format";
|
|
5291
|
-
}
|
|
5292
5507
|
return info.textureFilterable;
|
|
5293
5508
|
}
|
|
5294
5509
|
|
|
@@ -5300,9 +5515,6 @@ function canFilter(internalFormat) {
|
|
|
5300
5515
|
*/
|
|
5301
5516
|
function getNumComponentsForFormat(format) {
|
|
5302
5517
|
var info = formatInfo[format];
|
|
5303
|
-
if (!info) {
|
|
5304
|
-
throw "unknown format: " + format;
|
|
5305
|
-
}
|
|
5306
5518
|
return info.numColorComponents;
|
|
5307
5519
|
}
|
|
5308
5520
|
|
|
@@ -5320,7 +5532,7 @@ function getTextureTypeForArrayType(gl, src, defaultType) {
|
|
|
5320
5532
|
}
|
|
5321
5533
|
function guessDimensions(gl, target, width, height, numElements) {
|
|
5322
5534
|
if (numElements % 1 !== 0) {
|
|
5323
|
-
throw "can't guess dimensions";
|
|
5535
|
+
throw new Error("can't guess dimensions");
|
|
5324
5536
|
}
|
|
5325
5537
|
if (!width && !height) {
|
|
5326
5538
|
var size = Math.sqrt(numElements / (target === TEXTURE_CUBE_MAP ? 6 : 1));
|
|
@@ -5334,12 +5546,12 @@ function guessDimensions(gl, target, width, height, numElements) {
|
|
|
5334
5546
|
} else if (!height) {
|
|
5335
5547
|
height = numElements / width;
|
|
5336
5548
|
if (height % 1) {
|
|
5337
|
-
throw "can't guess dimensions";
|
|
5549
|
+
throw new Error("can't guess dimensions");
|
|
5338
5550
|
}
|
|
5339
5551
|
} else if (!width) {
|
|
5340
5552
|
width = numElements / height;
|
|
5341
5553
|
if (width % 1) {
|
|
5342
|
-
throw "can't guess dimensions";
|
|
5554
|
+
throw new Error("can't guess dimensions");
|
|
5343
5555
|
}
|
|
5344
5556
|
}
|
|
5345
5557
|
return {
|
|
@@ -5392,7 +5604,7 @@ function setDefaults(newDefaults) {
|
|
|
5392
5604
|
* @property {number} [level] the mip level to affect. Defaults to 0. Note, if set auto will be considered false unless explicitly set to true.
|
|
5393
5605
|
* @property {number} [width] the width of the texture. Only used if src is an array or typed array or null.
|
|
5394
5606
|
* @property {number} [height] the height of a texture. Only used if src is an array or typed array or null.
|
|
5395
|
-
* @property {number} [depth] the depth of a texture. Only used if src is an array or
|
|
5607
|
+
* @property {number} [depth] the depth of a texture. Only used if src is an array or typed array or null and target is `TEXTURE_3D` .
|
|
5396
5608
|
* @property {number} [min] the min filter setting (eg. `gl.LINEAR`). Defaults to `gl.NEAREST_MIPMAP_LINEAR`
|
|
5397
5609
|
* or if texture is not a power of 2 on both dimensions then defaults to `gl.LINEAR`.
|
|
5398
5610
|
* @property {number} [mag] the mag filter setting (eg. `gl.LINEAR`). Defaults to `gl.LINEAR`
|
|
@@ -5451,15 +5663,24 @@ function setDefaults(newDefaults) {
|
|
|
5451
5663
|
* If `TexImageSource` then it wil be used immediately to create the contents of the texture. Examples `HTMLImageElement`,
|
|
5452
5664
|
* `HTMLCanvasElement`, `HTMLVideoElement`.
|
|
5453
5665
|
*
|
|
5454
|
-
* If `number[]` or `ArrayBufferView` it's assumed to be data for a texture.
|
|
5455
|
-
* not specified it is guessed as follows. First the number of elements is computed by `src.length / numComponents`
|
|
5456
|
-
* where `numComponents` is derived from `format`. If `target` is `gl.TEXTURE_CUBE_MAP` then `numElements` is divided
|
|
5457
|
-
* by 6. Then
|
|
5666
|
+
* If `number[]` or `ArrayBufferView` it's assumed to be data for a texture.
|
|
5458
5667
|
*
|
|
5459
|
-
* *
|
|
5460
|
-
* are set to `sqrt(numElements)`. Otherwise `width = numElements` and `height = 1`.
|
|
5668
|
+
* * If `width` or `height` is not specified it is guessed as follows.
|
|
5461
5669
|
*
|
|
5462
|
-
*
|
|
5670
|
+
* First the number of elements is computed by `src.length / numComponents`
|
|
5671
|
+
* where `numComponents` is derived from `format`. If `target` is `gl.TEXTURE_CUBE_MAP` then `numElements` is divided
|
|
5672
|
+
* by 6. Then
|
|
5673
|
+
*
|
|
5674
|
+
* * If neither `width` nor `height` are specified and `sqrt(numElements)` is an integer then width and height
|
|
5675
|
+
* are set to `sqrt(numElements)`. Otherwise `width = numElements` and `height = 1`.
|
|
5676
|
+
*
|
|
5677
|
+
* * If only one of `width` or `height` is specified then the other equals `numElements / specifiedDimension`.
|
|
5678
|
+
*
|
|
5679
|
+
* * If both `width` and `height` is specified, then, the size of mip levels from `level` will be computed
|
|
5680
|
+
* and data for consecutive mip levels will be uploaded until the data runs out.
|
|
5681
|
+
*
|
|
5682
|
+
* In other words: `{ format: g.RGBA, width: 4, height: 4, src: Uint8Array((4 * 4 + 2 * 2 + 1) * 4) }`
|
|
5683
|
+
* uploads 3 mip levels (4x4, 2x2, 1x1) because src is more than the data for the first mip level.
|
|
5463
5684
|
*
|
|
5464
5685
|
* If `number[]` will be converted to `type`.
|
|
5465
5686
|
*
|
|
@@ -5710,27 +5931,48 @@ function make1Pixel(color) {
|
|
|
5710
5931
|
return new Uint8Array([color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255]);
|
|
5711
5932
|
}
|
|
5712
5933
|
|
|
5934
|
+
/**
|
|
5935
|
+
* @typedef {Object} SetTextureFilteringInternalOptions
|
|
5936
|
+
* @property {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
|
|
5937
|
+
* This is often the same options you passed in when you created the texture.
|
|
5938
|
+
* @property {number} [width] width of texture
|
|
5939
|
+
* @property {number} [height] height of texture
|
|
5940
|
+
* @property {number} [internalFormat] The internalFormat parameter from texImage2D etc..
|
|
5941
|
+
* @property {number} [lastMipLevelUploaded] The last mip level manually uploaded
|
|
5942
|
+
* @private
|
|
5943
|
+
*/
|
|
5944
|
+
|
|
5713
5945
|
/**
|
|
5714
5946
|
* Sets filtering or generates mips for texture based on width or height
|
|
5715
5947
|
* If width or height is not passed in uses `options.width` and//or `options.height`
|
|
5716
5948
|
*
|
|
5717
5949
|
* @param {WebGLRenderingContext} gl the WebGLRenderingContext
|
|
5718
5950
|
* @param {WebGLTexture} tex the WebGLTexture to set parameters for
|
|
5719
|
-
* @param {
|
|
5720
|
-
*
|
|
5721
|
-
* @param {number} [width] width of texture
|
|
5722
|
-
* @param {number} [height] height of texture
|
|
5723
|
-
* @param {number} [internalFormat] The internalFormat parameter from texImage2D etc..
|
|
5724
|
-
* @memberOf module:twgl/textures
|
|
5951
|
+
* @param {SetTextureFilteringInternalOptions} p
|
|
5952
|
+
* @private
|
|
5725
5953
|
*/
|
|
5726
|
-
function
|
|
5954
|
+
function setTextureFilteringForSizeInternal(gl, tex, _ref2) {
|
|
5955
|
+
var options = _ref2.options,
|
|
5956
|
+
width = _ref2.width,
|
|
5957
|
+
height = _ref2.height,
|
|
5958
|
+
internalFormat = _ref2.internalFormat,
|
|
5959
|
+
lastMipLevelUploaded = _ref2.lastMipLevelUploaded;
|
|
5727
5960
|
options = options || defaults.textureOptions;
|
|
5728
5961
|
internalFormat = internalFormat || RGBA;
|
|
5729
5962
|
var target = options.target || TEXTURE_2D;
|
|
5730
5963
|
width = width || options.width;
|
|
5731
5964
|
height = height || options.height;
|
|
5732
5965
|
gl.bindTexture(target, tex);
|
|
5733
|
-
if (
|
|
5966
|
+
if (lastMipLevelUploaded > 1) {
|
|
5967
|
+
var lastLevelWidth = Math.max(1, width >> lastMipLevelUploaded);
|
|
5968
|
+
var lastLevelHeight = Math.max(1, height >> lastMipLevelUploaded);
|
|
5969
|
+
// Note: This is a guess. The user can set maxLod etc...
|
|
5970
|
+
var canUseMips = lastLevelWidth === 1 && lastLevelHeight === 1;
|
|
5971
|
+
var magFiltering = canFilter(internalFormat) ? LINEAR : NEAREST;
|
|
5972
|
+
var minFiltering = canFilter(internalFormat) ? canUseMips ? NEAREST_MIPMAP_LINEAR : LINEAR : NEAREST;
|
|
5973
|
+
gl.texParameteri(target, TEXTURE_MAG_FILTER, magFiltering);
|
|
5974
|
+
gl.texParameteri(target, TEXTURE_MIN_FILTER, minFiltering);
|
|
5975
|
+
} else if (canGenerateMipmap(gl, width, height, internalFormat)) {
|
|
5734
5976
|
gl.generateMipmap(target);
|
|
5735
5977
|
} else {
|
|
5736
5978
|
var filtering = canFilter(internalFormat) ? LINEAR : NEAREST;
|
|
@@ -5740,6 +5982,28 @@ function setTextureFilteringForSize(gl, tex, options, width, height, internalFor
|
|
|
5740
5982
|
gl.texParameteri(target, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
|
|
5741
5983
|
}
|
|
5742
5984
|
}
|
|
5985
|
+
|
|
5986
|
+
/**
|
|
5987
|
+
* Sets filtering or generates mips for texture based on width or height
|
|
5988
|
+
* If width or height is not passed in uses `options.width` and//or `options.height`
|
|
5989
|
+
*
|
|
5990
|
+
* @param {WebGLRenderingContext} gl the WebGLRenderingContext
|
|
5991
|
+
* @param {WebGLTexture} tex the WebGLTexture to set parameters for
|
|
5992
|
+
* @param {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
|
|
5993
|
+
* This is often the same options you passed in when you created the texture.
|
|
5994
|
+
* @param {number} [width] width of texture
|
|
5995
|
+
* @param {number} [height] height of texture
|
|
5996
|
+
* @param {number} [internalFormat] The internalFormat parameter from texImage2D etc..
|
|
5997
|
+
* @memberOf module:twgl/textures
|
|
5998
|
+
*/
|
|
5999
|
+
function setTextureFilteringForSize(gl, tex, options, width, height, internalFormat) {
|
|
6000
|
+
setTextureFilteringForSizeInternal(gl, tex, {
|
|
6001
|
+
options: options,
|
|
6002
|
+
width: width,
|
|
6003
|
+
height: height,
|
|
6004
|
+
internalFormat: internalFormat
|
|
6005
|
+
});
|
|
6006
|
+
}
|
|
5743
6007
|
function shouldAutomaticallySetTextureFilteringForSize(options) {
|
|
5744
6008
|
return options.auto === true || options.auto === undefined && options.level === undefined;
|
|
5745
6009
|
}
|
|
@@ -5839,7 +6103,7 @@ function setTextureFromElement(gl, tex, element, options) {
|
|
|
5839
6103
|
size = imgWidth / 2;
|
|
5840
6104
|
slices = [0, 0, 1, 0, 0, 1, 1, 1, 0, 2, 1, 2];
|
|
5841
6105
|
} else {
|
|
5842
|
-
throw "can't figure out cube map from element: "
|
|
6106
|
+
throw new Error("can't figure out cube map from element: ".concat(element.src ? element.src : element.nodeName));
|
|
5843
6107
|
}
|
|
5844
6108
|
var ctx = getShared2DContext();
|
|
5845
6109
|
if (ctx) {
|
|
@@ -5892,7 +6156,7 @@ function setTextureFromElement(gl, tex, element, options) {
|
|
|
5892
6156
|
var largest = Math.max(element.width, element.height);
|
|
5893
6157
|
var depth = largest / smallest;
|
|
5894
6158
|
if (depth % 1 !== 0) {
|
|
5895
|
-
throw "can not compute 3D dimensions of element";
|
|
6159
|
+
throw new Error("can not compute 3D dimensions of element");
|
|
5896
6160
|
}
|
|
5897
6161
|
var xMult = element.width === largest ? 1 : 0;
|
|
5898
6162
|
var yMult = element.height === largest ? 1 : 0;
|
|
@@ -6174,7 +6438,7 @@ function loadCubemapFromUrls(gl, tex, options, callback) {
|
|
|
6174
6438
|
callback = callback || noop;
|
|
6175
6439
|
var urls = options.src;
|
|
6176
6440
|
if (urls.length !== 6) {
|
|
6177
|
-
throw "there must be 6 urls for a cubemap";
|
|
6441
|
+
throw new Error("there must be 6 urls for a cubemap");
|
|
6178
6442
|
}
|
|
6179
6443
|
var level = options.level || 0;
|
|
6180
6444
|
var internalFormat = options.internalFormat || options.format || RGBA;
|
|
@@ -6183,7 +6447,7 @@ function loadCubemapFromUrls(gl, tex, options, callback) {
|
|
|
6183
6447
|
var type = options.type || UNSIGNED_BYTE;
|
|
6184
6448
|
var target = options.target || TEXTURE_2D;
|
|
6185
6449
|
if (target !== TEXTURE_CUBE_MAP) {
|
|
6186
|
-
throw "target must be TEXTURE_CUBE_MAP";
|
|
6450
|
+
throw new Error("target must be TEXTURE_CUBE_MAP");
|
|
6187
6451
|
}
|
|
6188
6452
|
setTextureTo1PixelColor(gl, tex, options);
|
|
6189
6453
|
// Because it's async we need to copy the options.
|
|
@@ -6261,7 +6525,7 @@ function loadSlicesFromUrls(gl, tex, options, callback) {
|
|
|
6261
6525
|
var type = options.type || UNSIGNED_BYTE;
|
|
6262
6526
|
var target = options.target || TEXTURE_2D_ARRAY;
|
|
6263
6527
|
if (target !== TEXTURE_3D && target !== TEXTURE_2D_ARRAY) {
|
|
6264
|
-
throw "target must be TEXTURE_3D or TEXTURE_2D_ARRAY";
|
|
6528
|
+
throw new Error("target must be TEXTURE_3D or TEXTURE_2D_ARRAY");
|
|
6265
6529
|
}
|
|
6266
6530
|
setTextureTo1PixelColor(gl, tex, options);
|
|
6267
6531
|
// Because it's async we need to copy the options.
|
|
@@ -6351,63 +6615,96 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
6351
6615
|
} else if (src instanceof Uint8ClampedArray) {
|
|
6352
6616
|
src = new Uint8Array(src.buffer);
|
|
6353
6617
|
}
|
|
6354
|
-
var _getTextureSize = getTextureSize(
|
|
6618
|
+
var _getTextureSize = getTextureSize(target, src, options, internalFormat, format, type),
|
|
6355
6619
|
width = _getTextureSize.width,
|
|
6356
6620
|
height = _getTextureSize.height,
|
|
6357
6621
|
depth = _getTextureSize.depth;
|
|
6358
6622
|
var compressed = isCompressedInternalFormat(internalFormat);
|
|
6359
6623
|
setSkipStateToDefault(gl);
|
|
6360
6624
|
gl.pixelStorei(UNPACK_ALIGNMENT, options.unpackAlignment || 1);
|
|
6625
|
+
var mipLevelOffset = 0; // this is in addition to level
|
|
6361
6626
|
scopedSetPackState(gl, options, function () {
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6627
|
+
var mipLevelByteOffset = 0;
|
|
6628
|
+
var _getBlockInfoForInter = getBlockInfoForInternalFormat(internalFormat, type),
|
|
6629
|
+
blockWidth = _getBlockInfoForInter.blockWidth,
|
|
6630
|
+
blockHeight = _getBlockInfoForInter.blockHeight,
|
|
6631
|
+
bytesPerBlock = _getBlockInfoForInter.bytesPerBlock;
|
|
6632
|
+
var _loop = function _loop() {
|
|
6633
|
+
var mipWidth = Math.max(1, width >> mipLevelOffset);
|
|
6634
|
+
var mipHeight = Math.max(1, height >> mipLevelOffset);
|
|
6635
|
+
var mipDepth = target === TEXTURE_2D ? Math.max(1, depth >> mipLevelOffset) : depth;
|
|
6636
|
+
var blocksAcross = Math.ceil(mipWidth / blockWidth);
|
|
6637
|
+
var blocksDown = Math.ceil(mipHeight / blockHeight);
|
|
6638
|
+
var numFaces = target === TEXTURE_CUBE_MAP ? 6 : 1;
|
|
6639
|
+
var bytesPerMipLevel = blocksAcross * blocksDown * bytesPerBlock * mipDepth * numFaces;
|
|
6640
|
+
if (mipLevelByteOffset + bytesPerMipLevel > src.byteLength) {
|
|
6641
|
+
throw new Error('src size does not match number of mip levels');
|
|
6642
|
+
}
|
|
6643
|
+
var mipSource = src.subarray(mipLevelByteOffset / src.BYTES_PER_ELEMENT, (mipLevelByteOffset + bytesPerMipLevel) / src.BYTES_PER_ELEMENT);
|
|
6644
|
+
var mipLevel = level + mipLevelOffset;
|
|
6645
|
+
if (target === TEXTURE_CUBE_MAP) {
|
|
6646
|
+
var faceSize = mipSource.length / 6;
|
|
6647
|
+
getCubeFacesWithNdx(gl, options).forEach(function (f) {
|
|
6648
|
+
var offset = faceSize * f.ndx;
|
|
6649
|
+
var data = mipSource.subarray(offset, offset + faceSize);
|
|
6650
|
+
if (compressed) {
|
|
6651
|
+
gl.compressedTexImage2D(f.face, mipLevel, internalFormat, mipWidth, mipHeight, 0, data);
|
|
6652
|
+
} else {
|
|
6653
|
+
gl.texImage2D(f.face, mipLevel, internalFormat, mipWidth, mipHeight, 0, format, type, data);
|
|
6654
|
+
}
|
|
6655
|
+
});
|
|
6656
|
+
} else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6657
|
+
gl.texImage3D(target, mipLevel, internalFormat, mipWidth, mipHeight, mipDepth, 0, format, type, mipSource);
|
|
6658
|
+
} else {
|
|
6367
6659
|
if (compressed) {
|
|
6368
|
-
gl.compressedTexImage2D(
|
|
6660
|
+
gl.compressedTexImage2D(target, mipLevel, internalFormat, mipWidth, mipHeight, 0, mipSource);
|
|
6369
6661
|
} else {
|
|
6370
|
-
gl.texImage2D(
|
|
6662
|
+
gl.texImage2D(target, mipLevel, internalFormat, mipWidth, mipHeight, 0, format, type, mipSource);
|
|
6371
6663
|
}
|
|
6372
|
-
});
|
|
6373
|
-
} else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6374
|
-
gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
|
|
6375
|
-
} else {
|
|
6376
|
-
if (compressed) {
|
|
6377
|
-
gl.compressedTexImage2D(target, level, internalFormat, width, height, 0, src);
|
|
6378
|
-
} else {
|
|
6379
|
-
gl.texImage2D(target, level, internalFormat, width, height, 0, format, type, src);
|
|
6380
6664
|
}
|
|
6665
|
+
++mipLevelOffset;
|
|
6666
|
+
mipLevelByteOffset += bytesPerMipLevel;
|
|
6667
|
+
if (mipWidth === 1 && mipHeight === 1 && mipDepth === 1 && mipLevelByteOffset !== src.byteLength) {
|
|
6668
|
+
throw new Error('src size has more data than can fit in mip levels');
|
|
6669
|
+
}
|
|
6670
|
+
};
|
|
6671
|
+
while (mipLevelByteOffset < src.byteLength) {
|
|
6672
|
+
_loop();
|
|
6381
6673
|
}
|
|
6382
6674
|
});
|
|
6383
6675
|
return {
|
|
6384
6676
|
width: width,
|
|
6385
6677
|
height: height,
|
|
6386
6678
|
depth: depth,
|
|
6387
|
-
type: type
|
|
6679
|
+
type: type,
|
|
6680
|
+
lastMipLevelUploaded: level + mipLevelOffset - 1
|
|
6388
6681
|
};
|
|
6389
6682
|
}
|
|
6390
|
-
function getTextureSize(
|
|
6683
|
+
function getTextureSize(target, src, options, internalFormat, format, type) {
|
|
6391
6684
|
var width = options.width;
|
|
6392
6685
|
var height = options.height;
|
|
6393
6686
|
var depth = options.depth;
|
|
6394
6687
|
var compressed = isCompressedInternalFormat(internalFormat);
|
|
6395
6688
|
if (compressed) {
|
|
6396
6689
|
if (!width || !height) {
|
|
6397
|
-
throw "compressed texture needs to set width and height!";
|
|
6690
|
+
throw new Error("compressed texture needs to set width and height!");
|
|
6398
6691
|
}
|
|
6692
|
+
depth = depth || 1;
|
|
6399
6693
|
} else {
|
|
6400
6694
|
var bytesPerElement = getBytesPerElementForInternalFormat(internalFormat, type);
|
|
6401
6695
|
var numElements = src.byteLength / bytesPerElement; // TODO: check UNPACK_ALIGNMENT?
|
|
6402
6696
|
if (numElements % 1) {
|
|
6403
|
-
throw "length wrong size for format: "
|
|
6697
|
+
throw new Error("length wrong size for format: ".concat(utils.glEnumToString(gl, format)));
|
|
6698
|
+
}
|
|
6699
|
+
if (compressed && (!width || !height)) {
|
|
6700
|
+
throw new Error("compressed texture needs to set width and height!");
|
|
6404
6701
|
}
|
|
6405
6702
|
var dimensions;
|
|
6406
6703
|
if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6407
6704
|
if (!width && !height && !depth) {
|
|
6408
6705
|
var size = Math.cbrt(numElements);
|
|
6409
6706
|
if (size % 1 !== 0) {
|
|
6410
|
-
throw "can't guess cube size of array of numElements: "
|
|
6707
|
+
throw new Error("can't guess cube size of array of numElements: ".concat(numElements));
|
|
6411
6708
|
}
|
|
6412
6709
|
width = size;
|
|
6413
6710
|
height = size;
|
|
@@ -6507,6 +6804,7 @@ function createTexture(gl, options, callback) {
|
|
|
6507
6804
|
var target = options.target || TEXTURE_2D;
|
|
6508
6805
|
var width = options.width || 1;
|
|
6509
6806
|
var height = options.height || 1;
|
|
6807
|
+
var lastMipLevelUploaded = 0;
|
|
6510
6808
|
var internalFormat = options.internalFormat || RGBA;
|
|
6511
6809
|
gl.bindTexture(target, tex);
|
|
6512
6810
|
if (target === TEXTURE_CUBE_MAP) {
|
|
@@ -6525,6 +6823,7 @@ function createTexture(gl, options, callback) {
|
|
|
6525
6823
|
var dimensions = setTextureFromArray(gl, tex, src, options);
|
|
6526
6824
|
width = dimensions.width;
|
|
6527
6825
|
height = dimensions.height;
|
|
6826
|
+
lastMipLevelUploaded = dimensions.lastMipLevelUploaded;
|
|
6528
6827
|
} else if (Array.isArray(src) && (typeof src[0] === 'string' || isTexImageSource(src[0]))) {
|
|
6529
6828
|
if (target === TEXTURE_CUBE_MAP) {
|
|
6530
6829
|
loadCubemapFromUrls(gl, tex, options, callback);
|
|
@@ -6541,7 +6840,13 @@ function createTexture(gl, options, callback) {
|
|
|
6541
6840
|
setEmptyTexture(gl, tex, options);
|
|
6542
6841
|
}
|
|
6543
6842
|
if (shouldAutomaticallySetTextureFilteringForSize(options)) {
|
|
6544
|
-
|
|
6843
|
+
setTextureFilteringForSizeInternal(gl, tex, {
|
|
6844
|
+
options: options,
|
|
6845
|
+
width: width,
|
|
6846
|
+
height: height,
|
|
6847
|
+
internalFormat: internalFormat,
|
|
6848
|
+
lastMipLevelUploaded: lastMipLevelUploaded
|
|
6849
|
+
});
|
|
6545
6850
|
}
|
|
6546
6851
|
setTextureParameters(gl, tex, options);
|
|
6547
6852
|
return tex;
|