Skip to content

Commit fd070cf

Browse files
committed
remove dependency from GL renderer
1 parent cf47e21 commit fd070cf

3 files changed

Lines changed: 29 additions & 17 deletions

File tree

jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/DracoMeshCompressionExtensionLoader.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import com.jme3.asset.AssetLoadException;
5252
import com.jme3.plugins.json.JsonElement;
5353
import com.jme3.plugins.json.JsonObject;
54-
import com.jme3.renderer.opengl.GL;
5554
import com.jme3.scene.Mesh;
5655
import com.jme3.scene.VertexBuffer;
5756
import com.jme3.scene.VertexBuffer.Type;
@@ -216,15 +215,16 @@ private static DracoMesh readDracoMesh(GltfLoader loader, JsonElement extension)
216215
*/
217216
VertexBuffer createIndicesVertexBuffer(GltfLoader loader, int componentType, int indices[]) {
218217
Buffer data = null;
219-
if (componentType == GL.GL_UNSIGNED_BYTE) {
218+
if (componentType == GltfConstants.GL_UNSIGNED_BYTE) {
220219
data = createByteBuffer(indices);
221-
} else if (componentType == GL.GL_UNSIGNED_SHORT) {
220+
} else if (componentType == GltfConstants.GL_UNSIGNED_SHORT) {
222221
data = createShortBuffer(indices);
223-
} else if (componentType == GL.GL_UNSIGNED_INT) {
222+
} else if (componentType == GltfConstants.GL_UNSIGNED_INT) {
224223
data = BufferUtils.createIntBuffer(indices);
225224
} else {
226225
throw new AssetLoadException("The indices accessor must have a component type of "
227-
+ GL.GL_UNSIGNED_BYTE + ", " + GL.GL_UNSIGNED_SHORT + ", or " + GL.GL_UNSIGNED_INT
226+
+ GltfConstants.GL_UNSIGNED_BYTE + ", " + GltfConstants.GL_UNSIGNED_SHORT + ", or "
227+
+ GltfConstants.GL_UNSIGNED_INT
228228
+ ", but has " + componentType);
229229
}
230230
VertexBuffer vb = new VertexBuffer(VertexBuffer.Type.Index);
@@ -365,30 +365,31 @@ private static VertexBuffer createAttributeVertexBuffer(String attributeName, Js
365365
int componentCount = getAccessorComponentCount(accessor);
366366
Type bufferType = getVertexBufferType(attributeName);
367367

368-
if (componentType == GL.GL_BYTE || componentType == GL.GL_UNSIGNED_BYTE) {
368+
if (componentType == GltfConstants.GL_BYTE || componentType == GltfConstants.GL_UNSIGNED_BYTE) {
369369
ByteBuffer attributeData = readByteDracoAttribute(pointAttribute, indices, count, componentCount);
370370
VertexBuffer attributeVertexBuffer = createByteAttributeVertexBuffer(accessor, bufferType,
371371
attributeData);
372372
return attributeVertexBuffer;
373373
}
374-
if (componentType == GL.GL_SHORT || componentType == GL.GL_UNSIGNED_SHORT) {
374+
if (componentType == GltfConstants.GL_SHORT || componentType == GltfConstants.GL_UNSIGNED_SHORT) {
375375
ShortBuffer attributeData = readShortDracoAttribute(pointAttribute, indices, count,
376376
componentCount);
377377
VertexBuffer attributeVertexBuffer = createShortAttributeVertexBuffer(accessor, bufferType,
378378
attributeData);
379379
return attributeVertexBuffer;
380380
}
381-
if (componentType == GL.GL_FLOAT) {
381+
if (componentType == GltfConstants.GL_FLOAT) {
382382
FloatBuffer attributeData = readFloatDracoAttribute(pointAttribute, indices, count,
383383
componentCount);
384384
VertexBuffer attributeVertexBuffer = createFloatAttributeVertexBuffer(accessor, bufferType,
385385
attributeData);
386386
return attributeVertexBuffer;
387387
}
388388
throw new AssetLoadException(
389-
"The accessor for attribute " + attributeName + " must have a component type of " + GL.GL_BYTE
390-
+ ", " + GL.GL_UNSIGNED_BYTE + ", " + GL.GL_SHORT + ", " + GL.GL_UNSIGNED_SHORT + ", "
391-
+ "or " + GL.GL_FLOAT + ", but has " + componentType);
389+
"The accessor for attribute " + attributeName + " must have a component type of "
390+
+ GltfConstants.GL_BYTE + ", " + GltfConstants.GL_UNSIGNED_BYTE + ", "
391+
+ GltfConstants.GL_SHORT + ", " + GltfConstants.GL_UNSIGNED_SHORT + ", " + "or "
392+
+ GltfConstants.GL_FLOAT + ", but has " + componentType);
392393
}
393394

394395
/**
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.jme3.scene.plugins.gltf;
2+
3+
public class GltfConstants {
4+
public static final int GL_BYTE = 0x1400;
5+
public static final int GL_UNSIGNED_BYTE = 0x1401;
6+
public static final int GL_SHORT = 0x1402;
7+
public static final int GL_UNSIGNED_SHORT = 0x1403;
8+
public static final int GL_UNSIGNED_INT = 0x1405;
9+
public static final int GL_FLOAT = 0x1406;
10+
11+
}

jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ public static Mesh.Mode getMeshMode(Integer mode) {
105105

106106
public static VertexBuffer.Format getVertexBufferFormat(int componentType) {
107107
switch (componentType) {
108-
case GL.GL_BYTE:
108+
case GltfConstants.GL_BYTE:
109109
return VertexBuffer.Format.Byte;
110-
case GL.GL_UNSIGNED_BYTE:
110+
case GltfConstants.GL_UNSIGNED_BYTE:
111111
return VertexBuffer.Format.UnsignedByte;
112-
case GL.GL_SHORT:
112+
case GltfConstants.GL_SHORT:
113113
return VertexBuffer.Format.Short;
114-
case GL.GL_UNSIGNED_SHORT:
114+
case GltfConstants.GL_UNSIGNED_SHORT:
115115
return VertexBuffer.Format.UnsignedShort;
116-
case GL.GL_UNSIGNED_INT:
116+
case GltfConstants.GL_UNSIGNED_INT:
117117
return VertexBuffer.Format.UnsignedInt;
118-
case GL.GL_FLOAT:
118+
case GltfConstants.GL_FLOAT:
119119
return VertexBuffer.Format.Float;
120120
default:
121121
throw new AssetLoadException("Illegal component type: " + componentType);

0 commit comments

Comments
 (0)