|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * Copyright (c) 2009-2024 jMonkeyEngine
|
|
|
|
|
|
+ * Copyright (c) 2009-2025 jMonkeyEngine
|
|
* All rights reserved.
|
|
* All rights reserved.
|
|
*
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -45,6 +45,9 @@ import com.jme3.texture.TextureArray;
|
|
import com.jme3.texture.TextureCubeMap;
|
|
import com.jme3.texture.TextureCubeMap;
|
|
import com.jme3.texture.TextureImage;
|
|
import com.jme3.texture.TextureImage;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * Enum representing various GLSL variable types and their corresponding Java types.
|
|
|
|
+ */
|
|
public enum VarType {
|
|
public enum VarType {
|
|
|
|
|
|
Float("float", float.class, Float.class),
|
|
Float("float", float.class, Float.class),
|
|
@@ -59,7 +62,7 @@ public enum VarType {
|
|
Vector4Array(true, false, "vec4", Vector4f[].class),
|
|
Vector4Array(true, false, "vec4", Vector4f[].class),
|
|
|
|
|
|
Int("int", int.class, Integer.class),
|
|
Int("int", int.class, Integer.class),
|
|
- Boolean("bool", Boolean.class, boolean.class),
|
|
|
|
|
|
+ Boolean("bool", boolean.class, Boolean.class),
|
|
|
|
|
|
Matrix3(true, false, "mat3", Matrix3f.class),
|
|
Matrix3(true, false, "mat3", Matrix3f.class),
|
|
Matrix4(true, false, "mat4", Matrix4f.class),
|
|
Matrix4(true, false, "mat4", Matrix4f.class),
|
|
@@ -83,8 +86,14 @@ public enum VarType {
|
|
private boolean textureType = false;
|
|
private boolean textureType = false;
|
|
private boolean imageType = false;
|
|
private boolean imageType = false;
|
|
private final String glslType;
|
|
private final String glslType;
|
|
- private Class<?>[] javaTypes;
|
|
|
|
|
|
+ private final Class<?>[] javaTypes;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Constructs a VarType with the specified GLSL type and corresponding Java types.
|
|
|
|
+ *
|
|
|
|
+ * @param glslType the GLSL type name(s)
|
|
|
|
+ * @param javaTypes the Java classes mapped to this GLSL type
|
|
|
|
+ */
|
|
VarType(String glslType, Class<?>... javaTypes) {
|
|
VarType(String glslType, Class<?>... javaTypes) {
|
|
this.glslType = glslType;
|
|
this.glslType = glslType;
|
|
if (javaTypes != null) {
|
|
if (javaTypes != null) {
|
|
@@ -94,6 +103,14 @@ public enum VarType {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Constructs a VarType with additional flags for multi-data and texture types.
|
|
|
|
+ *
|
|
|
|
+ * @param multiData true if this type uses multiple data elements (e.g. arrays, matrices)
|
|
|
|
+ * @param textureType true if this type represents a texture sampler
|
|
|
|
+ * @param glslType the GLSL type name(s)
|
|
|
|
+ * @param javaTypes the Java classes mapped to this GLSL type
|
|
|
|
+ */
|
|
VarType(boolean multiData, boolean textureType, String glslType, Class<?>... javaTypes) {
|
|
VarType(boolean multiData, boolean textureType, String glslType, Class<?>... javaTypes) {
|
|
this.usesMultiData = multiData;
|
|
this.usesMultiData = multiData;
|
|
this.textureType = textureType;
|
|
this.textureType = textureType;
|
|
@@ -104,7 +121,16 @@ public enum VarType {
|
|
this.javaTypes = new Class<?>[0];
|
|
this.javaTypes = new Class<?>[0];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Constructs a VarType with flags for multi-data, texture, and image types.
|
|
|
|
+ *
|
|
|
|
+ * @param multiData true if this type uses multiple data elements
|
|
|
|
+ * @param textureType true if this type represents a texture sampler
|
|
|
|
+ * @param imageType true if this type represents an image
|
|
|
|
+ * @param glslType the GLSL type name(s)
|
|
|
|
+ * @param javaTypes the Java classes mapped to this GLSL type
|
|
|
|
+ */
|
|
VarType(boolean multiData, boolean textureType, boolean imageType, String glslType, Class<?>... javaTypes) {
|
|
VarType(boolean multiData, boolean textureType, boolean imageType, String glslType, Class<?>... javaTypes) {
|
|
this(multiData, textureType, glslType, javaTypes);
|
|
this(multiData, textureType, glslType, javaTypes);
|
|
this.imageType = imageType;
|
|
this.imageType = imageType;
|
|
@@ -127,25 +153,45 @@ public enum VarType {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the java types mapped to this VarType
|
|
* Get the java types mapped to this VarType
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return an array of classes mapped to this VarType
|
|
* @return an array of classes mapped to this VarType
|
|
*/
|
|
*/
|
|
public Class<?>[] getJavaType() {
|
|
public Class<?>[] getJavaType() {
|
|
return javaTypes;
|
|
return javaTypes;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns whether this VarType represents a texture sampler type.
|
|
|
|
+ *
|
|
|
|
+ * @return true if this is a texture type, false otherwise
|
|
|
|
+ */
|
|
public boolean isTextureType() {
|
|
public boolean isTextureType() {
|
|
return textureType;
|
|
return textureType;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns whether this VarType represents an image type.
|
|
|
|
+ *
|
|
|
|
+ * @return true if this is an image type, false otherwise
|
|
|
|
+ */
|
|
public boolean isImageType() {
|
|
public boolean isImageType() {
|
|
return imageType;
|
|
return imageType;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns whether this VarType uses multiple data elements (e.g. arrays or matrices).
|
|
|
|
+ *
|
|
|
|
+ * @return true if this type uses multiple data elements, false otherwise
|
|
|
|
+ */
|
|
public boolean usesMultiData() {
|
|
public boolean usesMultiData() {
|
|
return usesMultiData;
|
|
return usesMultiData;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns the GLSL type name(s) associated with this VarType.
|
|
|
|
+ *
|
|
|
|
+ * @return the GLSL type string (e.g. "float", "vec3", "sampler2D")
|
|
|
|
+ */
|
|
public String getGlslType() {
|
|
public String getGlslType() {
|
|
return glslType;
|
|
return glslType;
|
|
}
|
|
}
|