UNPKG

1.15 kBJavaScriptView Raw
1let GL_TABLE = null;
2const GL_TO_GLSL_TYPES = {
3 FLOAT: "float",
4 FLOAT_VEC2: "vec2",
5 FLOAT_VEC3: "vec3",
6 FLOAT_VEC4: "vec4",
7 INT: "int",
8 INT_VEC2: "ivec2",
9 INT_VEC3: "ivec3",
10 INT_VEC4: "ivec4",
11 UNSIGNED_INT: "uint",
12 UNSIGNED_INT_VEC2: "uvec2",
13 UNSIGNED_INT_VEC3: "uvec3",
14 UNSIGNED_INT_VEC4: "uvec4",
15 BOOL: "bool",
16 BOOL_VEC2: "bvec2",
17 BOOL_VEC3: "bvec3",
18 BOOL_VEC4: "bvec4",
19 FLOAT_MAT2: "mat2",
20 FLOAT_MAT3: "mat3",
21 FLOAT_MAT4: "mat4",
22 SAMPLER_2D: "sampler2D",
23 INT_SAMPLER_2D: "sampler2D",
24 UNSIGNED_INT_SAMPLER_2D: "sampler2D",
25 SAMPLER_CUBE: "samplerCube",
26 INT_SAMPLER_CUBE: "samplerCube",
27 UNSIGNED_INT_SAMPLER_CUBE: "samplerCube",
28 SAMPLER_2D_ARRAY: "sampler2DArray",
29 INT_SAMPLER_2D_ARRAY: "sampler2DArray",
30 UNSIGNED_INT_SAMPLER_2D_ARRAY: "sampler2DArray"
31};
32function mapType(gl, type) {
33 if (!GL_TABLE) {
34 const typeNames = Object.keys(GL_TO_GLSL_TYPES);
35 GL_TABLE = {};
36 for (let i = 0; i < typeNames.length; ++i) {
37 const tn = typeNames[i];
38 GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];
39 }
40 }
41 return GL_TABLE[type];
42}
43
44export { mapType };
45//# sourceMappingURL=mapType.mjs.map