Skip to content

Commit 4c01a25

Browse files
committed
updated GLSLType enum.
1 parent f031324 commit 4c01a25

File tree

1 file changed

+64
-26
lines changed

1 file changed

+64
-26
lines changed

src/main/java/com/ss/editor/util/GLSLType.java

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,100 @@
1212
* @author JavaSaBr
1313
*/
1414
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");
3636

3737
@NotNull
3838
public static final GLSLType[] VALUES = values();
3939

4040
@NotNull
4141
private static final ObjectDictionary<String, GLSLType> RAW_TYPE_TO_ENUM = DictionaryFactory.newObjectDictionary();
4242

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+
4353
/**
4454
* Get the enum value for the raw type.
4555
*
4656
* @param rawType the raw type.
4757
* @return the enum value.
4858
*/
4959
@FromAnyThread
50-
public static @NotNull GLSLType of(@NotNull final String rawType) {
60+
public static @NotNull GLSLType ofRawType(@NotNull final String rawType) {
5161
return notNull(RAW_TYPE_TO_ENUM.get(rawType));
5262
}
5363

5464
/**
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.
5677
*/
5778
@NotNull
5879
private String rawType;
5980

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) {
6188
this.rawType = rawType;
89+
this.uiName = uiName;
6290
}
6391

6492
/**
65-
* Get the type to use in shaders.
93+
* Get the type to use in a shader.
6694
*
67-
* @return the type to use in shaders.
95+
* @return the type to use in a shader.
6896
*/
6997
@FromAnyThread
7098
public @NotNull String getRawType() {
7199
return rawType;
72100
}
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+
}
73111
}

0 commit comments

Comments
 (0)