aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-core/src
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2021-08-30 20:43:08 +0200
committerJulien Gouesse <[email protected]>2021-08-30 20:43:08 +0200
commit12e6dd7dcbad20ef0bd573d4b44679d802fa2fdc (patch)
treecff8136985c0f7c793ce7e12b29bfda2098358d4 /ardor3d-core/src
parent6eb68ea594195f5032222ac151570aa63bdedf1f (diff)
Removes the misleading VBO interleaved data mode
Diffstat (limited to 'ardor3d-core/src')
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java45
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/renderer/Renderer.java9
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java55
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java105
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/DataMode.java11
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java3
6 files changed, 30 insertions, 198 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
index 18f1347..ba0021a 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/AbstractRenderer.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -12,7 +12,6 @@ package com.ardor3d.renderer;
import java.nio.ByteBuffer;
import java.util.EnumMap;
-import java.util.List;
import com.ardor3d.image.ImageDataFormat;
import com.ardor3d.image.PixelDataType;
@@ -22,9 +21,7 @@ import com.ardor3d.math.type.ReadOnlyColorRGBA;
import com.ardor3d.renderer.queue.RenderQueue;
import com.ardor3d.renderer.state.RenderState;
import com.ardor3d.renderer.state.RenderState.StateType;
-import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.renderer.state.record.RendererRecord;
-import com.ardor3d.scenegraph.FloatBufferData;
import com.ardor3d.util.Constants;
import com.ardor3d.util.stat.StatCollector;
import com.ardor3d.util.stat.StatType;
@@ -122,46 +119,6 @@ public abstract class AbstractRenderer implements Renderer {
}
}
- protected int getTotalInterleavedSize(final RenderContext context, final FloatBufferData vertexCoords,
- final FloatBufferData normalCoords, final FloatBufferData colorCoords,
- final List<FloatBufferData> textureCoords) {
- final ContextCapabilities caps = context.getCapabilities();
-
- int bufferSizeBytes = 0;
- if (normalCoords != null) {
- bufferSizeBytes += normalCoords.getBufferLimit() * 4;
- }
- if (colorCoords != null) {
- bufferSizeBytes += colorCoords.getBufferLimit() * 4;
- }
- if (textureCoords != null) {
- final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture);
- if (ts != null) {
- final int max = caps.isMultitextureSupported() ? Math.min(caps.getNumberOfFragmentTexCoordUnits(),
- TextureState.MAX_TEXTURES) : 1;
- boolean exists;
- for (int i = 0; i < max; i++) {
- exists = i < textureCoords.size() && textureCoords.get(i) != null
- && i <= ts.getMaxTextureIndexUsed();
-
- if (!exists) {
- continue;
- }
-
- final FloatBufferData textureBufferData = textureCoords.get(i);
- if (textureBufferData != null) {
- bufferSizeBytes += textureBufferData.getBufferLimit() * 4;
- }
- }
- }
- }
- if (vertexCoords != null) {
- bufferSizeBytes += vertexCoords.getBufferLimit() * 4;
- }
-
- return bufferSizeBytes;
- }
-
public int getStencilClearValue() {
return _stencilClearValue;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/Renderer.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/Renderer.java
index 92e18e9..aba299d 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/renderer/Renderer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/Renderer.java
@@ -403,7 +403,7 @@ public interface Renderer {
*/
void undoTransforms(ReadOnlyTransform transform);
- // TODO: Arrays
+ // Arrays
void setupVertexData(FloatBufferData vertexCoords);
void setupNormalData(FloatBufferData normalCoords);
@@ -424,7 +424,7 @@ public interface Renderer {
void applyDefaultColor(ReadOnlyColorRGBA defaultColor);
- // TODO: VBO
+ // VBO
void setupVertexDataVBO(FloatBufferData vertexCoords);
void setupNormalDataVBO(FloatBufferData normalCoords);
@@ -435,10 +435,7 @@ public interface Renderer {
void setupTextureDataVBO(List<FloatBufferData> textureCoords);
- void setupInterleavedDataVBO(FloatBufferData interleaved, FloatBufferData vertexCoords,
- FloatBufferData normalCoords, FloatBufferData colorCoords, List<FloatBufferData> textureCoords);
-
- // TODO: Display List
+ // Display List
void renderDisplayList(int displayListID);
void setProjectionMatrix(FloatBuffer matrix);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
index bb67fac..46bc423 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java
@@ -267,8 +267,7 @@ public class Mesh extends Spatial implements Renderable, Pickable {
}
}
- final boolean useVBO = (getSceneHints().getDataMode() == DataMode.VBO
- || getSceneHints().getDataMode() == DataMode.VBOInterleaved) && caps.isVBOSupported();
+ final boolean useVBO = getSceneHints().getDataMode() == DataMode.VBO && caps.isVBOSupported();
if (instancing == null) {
final boolean transformed = renderer.doTransforms(_worldTransform);
@@ -351,44 +350,30 @@ public class Mesh extends Spatial implements Renderable, Pickable {
}
protected void renderVBO(final Renderer renderer, final MeshData meshData, final int primcount) {
- if (getSceneHints().getDataMode() == DataMode.VBOInterleaved) {
- if (meshData.getColorCoords() == null) {
- renderer.applyDefaultColor(_defaultColor);
- }
- renderer.applyNormalsMode(getSceneHints().getNormalsMode(), _worldTransform);
- // Make sure we have a FBD to hold our id.
- if (meshData.getInterleavedData() == null) {
- final FloatBufferData interleaved = new FloatBufferData(FloatBuffer.allocate(0), 1);
- meshData.setInterleavedData(interleaved);
- }
- renderer.setupInterleavedDataVBO(meshData.getInterleavedData(), meshData.getVertexCoords(),
- meshData.getNormalCoords(), meshData.getColorCoords(), meshData.getTextureCoords());
+ if (RENDER_VERTEX_ONLY) {
+ renderer.applyNormalsMode(NormalsMode.Off, null);
+ renderer.setupNormalDataVBO(null);
+ renderer.applyDefaultColor(null);
+ renderer.setupColorDataVBO(null);
+ renderer.setupTextureDataVBO(null);
} else {
- if (RENDER_VERTEX_ONLY) {
- renderer.applyNormalsMode(NormalsMode.Off, null);
- renderer.setupNormalDataVBO(null);
- renderer.applyDefaultColor(null);
- renderer.setupColorDataVBO(null);
- renderer.setupTextureDataVBO(null);
+ renderer.applyNormalsMode(getSceneHints().getNormalsMode(), _worldTransform);
+ if (getSceneHints().getNormalsMode() != NormalsMode.Off) {
+ renderer.setupNormalDataVBO(meshData.getNormalCoords());
} else {
- renderer.applyNormalsMode(getSceneHints().getNormalsMode(), _worldTransform);
- if (getSceneHints().getNormalsMode() != NormalsMode.Off) {
- renderer.setupNormalDataVBO(meshData.getNormalCoords());
- } else {
- renderer.setupNormalDataVBO(null);
- }
-
- if (meshData.getColorCoords() != null) {
- renderer.setupColorDataVBO(meshData.getColorCoords());
- } else {
- renderer.applyDefaultColor(_defaultColor);
- renderer.setupColorDataVBO(null);
- }
+ renderer.setupNormalDataVBO(null);
+ }
- renderer.setupTextureDataVBO(meshData.getTextureCoords());
+ if (meshData.getColorCoords() != null) {
+ renderer.setupColorDataVBO(meshData.getColorCoords());
+ } else {
+ renderer.applyDefaultColor(_defaultColor);
+ renderer.setupColorDataVBO(null);
}
- renderer.setupVertexDataVBO(meshData.getVertexCoords());
+
+ renderer.setupTextureDataVBO(meshData.getTextureCoords());
}
+ renderer.setupVertexDataVBO(meshData.getVertexCoords());
if (meshData.getIndices() != null) {
// TODO: Maybe ask for the IndexBuffer's dynamic/static type and fall back to arrays for indices?
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
index 2b3785b..695f3fa 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java
@@ -18,8 +18,6 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
import java.util.logging.Logger;
import com.ardor3d.math.MathUtils;
@@ -28,7 +26,6 @@ import com.ardor3d.math.Transform;
import com.ardor3d.math.Vector2;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.IndexMode;
-import com.ardor3d.renderer.RenderContext;
import com.ardor3d.util.export.InputCapsule;
import com.ardor3d.util.export.OutputCapsule;
import com.ardor3d.util.export.Savable;
@@ -42,9 +39,6 @@ public class MeshData implements Savable {
/** The Constant logger. */
private static final Logger logger = Logger.getLogger(MeshData.class.getName());
- /** A cache of ids for interleaved use. */
- private transient Map<Object, Integer> _vboIdCache = null;
-
/** Number of vertices represented by this data. */
protected int _vertexCount;
@@ -59,9 +53,6 @@ public class MeshData implements Savable {
protected FloatBufferData _tangentCoords;
protected List<FloatBufferData> _textureCoords = new ArrayList<>(1);
- /** Interleaved data (for VBO id use). */
- protected FloatBufferData _interleaved;
-
/** Index data. */
protected IndexBufferData<?> _indexBuffer;
protected int[] _indexLengths;
@@ -102,7 +93,6 @@ public class MeshData implements Savable {
} else {
setVertexCoords(new FloatBufferData(vertexBuffer, 3));
}
- refreshInterleaved();
}
/**
@@ -114,12 +104,6 @@ public class MeshData implements Savable {
return _vertexCoords;
}
- private void refreshInterleaved() {
- if (_interleaved != null) {
- _interleaved.setNeedsRefresh(true);
- }
- }
-
/**
* Sets the vertex coords.
*
@@ -129,7 +113,6 @@ public class MeshData implements Savable {
public void setVertexCoords(final FloatBufferData bufferData) {
_vertexCoords = bufferData;
updateVertexCount();
- refreshInterleaved();
}
/**
@@ -156,7 +139,6 @@ public class MeshData implements Savable {
} else {
_normalCoords = new FloatBufferData(normalBuffer, 3);
}
- refreshInterleaved();
}
/**
@@ -176,7 +158,6 @@ public class MeshData implements Savable {
*/
public void setNormalCoords(final FloatBufferData bufferData) {
_normalCoords = bufferData;
- refreshInterleaved();
}
/**
@@ -203,7 +184,6 @@ public class MeshData implements Savable {
} else {
_colorCoords = new FloatBufferData(colorBuffer, 4);
}
- refreshInterleaved();
}
/**
@@ -223,7 +203,6 @@ public class MeshData implements Savable {
*/
public void setColorCoords(final FloatBufferData bufferData) {
_colorCoords = bufferData;
- refreshInterleaved();
}
/**
@@ -354,7 +333,6 @@ public class MeshData implements Savable {
} else if (index < _textureCoords.size()) {
_textureCoords.set(index, null);
}
- refreshInterleaved();
}
/**
@@ -389,7 +367,6 @@ public class MeshData implements Savable {
*/
public void setTextureCoords(final List<FloatBufferData> textureCoords) {
_textureCoords = textureCoords;
- refreshInterleaved();
}
/**
@@ -405,39 +382,6 @@ public class MeshData implements Savable {
_textureCoords.add(null);
}
_textureCoords.set(index, textureCoords);
- refreshInterleaved();
- }
-
- /**
- * Retrieves the interleaved buffer, if set or created through packInterleaved.
- *
- * @return the interleaved buffer
- */
- public FloatBuffer getInterleavedBuffer() {
- if (_interleaved == null) {
- return null;
- }
- return _interleaved.getBuffer();
- }
-
- /**
- * Gets the interleaved data.
- *
- * @return the interleaved data
- */
- public FloatBufferData getInterleavedData() {
- return _interleaved;
- }
-
- /**
- * Sets the interleaved data.
- *
- * @param interleavedData
- * the interleaved data
- */
- public void setInterleavedData(final FloatBufferData interleavedData) {
- _interleaved = interleavedData;
- refreshInterleaved();
}
/**
@@ -591,7 +535,6 @@ public class MeshData implements Savable {
_indexBuffer = new IntBufferData(indices);
}
updatePrimitiveCounts();
- refreshInterleaved();
}
/**
@@ -607,7 +550,6 @@ public class MeshData implements Savable {
_indexBuffer = new ShortBufferData(indices);
}
updatePrimitiveCounts();
- refreshInterleaved();
}
/**
@@ -623,7 +565,6 @@ public class MeshData implements Savable {
_indexBuffer = new ByteBufferData(indices);
}
updatePrimitiveCounts();
- refreshInterleaved();
}
/**
@@ -644,7 +585,6 @@ public class MeshData implements Savable {
public void setIndices(final IndexBufferData<?> bufferData) {
_indexBuffer = bufferData;
updatePrimitiveCounts();
- refreshInterleaved();
}
/**
@@ -667,7 +607,6 @@ public class MeshData implements Savable {
public void setIndexMode(final IndexMode indexMode) {
_indexModes[0] = indexMode;
updatePrimitiveCounts();
- refreshInterleaved();
}
/**
@@ -688,7 +627,6 @@ public class MeshData implements Savable {
public void setIndexLengths(final int[] indexLengths) {
_indexLengths = indexLengths;
updatePrimitiveCounts();
- refreshInterleaved();
}
/**
@@ -724,7 +662,6 @@ public class MeshData implements Savable {
public void setIndexModes(final IndexMode[] indexModes) {
_indexModes = indexModes;
updatePrimitiveCounts();
- refreshInterleaved();
}
/**
@@ -892,7 +829,7 @@ public class MeshData implements Savable {
}
return result;
}
-
+
/**
* Gets the normals of the primitive.
*
@@ -912,7 +849,8 @@ public class MeshData implements Savable {
} else {
final int count = getPrimitiveCount(section);
if (primitiveIndex >= count || primitiveIndex < 0) {
- throw new IndexOutOfBoundsException("Invalid primitiveIndex '" + primitiveIndex + "'. Count is " + count);
+ throw new IndexOutOfBoundsException(
+ "Invalid primitiveIndex '" + primitiveIndex + "'. Count is " + count);
}
final IndexMode mode = getIndexMode(section);
final int rSize = mode.getVertexCount();
@@ -1219,41 +1157,6 @@ public class MeshData implements Savable {
}
- /**
- * @param glContext
- * the object representing the OpenGL context a vbo belongs to. See
- * {@link RenderContext#getGlContextRep()}
- * @return the vbo id of a vbo in the given context. If the vbo is not found in the given context, 0 is returned.
- */
- public int getVBOInterleavedID(final Object glContext) {
- if (_vboIdCache != null && _vboIdCache.containsKey(glContext)) {
- return _vboIdCache.get(glContext);
- }
- return 0;
- }
-
- /**
- * Sets the id for a vbo based on interleaving this MeshData's buffer, in regards to the given OpenGL context.
- *
- * @param glContext
- * the object representing the OpenGL context a vbo belongs to. See
- * {@link RenderContext#getGlContextRep()}
- * @param vboId
- * the vbo id of a vbo. To be valid, this must be != 0.
- * @throws IllegalArgumentException
- * if vboId is equal to 0.
- */
- public void setVBOInterleavedID(final Object glContext, final int vboId) {
- if (vboId == 0) {
- throw new IllegalArgumentException("vboId must != 0");
- }
-
- if (_vboIdCache == null) {
- _vboIdCache = new WeakHashMap<>(1);
- }
- _vboIdCache.put(glContext, vboId);
- }
-
public MeshData makeCopy() {
final MeshData data = new MeshData();
data._vertexCount = _vertexCount;
@@ -1317,7 +1220,6 @@ public class MeshData implements Savable {
capsule.write(_tangentCoords, "tangentBuffer", null);
capsule.writeSavableList(_textureCoords, "textureCoords", new ArrayList<FloatBufferData>(1));
capsule.write((Savable) _indexBuffer, "indexBuffer", null);
- capsule.write(_interleaved, "interleaved", null);
capsule.write(_indexLengths, "indexLengths", null);
capsule.write(_indexModes, "indexModes");
}
@@ -1332,7 +1234,6 @@ public class MeshData implements Savable {
_tangentCoords = (FloatBufferData) capsule.readSavable("tangentBuffer", null);
_textureCoords = capsule.readSavableList("textureCoords", new ArrayList<FloatBufferData>(1));
_indexBuffer = (IndexBufferData<?>) capsule.readSavable("indexBuffer", null);
- _interleaved = (FloatBufferData) capsule.readSavable("interleaved", null);
_indexLengths = capsule.readIntArray("indexLengths", null);
_indexModes = capsule.readEnumArray("indexModes", IndexMode.class, new IndexMode[] { IndexMode.Triangles });
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/DataMode.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/DataMode.java
index c2ea681..c717259 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/DataMode.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/hint/DataMode.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -28,12 +28,5 @@ public enum DataMode {
* Send each data buffer to the card using vertex buffer objects. This is usually faster than Arrays, but may not be
* supported on older cards. If not supported, Arrays is used by the Renderer.
*/
- VBO,
-
- /**
- * Send each data buffer to the card using a combined vertex buffer object(s). Usually this is done by combining all
- * FloatBufferData buffers in one buffer sequentially, but if their types are different, multiple buffers might be
- * used instead. This is usually a bit faster than just VBO. If not supported, Arrays is used by the Renderer.
- */
- VBOInterleaved;
+ VBO;
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java
index d2b1500..4a57efd 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/visitor/DeleteVBOsVisitor.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -28,7 +28,6 @@ public class DeleteVBOsVisitor implements Visitor {
final Mesh mesh = (Mesh) spatial;
_deleter.deleteVBOs(mesh.getMeshData().getVertexCoords());
_deleter.deleteVBOs(mesh.getMeshData().getIndices());
- _deleter.deleteVBOs(mesh.getMeshData().getInterleavedData());
_deleter.deleteVBOs(mesh.getMeshData().getNormalCoords());
_deleter.deleteVBOs(mesh.getMeshData().getTangentCoords());
for (final FloatBufferData coords : mesh.getMeshData().getTextureCoords()) {