|
12 | 12 | * @author JavaSaBr |
13 | 13 | */ |
14 | 14 | public enum GLSLType { |
15 | | - BOOL("bool"), |
16 | | - BOOL_VEC_2("bvec2"), |
17 | | - BOOL_VEC_3("bvec3"), |
18 | | - BOOL_VEC_4("bvec4"), |
19 | | - INT("int"), |
20 | | - INT_VEC_2("ivec2"), |
21 | | - INT_VEC_3("ivec3"), |
22 | | - INT_VEC_4("ivec4"), |
23 | | - UNSIGNED_INT("uint"), |
24 | | - UNSIGNED_INT_VEC_2("uvec2"), |
25 | | - UNSIGNED_INT_VEC_3("uvec3"), |
26 | | - UNSIGNED_INT_VEC_4("uvec4"), |
27 | | - FLOAT("float"), |
28 | | - VEC_2("vec2"), |
29 | | - VEC_3("vec3"), |
30 | | - VEC_4("vec4"), |
31 | | - MAT_2("mat2"), |
32 | | - MAT_3("mat3"), |
33 | | - MAT_4("mat4"), |
34 | | - SAMPLER_2D("sampler2D"), |
35 | | - SAMPLER_CUBE("samplerCube"); |
| 15 | + BOOL("bool", "Boolean"), |
| 16 | + BOOL_VEC_2("bvec2", "Boolean vector x 2"), |
| 17 | + BOOL_VEC_3("bvec3", "Boolean vector x 3"), |
| 18 | + BOOL_VEC_4("bvec4", "Boolean vector x 4"), |
| 19 | + INT("int", "Integer"), |
| 20 | + INT_VEC_2("ivec2", "Integer vector x 2"), |
| 21 | + INT_VEC_3("ivec3", "Integer vector x 3"), |
| 22 | + INT_VEC_4("ivec4", "Integer vector x 4"), |
| 23 | + UNSIGNED_INT("uint", "Unsigned integer"), |
| 24 | + UNSIGNED_INT_VEC_2("uvec2", "Unsigned integer vector x 2"), |
| 25 | + UNSIGNED_INT_VEC_3("uvec3", "Unsigned integer vector x 3"), |
| 26 | + UNSIGNED_INT_VEC_4("uvec4", "Unsigned integer vector x 4"), |
| 27 | + FLOAT("float", "Float"), |
| 28 | + VEC_2("vec2", "Float vector x 2"), |
| 29 | + VEC_3("vec3", "Float vector x 3"), |
| 30 | + VEC_4("vec4", "Float vector x 4"), |
| 31 | + MAT_2("mat2", "Matrix x 2"), |
| 32 | + MAT_3("mat3", "Matrix x 3"), |
| 33 | + MAT_4("mat4", "Matrix x 4"), |
| 34 | + SAMPLER_2D("sampler2D", "Texture 2D"), |
| 35 | + SAMPLER_CUBE("samplerCube", "Cube Texture"); |
36 | 36 |
|
37 | 37 | @NotNull |
38 | 38 | public static final GLSLType[] VALUES = values(); |
39 | 39 |
|
40 | 40 | @NotNull |
41 | 41 | private static final ObjectDictionary<String, GLSLType> RAW_TYPE_TO_ENUM = DictionaryFactory.newObjectDictionary(); |
42 | 42 |
|
| 43 | + @NotNull |
| 44 | + private static final ObjectDictionary<String, GLSLType> UI_NAME_TO_ENUM = DictionaryFactory.newObjectDictionary(); |
| 45 | + |
| 46 | + static { |
| 47 | + for (final GLSLType glslType : VALUES) { |
| 48 | + RAW_TYPE_TO_ENUM.put(glslType.getRawType(), glslType); |
| 49 | + UI_NAME_TO_ENUM.put(glslType.getUiName(), glslType); |
| 50 | + } |
| 51 | + } |
| 52 | + |
43 | 53 | /** |
44 | 54 | * Get the enum value for the raw type. |
45 | 55 | * |
46 | 56 | * @param rawType the raw type. |
47 | 57 | * @return the enum value. |
48 | 58 | */ |
49 | 59 | @FromAnyThread |
50 | | - public static @NotNull GLSLType of(@NotNull final String rawType) { |
| 60 | + public static @NotNull GLSLType ofRawType(@NotNull final String rawType) { |
51 | 61 | return notNull(RAW_TYPE_TO_ENUM.get(rawType)); |
52 | 62 | } |
53 | 63 |
|
54 | 64 | /** |
55 | | - * The type to use in shaders. |
| 65 | + * Get the enum value for the UI name. |
| 66 | + * |
| 67 | + * @param uiName the UI name. |
| 68 | + * @return the enum value. |
| 69 | + */ |
| 70 | + @FromAnyThread |
| 71 | + public static @NotNull GLSLType ofUIName(@NotNull final String uiName) { |
| 72 | + return notNull(RAW_TYPE_TO_ENUM.get(uiName)); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * The type to use in a shader. |
56 | 77 | */ |
57 | 78 | @NotNull |
58 | 79 | private String rawType; |
59 | 80 |
|
60 | | - GLSLType(@NotNull final String rawType) { |
| 81 | + /** |
| 82 | + * The name for UI. |
| 83 | + */ |
| 84 | + @NotNull |
| 85 | + private String uiName; |
| 86 | + |
| 87 | + GLSLType(@NotNull final String rawType, @NotNull final String uiName) { |
61 | 88 | this.rawType = rawType; |
| 89 | + this.uiName = uiName; |
62 | 90 | } |
63 | 91 |
|
64 | 92 | /** |
65 | | - * Get the type to use in shaders. |
| 93 | + * Get the type to use in a shader. |
66 | 94 | * |
67 | | - * @return the type to use in shaders. |
| 95 | + * @return the type to use in a shader. |
68 | 96 | */ |
69 | 97 | @FromAnyThread |
70 | 98 | public @NotNull String getRawType() { |
71 | 99 | return rawType; |
72 | 100 | } |
| 101 | + |
| 102 | + /** |
| 103 | + * Get the name for UI. |
| 104 | + * |
| 105 | + * @return the name for UI. |
| 106 | + */ |
| 107 | + @FromAnyThread |
| 108 | + public @NotNull String getUiName() { |
| 109 | + return uiName; |
| 110 | + } |
73 | 111 | } |
0 commit comments