Skip to content

Commit 5193024

Browse files
authored
Merge pull request jMonkeyEngine#2519 from capdevon/capdevon-VarType
VarType: javadoc
2 parents 1f9d606 + 45e7c56 commit 5193024

1 file changed

Lines changed: 52 additions & 6 deletions

File tree

jme3-core/src/main/java/com/jme3/shader/VarType.java

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2024 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,9 @@
4545
import com.jme3.texture.TextureCubeMap;
4646
import com.jme3.texture.TextureImage;
4747

48+
/**
49+
* Enum representing various GLSL variable types and their corresponding Java types.
50+
*/
4851
public enum VarType {
4952

5053
Float("float", float.class, Float.class),
@@ -59,7 +62,7 @@ public enum VarType {
5962
Vector4Array(true, false, "vec4", Vector4f[].class),
6063

6164
Int("int", int.class, Integer.class),
62-
Boolean("bool", Boolean.class, boolean.class),
65+
Boolean("bool", boolean.class, Boolean.class),
6366

6467
Matrix3(true, false, "mat3", Matrix3f.class),
6568
Matrix4(true, false, "mat4", Matrix4f.class),
@@ -83,8 +86,14 @@ public enum VarType {
8386
private boolean textureType = false;
8487
private boolean imageType = false;
8588
private final String glslType;
86-
private Class<?>[] javaTypes;
89+
private final Class<?>[] javaTypes;
8790

91+
/**
92+
* Constructs a VarType with the specified GLSL type and corresponding Java types.
93+
*
94+
* @param glslType the GLSL type name(s)
95+
* @param javaTypes the Java classes mapped to this GLSL type
96+
*/
8897
VarType(String glslType, Class<?>... javaTypes) {
8998
this.glslType = glslType;
9099
if (javaTypes != null) {
@@ -94,6 +103,14 @@ public enum VarType {
94103
}
95104
}
96105

106+
/**
107+
* Constructs a VarType with additional flags for multi-data and texture types.
108+
*
109+
* @param multiData true if this type uses multiple data elements (e.g. arrays, matrices)
110+
* @param textureType true if this type represents a texture sampler
111+
* @param glslType the GLSL type name(s)
112+
* @param javaTypes the Java classes mapped to this GLSL type
113+
*/
97114
VarType(boolean multiData, boolean textureType, String glslType, Class<?>... javaTypes) {
98115
this.usesMultiData = multiData;
99116
this.textureType = textureType;
@@ -104,7 +121,16 @@ public enum VarType {
104121
this.javaTypes = new Class<?>[0];
105122
}
106123
}
107-
124+
125+
/**
126+
* Constructs a VarType with flags for multi-data, texture, and image types.
127+
*
128+
* @param multiData true if this type uses multiple data elements
129+
* @param textureType true if this type represents a texture sampler
130+
* @param imageType true if this type represents an image
131+
* @param glslType the GLSL type name(s)
132+
* @param javaTypes the Java classes mapped to this GLSL type
133+
*/
108134
VarType(boolean multiData, boolean textureType, boolean imageType, String glslType, Class<?>... javaTypes) {
109135
this(multiData, textureType, glslType, javaTypes);
110136
this.imageType = imageType;
@@ -127,25 +153,45 @@ public boolean isOfType(Object o) {
127153

128154
/**
129155
* Get the java types mapped to this VarType
130-
*
156+
*
131157
* @return an array of classes mapped to this VarType
132158
*/
133159
public Class<?>[] getJavaType() {
134160
return javaTypes;
135161
}
136162

163+
/**
164+
* Returns whether this VarType represents a texture sampler type.
165+
*
166+
* @return true if this is a texture type, false otherwise
167+
*/
137168
public boolean isTextureType() {
138169
return textureType;
139170
}
140-
171+
172+
/**
173+
* Returns whether this VarType represents an image type.
174+
*
175+
* @return true if this is an image type, false otherwise
176+
*/
141177
public boolean isImageType() {
142178
return imageType;
143179
}
144180

181+
/**
182+
* Returns whether this VarType uses multiple data elements (e.g. arrays or matrices).
183+
*
184+
* @return true if this type uses multiple data elements, false otherwise
185+
*/
145186
public boolean usesMultiData() {
146187
return usesMultiData;
147188
}
148189

190+
/**
191+
* Returns the GLSL type name(s) associated with this VarType.
192+
*
193+
* @return the GLSL type string (e.g. "float", "vec3", "sampler2D")
194+
*/
149195
public String getGlslType() {
150196
return glslType;
151197
}

0 commit comments

Comments
 (0)