Skip to content

Commit 7298a83

Browse files
authored
Merge pull request #2 from bilgorajskim/feature/texture-internal-format
Add more texture formats
2 parents 38ccba8 + 675072a commit 7298a83

File tree

3 files changed

+101
-23
lines changed

3 files changed

+101
-23
lines changed

src/constants.js

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,58 @@ export var RedFormat = 1028;
9898

9999
export var RedIntegerFormat = 1029;
100100
export var R8Format = 1030;
101-
export var R8UIFormat = 1031;
102-
export var R16FFormat = 1032;
103-
export var R32FFormat = 1033;
104-
export var RGFormat = 1034;
105-
export var RGIntegerFormat = 1035;
106-
export var RGBIntegerFormat = 1036;
107-
export var RGBAIntegerFormat = 1037;
108-
export var RG8Format = 1038;
109-
export var RG8UIFormat = 1039;
110-
export var RG16FFormat = 1040;
111-
export var RG32FFormat = 1041;
112-
export var RGB8Format = 1042;
113-
export var RGB8UIFormat = 1042;
114-
export var RGB16FFormat = 1043;
115-
export var RGB32FFormat = 1044;
116-
export var RGBA8Format = 1045;
117-
export var RGBA8UIFormat = 1046;
118-
export var RGBA16FFormat = 1047;
119-
export var RGBA32FFormat = 1048;
101+
export var R8_SNORMFormat = 1031;
102+
export var R8IFormat = 1032;
103+
export var R8UIFormat = 1033;
104+
export var R16IFormat = 1034;
105+
export var R16UIFormat = 1035;
106+
export var R16FFormat = 1036;
107+
export var R32IFormat = 1037;
108+
export var R32UIFormat = 1038;
109+
export var R32FFormat = 1039;
110+
export var RGFormat = 1040;
111+
export var RGIntegerFormat = 1041;
112+
export var RGBIntegerFormat = 1042;
113+
export var RGBAIntegerFormat = 1043;
114+
export var RG8Format = 1044;
115+
export var RG8_SNORMFormat = 1045;
116+
export var RG8IFormat = 1046;
117+
export var RG8UIFormat = 1047;
118+
export var RG16IFormat = 1048;
119+
export var RG16UIFormat = 1049;
120+
export var RG16FFormat = 1050;
121+
export var RG32IFormat = 1051;
122+
export var RG32UIFormat = 1052;
123+
export var RG32FFormat = 1053;
124+
export var RGB565Format = 1054;
125+
export var RGB8Format = 1055;
126+
export var RGB8_SNORMFormat = 1056;
127+
export var RGB8IFormat = 1057;
128+
export var RGB8UIFormat = 1058;
129+
export var RGB9_E5Format = 1059;
130+
export var RGB16IFormat = 1060;
131+
export var RGB16UIFormat = 1061;
132+
export var RGB16FFormat = 1062;
133+
export var RGB32IFormat = 1063;
134+
export var RGB32UIFormat = 1064;
135+
export var RGB32FFormat = 1065;
136+
export var SRGB8Format = 1066;
137+
export var R11F_G11F_B10FFormat = 1067;
138+
export var RGBA4Format = 1068;
139+
export var RGBA8Format = 1069;
140+
export var RGBA8_SNORMFormat = 1070;
141+
export var RGBA8IFormat = 1071;
142+
export var RGBA8UIFormat = 1072;
143+
export var RGBA16IFormat = 1073;
144+
export var RGBA16UIFormat = 1074;
145+
export var RGBA16FFormat = 1075;
146+
export var RGBA32IFormat = 1076;
147+
export var RGBA32UIFormat = 1077;
148+
export var RGBA32FFormat = 1078;
149+
export var RGB5_A1Format = 1079;
150+
export var RGB10_A2Format = 1080;
151+
export var RGB10_A2UIFormat = 1081;
152+
export var SRGB8_ALPHA8Format = 1082;
120153

121154
export var RGB_S3TC_DXT1_Format = 33776;
122155
export var RGBA_S3TC_DXT1_Format = 33777;

src/renderers/webgl/WebGLUniforms.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,19 @@ function getSingularSetter( type ) {
475475
case 0x8b5b: return setValue3fm; // _MAT3
476476
case 0x8b5c: return setValue4fm; // _MAT4
477477

478-
case 0x8b5e: case 0x8d66: return setValueT1; // SAMPLER_2D, SAMPLER_EXTERNAL_OES
479-
case 0x8B5F: return setValueT3D1; // SAMPLER_3D
480-
case 0x8b60: return setValueT6; // SAMPLER_CUBE
478+
case 0x8b5e: // SAMPLER_2D
479+
case 0x8d66: // SAMPLER_EXTERNAL_OES
480+
case 0x8dca: // INT_SAMPLER_2D
481+
case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D
482+
return setValueT1;
483+
case 0x8b5f: // SAMPLER_3D
484+
case 0x8dcb: // INT_SAMPLER_3D
485+
case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
486+
return setValueT3D1;
487+
case 0x8b60: // SAMPLER_CUBE
488+
case 0x8dcc: // INT_SAMPLER_CUBE
489+
case 0x8dd4: // UNSIGNED_SAMPLER_CUBE
490+
return setValueT6;
481491

482492
case 0x1404: case 0x8b56: return setValue1i; // INT, BOOL
483493
case 0x8b53: case 0x8b57: return setValue2iv; // _VEC2

src/renderers/webgl/WebGLUtils.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @author thespite / http://www.twitter.com/thespite
33
*/
44

5-
import { MaxEquation, MinEquation, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, SrcAlphaSaturateFactor, OneMinusDstColorFactor, DstColorFactor, OneMinusDstAlphaFactor, DstAlphaFactor, OneMinusSrcAlphaFactor, SrcAlphaFactor, OneMinusSrcColorFactor, SrcColorFactor, OneFactor, ZeroFactor, ReverseSubtractEquation, SubtractEquation, AddEquation, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, RGBFormat, AlphaFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestFilter, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, RedIntegerFormat, R8Format, R8UIFormat, R16FFormat, R32FFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, RG8Format, RG8UIFormat, RG16FFormat, RG32FFormat, RGB8Format, RGB8UIFormat, RGB16FFormat, RGB32FFormat, RGBA8Format, RGBA8UIFormat, RGBA16FFormat, RGBA32FFormat } from '../../constants.js';
5+
import { MaxEquation, MinEquation, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, SrcAlphaSaturateFactor, OneMinusDstColorFactor, DstColorFactor, OneMinusDstAlphaFactor, DstAlphaFactor, OneMinusSrcAlphaFactor, SrcAlphaFactor, OneMinusSrcColorFactor, SrcColorFactor, OneFactor, ZeroFactor, ReverseSubtractEquation, SubtractEquation, AddEquation, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RGBAFormat, RGBAIntegerFormat, RGBFormat, RGBIntegerFormat, AlphaFormat, RedFormat, RedIntegerFormat, R8Format, R8_SNORMFormat, R8IFormat, R8UIFormat, R16IFormat, R16UIFormat, R16FFormat, R32IFormat, R32UIFormat, R32FFormat, RGFormat, RGIntegerFormat, RG8Format, RG8_SNORMFormat, RG8IFormat, RG8UIFormat, RG16IFormat, RG16UIFormat, RG16FFormat, RG32IFormat, RG32UIFormat, RG32FFormat, RGB565Format, RGB8Format, RGB8_SNORMFormat, RGB8IFormat, RGB8UIFormat, RGB9_E5Format, RGB16IFormat, RGB16UIFormat, RGB16FFormat, RGB32IFormat, RGB32UIFormat, RGB32FFormat, SRGB8Format, R11F_G11F_B10FFormat, RGBA4Format, RGBA8Format, RGBA8_SNORMFormat, RGBA8IFormat, RGBA8UIFormat, RGBA16IFormat, RGBA16UIFormat, RGBA16FFormat, RGBA32IFormat, RGBA32UIFormat, RGBA32FFormat, RGB5_A1Format, RGB10_A2Format, RGB10_A2UIFormat, SRGB8_ALPHA8Format, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestFilter, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js';
66

77
function WebGLUtils( gl, extensions, capabilities ) {
88

@@ -51,37 +51,72 @@ function WebGLUtils( gl, extensions, capabilities ) {
5151
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
5252
if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
5353
if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
54+
5455
if ( p === RedFormat ) return gl.RED;
5556
if ( p === RedIntegerFormat ) return gl.RED_INTEGER;
5657

58+
5759
if ( p === R8Format ) return gl.R8;
60+
if ( p === R8_SNORMFormat ) return gl.R8_SNORM;
61+
if ( p === R8IFormat ) return gl.R8I;
5862
if ( p === R8UIFormat ) return gl.R8UI;
63+
if ( p === R16IFormat ) return gl.R16I;
64+
if ( p === R16UIFormat ) return gl.R16UI;
5965
if ( p === R16FFormat ) return gl.R16F;
66+
if ( p === R32IFormat ) return gl.R32I;
67+
if ( p === R32UIFormat ) return gl.R32UI;
6068
if ( p === R32FFormat ) return gl.R32F;
6169

6270
if ( p === RGFormat ) return gl.RG;
6371
if ( p === RGIntegerFormat ) return gl.RG_INTEGER;
6472

6573
if ( p === RG8Format ) return gl.RG8;
74+
if ( p === RG8_SNORMFormat ) return gl.RG8_SNORM;
75+
if ( p === RG8IFormat ) return gl.RG8I;
6676
if ( p === RG8UIFormat ) return gl.RG8UI;
77+
if ( p === RG16IFormat ) return gl.RG16I;
78+
if ( p === RG16UIFormat ) return gl.RG16UI;
6779
if ( p === RG16FFormat ) return gl.RG16F;
80+
if ( p === RG32IFormat ) return gl.RG32I;
81+
if ( p === RG32UIFormat ) return gl.RG32UI;
6882
if ( p === RG32FFormat ) return gl.RG32F;
6983

7084
if ( p === RGBFormat ) return gl.RGB;
7185
if ( p === RGBIntegerFormat ) return gl.RGB_INTEGER;
7286

87+
if ( p === RGB565Format ) return gl.RGB565;
7388
if ( p === RGB8Format ) return gl.RGB8;
89+
if ( p === RGB8_SNORMFormat ) return gl.RGB8_SNORM;
90+
if ( p === RGB8IFormat ) return gl.RGB8I;
7491
if ( p === RGB8UIFormat ) return gl.RGB8UI;
92+
if ( p === RGB9_E5Format ) return gl.RGB9_E5;
93+
if ( p === RGB16IFormat ) return gl.RGB16I;
94+
if ( p === RGB16UIFormat ) return gl.RGB16UI;
7595
if ( p === RGB16FFormat ) return gl.RGB16F;
96+
if ( p === RGB32IFormat ) return gl.RGB32I;
97+
if ( p === RGB32UIFormat ) return gl.RGB32UI;
7698
if ( p === RGB32FFormat ) return gl.RGB32F;
99+
if ( p === SRGB8Format ) return gl.SRGB8;
100+
if ( p === R11F_G11F_B10FFormat ) return gl.R11F_G11F_B10F;
77101

78102
if ( p === RGBAFormat ) return gl.RGBA;
79103
if ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;
80104

105+
if ( p === RGBA4Format ) return gl.RGBA4;
81106
if ( p === RGBA8Format ) return gl.RGBA8;
107+
if ( p === RGBA8_SNORMFormat ) return gl.RGBA8_SNORM;
108+
if ( p === RGBA8IFormat ) return gl.RGBA8I;
82109
if ( p === RGBA8UIFormat ) return gl.RGBA8UI;
110+
if ( p === RGBA16IFormat ) return gl.RGBA16I;
111+
if ( p === RGBA16UIFormat ) return gl.RGBA16UI;
83112
if ( p === RGBA16FFormat ) return gl.RGBA16F;
113+
if ( p === RGBA32IFormat ) return gl.RGBA32I;
114+
if ( p === RGBA32UIFormat ) return gl.RGBA32UI;
84115
if ( p === RGBA32FFormat ) return gl.RGBA32F;
116+
if ( p === RGB5_A1Format ) return gl.RGB5_A1;
117+
if ( p === RGB10_A2Format ) return gl.RGB10_A2;
118+
if ( p === RGB10_A2UIFormat ) return gl.RGB10_A2UI;
119+
if ( p === SRGB8_ALPHA8Format ) return gl.SRGB8_ALPHA8;
85120

86121
if ( p === AddEquation ) return gl.FUNC_ADD;
87122
if ( p === SubtractEquation ) return gl.FUNC_SUBTRACT;

0 commit comments

Comments
 (0)