@@ -69,6 +69,78 @@ define([
69
69
*/
70
70
LUMINANCE_ALPHA : WebGLConstants . LUMINANCE_ALPHA ,
71
71
72
+ /**
73
+ * A pixel format containing red, green, and blue channels that is DXT1 compressed.
74
+ *
75
+ * @type {Number }
76
+ * @constant
77
+ */
78
+ RGB_DXT1 : WebGLConstants . COMPRESSED_RGB_S3TC_DXT1_EXT ,
79
+
80
+ /**
81
+ * A pixel format containing red, green, blue, and alpha channels that is DXT1 compressed.
82
+ *
83
+ * @type {Number }
84
+ * @constant
85
+ */
86
+ RGBA_DXT1 : WebGLConstants . COMPRESSED_RGBA_S3TC_DXT1_EXT ,
87
+
88
+ /**
89
+ * A pixel format containing red, green, blue, and alpha channels that is DXT3 compressed.
90
+ *
91
+ * @type {Number }
92
+ * @constant
93
+ */
94
+ RGBA_DXT3 : WebGLConstants . COMPRESSED_RGBA_S3TC_DXT3_EXT ,
95
+
96
+ /**
97
+ * A pixel format containing red, green, blue, and alpha channels that is DXT5 compressed.
98
+ *
99
+ * @type {Number }
100
+ * @constant
101
+ */
102
+ RGBA_DXT5 : WebGLConstants . COMPRESSED_RGBA_S3TC_DXT5_EXT ,
103
+
104
+ /**
105
+ * A pixel format containing red, green, and blue channels that is PVR 4bpp compressed.
106
+ *
107
+ * @type {Number }
108
+ * @constant
109
+ */
110
+ RGB_PVRTC_4BPPV1 : WebGLConstants . COMPRESSED_RGB_PVRTC_4BPPV1_IMG ,
111
+
112
+ /**
113
+ * A pixel format containing red, green, and blue channels that is PVR 2bpp compressed.
114
+ *
115
+ * @type {Number }
116
+ * @constant
117
+ */
118
+ RGB_PVRTC_2BPPV1 : WebGLConstants . COMPRESSED_RGB_PVRTC_2BPPV1_IMG ,
119
+
120
+ /**
121
+ * A pixel format containing red, green, blue, and alpha channels that is PVR 4bpp compressed.
122
+ *
123
+ * @type {Number }
124
+ * @constant
125
+ */
126
+ RGBA_PVRTC_4BPPV1 : WebGLConstants . COMPRESSED_RGBA_PVRTC_4BPPV1_IMG ,
127
+
128
+ /**
129
+ * A pixel format containing red, green, blue, and alpha channels that is PVR 2bpp compressed.
130
+ *
131
+ * @type {Number }
132
+ * @constant
133
+ */
134
+ RGBA_PVRTC_2BPPV1 : WebGLConstants . COMPRESSED_RGBA_PVRTC_2BPPV1_IMG ,
135
+
136
+ /**
137
+ * A pixel format containing red, green, and blue channels that is ETC1 compressed.
138
+ *
139
+ * @type {Number }
140
+ * @constant
141
+ */
142
+ RGB_ETC1 : WebGLConstants . COMPRESSED_RGB_ETC1_WEBGL ,
143
+
72
144
/**
73
145
* @private
74
146
*/
@@ -79,7 +151,16 @@ define([
79
151
pixelFormat === PixelFormat . RGB ||
80
152
pixelFormat === PixelFormat . RGBA ||
81
153
pixelFormat === PixelFormat . LUMINANCE ||
82
- pixelFormat === PixelFormat . LUMINANCE_ALPHA ;
154
+ pixelFormat === PixelFormat . LUMINANCE_ALPHA ||
155
+ pixelFormat === PixelFormat . RGB_DXT1 ||
156
+ pixelFormat === PixelFormat . RGBA_DXT1 ||
157
+ pixelFormat === PixelFormat . RGBA_DXT3 ||
158
+ pixelFormat === PixelFormat . RGBA_DXT5 ||
159
+ pixelFormat === PixelFormat . RGB_PVRTC_4BPPV1 ||
160
+ pixelFormat === PixelFormat . RGB_PVRTC_2BPPV1 ||
161
+ pixelFormat === PixelFormat . RGBA_PVRTC_4BPPV1 ||
162
+ pixelFormat === PixelFormat . RGBA_PVRTC_2BPPV1 ||
163
+ pixelFormat === PixelFormat . RGB_ETC1 ;
83
164
} ,
84
165
85
166
/**
@@ -99,6 +180,75 @@ define([
99
180
isDepthFormat : function ( pixelFormat ) {
100
181
return pixelFormat === PixelFormat . DEPTH_COMPONENT ||
101
182
pixelFormat === PixelFormat . DEPTH_STENCIL ;
183
+ } ,
184
+
185
+ /**
186
+ * @private
187
+ */
188
+ isCompressedFormat : function ( pixelFormat ) {
189
+ return pixelFormat === PixelFormat . RGB_DXT1 ||
190
+ pixelFormat === PixelFormat . RGBA_DXT1 ||
191
+ pixelFormat === PixelFormat . RGBA_DXT3 ||
192
+ pixelFormat === PixelFormat . RGBA_DXT5 ||
193
+ pixelFormat === PixelFormat . RGB_PVRTC_4BPPV1 ||
194
+ pixelFormat === PixelFormat . RGB_PVRTC_2BPPV1 ||
195
+ pixelFormat === PixelFormat . RGBA_PVRTC_4BPPV1 ||
196
+ pixelFormat === PixelFormat . RGBA_PVRTC_2BPPV1 ||
197
+ pixelFormat === PixelFormat . RGB_ETC1 ;
198
+ } ,
199
+
200
+ /**
201
+ * @private
202
+ */
203
+ isDXTFormat : function ( pixelFormat ) {
204
+ return pixelFormat === PixelFormat . RGB_DXT1 ||
205
+ pixelFormat === PixelFormat . RGBA_DXT1 ||
206
+ pixelFormat === PixelFormat . RGBA_DXT3 ||
207
+ pixelFormat === PixelFormat . RGBA_DXT5 ;
208
+ } ,
209
+
210
+ /**
211
+ * @private
212
+ */
213
+ isPVRTCFormat : function ( pixelFormat ) {
214
+ return pixelFormat === PixelFormat . RGB_PVRTC_4BPPV1 ||
215
+ pixelFormat === PixelFormat . RGB_PVRTC_2BPPV1 ||
216
+ pixelFormat === PixelFormat . RGBA_PVRTC_4BPPV1 ||
217
+ pixelFormat === PixelFormat . RGBA_PVRTC_2BPPV1 ;
218
+ } ,
219
+
220
+ /**
221
+ * @private
222
+ */
223
+ isETC1Format : function ( pixelFormat ) {
224
+ return pixelFormat === PixelFormat . RGB_ETC1 ;
225
+ } ,
226
+
227
+ /**
228
+ * @private
229
+ */
230
+ compressedTextureSize : function ( pixelFormat , width , height ) {
231
+ switch ( pixelFormat ) {
232
+ case PixelFormat . RGB_DXT1 :
233
+ case PixelFormat . RGBA_DXT1 :
234
+ case PixelFormat . RGB_ETC1 :
235
+ return Math . floor ( ( width + 3 ) / 4 ) * Math . floor ( ( height + 3 ) / 4 ) * 8 ;
236
+
237
+ case PixelFormat . RGBA_DXT3 :
238
+ case PixelFormat . RGBA_DXT5 :
239
+ return Math . floor ( ( width + 3 ) / 4 ) * Math . floor ( ( height + 3 ) / 4 ) * 16 ;
240
+
241
+ case PixelFormat . RGB_PVRTC_4BPPV1 :
242
+ case PixelFormat . RGBA_PVRTC_4BPPV1 :
243
+ return Math . floor ( ( Math . max ( width , 8 ) * Math . max ( height , 8 ) * 4 + 7 ) / 8 ) ;
244
+
245
+ case PixelFormat . RGB_PVRTC_2BPPV1 :
246
+ case PixelFormat . RGBA_PVRTC_2BPPV1 :
247
+ return Math . floor ( ( Math . max ( width , 16 ) * Math . max ( height , 8 ) * 2 + 7 ) / 8 ) ;
248
+
249
+ default :
250
+ return 0 ;
251
+ }
102
252
}
103
253
} ;
104
254
0 commit comments