diff options
99 files changed, 1432 insertions, 1037 deletions
diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java index cb1ea7a..a0fa4c1 100644 --- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java +++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/SkeletonPose.java @@ -196,7 +196,6 @@ public class SkeletonPose implements Savable { } Transform.releaseTempInstance(temp); updateTransforms(); - firePoseUpdated(); } /** diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java index fec63a8..5edb64d 100644 --- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java +++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/BinaryLERPSource.java @@ -95,7 +95,8 @@ public class BinaryLERPSource extends AbstractTwoPartSource { */ public static Map<String, ? extends Object> combineSourceData(final Map<String, ? extends Object> sourceAData, final Map<String, ? extends Object> sourceBData, final Double blendWeight) { - return BinaryLERPSource.combineSourceData(sourceAData, sourceBData, blendWeight, null); + return BinaryLERPSource.combineSourceData(sourceAData, sourceBData, + blendWeight != null ? blendWeight.doubleValue() : 0.0, null); } public static Map<String, ? extends Object> combineSourceData(final Map<String, ? extends Object> sourceAData, diff --git a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java index 6530783..1806e6a 100644 --- a/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java +++ b/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/blendtree/ManagedTransformSource.java @@ -24,7 +24,7 @@ import com.google.common.collect.Maps; /** * This tree source maintains its own source data, which can be modified directly using setJointXXX. This source is - * meant to be used for controlling a particular joint or set of joints programmatically. + * meant to be used for controlling a particular joint or set of joints programatically. */ public class ManagedTransformSource implements BlendTreeSource { diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java index 379651e..5076600 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java @@ -979,7 +979,7 @@ public class ColladaAnimUtils { String accessorString = targetString.substring(accessorIndex, targetString.length()); accessorString = accessorString.replace(".", ""); - if (accessorString.startsWith("(")) { + if (accessorString.length() > 0 && accessorString.charAt(0) == '(') { int endPara = accessorString.indexOf(")"); final String indexXString = accessorString.substring(1, endPara); target.accessorIndexX = Integer.parseInt(indexXString); @@ -1104,46 +1104,46 @@ public class ColladaAnimUtils { private static void getElementString(final Element e, final StringBuilder str, final int depth, final int maxDepth, final boolean showDots) { addSpacing(str, depth); - str.append("<"); + str.append('<'); str.append(e.getName()); - str.append(" "); + str.append(' '); final List<Attribute> attrs = e.getAttributes(); for (int i = 0; i < attrs.size(); i++) { final Attribute attr = attrs.get(i); str.append(attr.getName()); str.append("=\""); str.append(attr.getValue()); - str.append("\""); + str.append('"'); if (i < attrs.size() - 1) { - str.append(" "); + str.append(' '); } } if (!e.getChildren().isEmpty() || !"".equals(e.getText())) { - str.append(">"); + str.append('>'); if (depth < maxDepth) { - str.append("\n"); - for (final Element child : e.getChildren()) { + str.append('\n'); + for (final Element child : (List<Element>) e.getChildren()) { getElementString(child, str, depth + 1, maxDepth, showDots); } if (!"".equals(e.getText())) { addSpacing(str, depth + 1); str.append(e.getText()); - str.append("\n"); + str.append('\n'); } } else if (showDots) { - str.append("\n"); + str.append('\n'); addSpacing(str, depth + 1); str.append("..."); - str.append("\n"); + str.append('\n'); } addSpacing(str, depth); str.append("</"); str.append(e.getName()); - str.append(">"); + str.append('>'); } else { str.append("/>"); } - str.append("\n"); + str.append('\n'); } private static void addSpacing(final StringBuilder str, final int depth) { diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java index 2f67140..956af66 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java @@ -110,7 +110,7 @@ public class ColladaDOMUtil { } private String parseUrl(String baseUrl) { - if (baseUrl.startsWith("#")) { + if (baseUrl.length() > 1 && baseUrl.charAt(0) == '#') { baseUrl = baseUrl.substring(1); } return baseUrl; diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java index 3f3a87e..d883756 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java @@ -142,7 +142,7 @@ public class ColladaInputPipe { } // String paramType = param.getAttributeValue("type"); } - if (_paramCount > 1 && skippedParam == true) { + if (_paramCount > 1 && skippedParam) { ColladaInputPipe.logger.warning("Parameter skipping not yet supported when parsing sources. " + _source.getAttributeValue("id")); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java index d488d81..c7de5dc 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java +++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingBox.java @@ -426,6 +426,33 @@ public class BoundingBox extends BoundingVolume { } } + @Override + public BoundingVolume asType(final Type newType) { + if (newType == null) { + return null; + } + + switch (newType) { + case AABB: { + return this.clone(null); + } + + case Sphere: { + final BoundingSphere sphere = new BoundingSphere(0, _center); + return sphere.merge(this); + } + + case OBB: { + final OrientedBoundingBox obb = new OrientedBoundingBox(); + obb.setCenter(_center); + return obb.merge(this); + } + + default: + return null; + } + } + /** * Merges this AABB with the given OBB. * diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java index 9bf81b8..675a53c 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java +++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingSphere.java @@ -20,10 +20,10 @@ import com.ardor3d.math.MathUtils; import com.ardor3d.math.Plane; import com.ardor3d.math.Vector3; import com.ardor3d.math.type.ReadOnlyPlane; +import com.ardor3d.math.type.ReadOnlyPlane.Side; import com.ardor3d.math.type.ReadOnlyRay3; import com.ardor3d.math.type.ReadOnlyTransform; import com.ardor3d.math.type.ReadOnlyVector3; -import com.ardor3d.math.type.ReadOnlyPlane.Side; import com.ardor3d.scenegraph.MeshData; import com.ardor3d.util.export.InputCapsule; import com.ardor3d.util.export.OutputCapsule; @@ -103,6 +103,7 @@ public class BoundingSphere extends BoundingVolume { * * @return the radius of the bounding sphere. */ + @Override public double getRadius() { return _radius; } @@ -269,9 +270,9 @@ public class BoundingSphere extends BoundingVolume { _center.set(0, 0, 0); setRadius(0); } else { - final Vector3 o = a.cross(b, null).multiplyLocal(c.lengthSquared()).addLocal( - c.cross(a, null).multiplyLocal(b.lengthSquared())).addLocal( - b.cross(c, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); + final Vector3 o = a.cross(b, null).multiplyLocal(c.lengthSquared()) + .addLocal(c.cross(a, null).multiplyLocal(b.lengthSquared())) + .addLocal(b.cross(c, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); setRadius(o.length() * radiusEpsilon); O.add(o, _center); @@ -301,8 +302,8 @@ public class BoundingSphere extends BoundingVolume { setRadius(0); } else { - final Vector3 o = acrossB.cross(a, null).multiplyLocal(b.lengthSquared()).addLocal( - b.cross(acrossB, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); + final Vector3 o = acrossB.cross(a, null).multiplyLocal(b.lengthSquared()) + .addLocal(b.cross(acrossB, null).multiplyLocal(a.lengthSquared())).divideLocal(Denominator); setRadius(o.length() * radiusEpsilon); O.add(o, _center); } @@ -562,6 +563,33 @@ public class BoundingSphere extends BoundingVolume { return store; } + @Override + public BoundingVolume asType(final Type newType) { + if (newType == null) { + return null; + } + + switch (newType) { + case AABB: { + final BoundingBox box = new BoundingBox(_center, 0, 0, 0); + return box.merge(this); + } + + case Sphere: { + return this.clone(null); + } + + case OBB: { + final OrientedBoundingBox obb = new OrientedBoundingBox(); + obb.setCenter(_center); + return obb.merge(this); + } + + default: + return null; + } + } + /** * <code>clone</code> creates a new BoundingSphere object containing the same data as this one. * @@ -662,8 +690,8 @@ public class BoundingSphere extends BoundingVolume { discr = (a1 * a1) - a; root = Math.sqrt(discr); final double[] distances = new double[] { root - a1 }; - final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3()).addLocal( - ray.getOrigin()) }; + final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3()) + .addLocal(ray.getOrigin()) }; return new IntersectionRecord(distances, points); } @@ -687,8 +715,8 @@ public class BoundingSphere extends BoundingVolume { } final double[] distances = new double[] { -a1 }; - final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3()).addLocal( - ray.getOrigin()) }; + final Vector3[] points = new Vector3[] { ray.getDirection().multiply(distances[0], new Vector3()) + .addLocal(ray.getOrigin()) }; return new IntersectionRecord(distances, points); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java index 5c0ba3d..19a9822 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java +++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/BoundingVolume.java @@ -241,6 +241,15 @@ public abstract class BoundingVolume implements Serializable, Savable { */ public abstract boolean contains(ReadOnlyVector3 point); + /** + * Convert this bounding volume to another, given bounding type. + * + * @param newType + * the type of bounding volume to convert to. + * @return a new bounding volume of the given type, containing this bounding volume. + */ + public abstract BoundingVolume asType(Type newType); + public void write(final OutputCapsule capsule) throws IOException { capsule.write(_center, "center", new Vector3(Vector3.ZERO)); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java b/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java index e3e77b0..20dd515 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java +++ b/ardor3d-core/src/main/java/com/ardor3d/bounding/OrientedBoundingBox.java @@ -191,6 +191,32 @@ public class OrientedBoundingBox extends BoundingVolume { } } + @Override + public BoundingVolume asType(final Type newType) { + if (newType == null) { + return null; + } + + switch (newType) { + case AABB: { + final BoundingBox box = new BoundingBox(_center, 0, 0, 0); + return box.merge(this); + } + + case Sphere: { + final BoundingSphere sphere = new BoundingSphere(0, _center); + return sphere.merge(this); + } + + case OBB: { + return this.clone(null); + } + + default: + return null; + } + } + private BoundingVolume mergeSphere(final BoundingSphere volume) { // check for infinite bounds to prevent NaN values if (Vector3.isInfinite(getExtent()) || Double.isInfinite(volume.getRadius())) { diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java index dca8689..70e8c1c 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java +++ b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerState.java @@ -75,11 +75,11 @@ public class ControllerState { for (final String controllerStateKey : _controllerStates.keySet()) {
final Map<String, Float> state = _controllerStates.get(controllerStateKey);
- stateString.append("[").append(controllerStateKey);
+ stateString.append('[').append(controllerStateKey);
for (final String stateKey : state.keySet()) {
- stateString.append("[").append(stateKey).append(":").append(state.get(stateKey)).append("]");
+ stateString.append('[').append(stateKey).append(':').append(state.get(stateKey)).append(']');
}
- stateString.append("]");
+ stateString.append(']');
}
return stateString.toString();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java index 82b1771..4937a74 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java +++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/ControllerComponentActiveCondition.java @@ -34,17 +34,20 @@ public final class ControllerComponentActiveCondition implements Predicate<TwoIn return false;
}
- float prev, curr;
+ Float prev, curr;
for (final String component : componentNames) {
curr = currentStates.get(component);
- if (curr != 0) {
+ if (curr == null) {
+ continue;
+ }
+ if (curr.floatValue() != 0) {
return true;
}
if (previousStates != null) {
prev = previousStates.get(component);
- if (curr != prev) {
+ if (prev != null && curr.floatValue() != prev.floatValue()) {
return true;
}
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java index f281735..3b72a92 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java +++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java @@ -1386,8 +1386,6 @@ public class Camera implements Savable, Externalizable { */ private void checkModelViewProjection() { if (_updateMVPMatrix) { - checkModelView(); - checkProjection(); _modelViewProjection.set(getModelViewMatrix()).multiplyLocal(getProjectionMatrix()); _updateMVPMatrix = false; } diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.java index f2ac794..3e8d55c 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.java +++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.java @@ -43,6 +43,8 @@ public class ContextCapabilities { protected boolean _pbufferSupported = false; protected boolean _fboSupported = false; + protected boolean _supportsFBOMultisample = false; + protected boolean _supportsFBOBlit = false; protected int _maxFBOColorAttachments = 1; protected int _maxFBOSamples = 0; @@ -227,6 +229,20 @@ public class ContextCapabilities { } /** + * @return true if we support fbo multisampling (antialiasing) + */ + public boolean isFBOMultisampleSupported() { + return _supportsFBOMultisample; + } + + /** + * @return true if we support fbo blitting + */ + public boolean isFBOBlitSupported() { + return _supportsFBOBlit; + } + + /** * @return true if we support setting a constant color for use with *Constant* type BlendFunctions. */ public boolean isConstantBlendColorSupported() { diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java index 8299c14..c5780bd 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java +++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/effect/EffectManager.java @@ -18,11 +18,11 @@ import com.ardor3d.framework.DisplaySettings; import com.ardor3d.image.TextureStoreFormat; import com.ardor3d.math.Vector3; import com.ardor3d.renderer.Camera; -import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.Camera.ProjectionMode; +import com.ardor3d.renderer.Renderer; import com.ardor3d.renderer.state.RenderState; -import com.ardor3d.renderer.state.ZBufferState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.ZBufferState; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; @@ -139,7 +139,7 @@ public class EffectManager { _fsq = new Mesh("fsq"); _fsq.getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1)); _fsq.getMeshData().setTextureBuffer(BufferUtils.createFloatBuffer(0, 0, 1, 0, 1, 1, 0, 1), 0); - _fsq.getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(0, 1, 3, 1, 2, 3)); + _fsq.getMeshData().setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 1, 2, 3 }, 3)); _fsq.getSceneHints().setCullHint(CullHint.Never); _fsq.getSceneHints().setLightCombineMode(LightCombineMode.Off); diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java index 89d516e..4091e06 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ByteBufferData.java @@ -106,6 +106,20 @@ public class ByteBufferData extends IndexBufferData<ByteBuffer> implements Savab } @Override + public void put(final int[] array) { + for (int i = 0; i < array.length; i++) { + put(array[i]); + } + } + + @Override + public void put(final int[] array, final int offset, final int length) { + for (int i = offset, max = offset + length; i < max; i++) { + put(array[i]); + } + } + + @Override public int getByteCount() { return 1; } diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java index 9c39fae..4ca77b5 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IndexBufferData.java @@ -66,6 +66,26 @@ public abstract class IndexBufferData<T extends Buffer> extends AbstractBufferDa public abstract void put(IndexBufferData<?> buf); /** + * Write the contents of the given int array into this IndexBufferData. Note that data conversion is handled using + * the get/put methods in IndexBufferData. + * + * @param array + * the source int array. + */ + public abstract void put(int[] array); + + /** + * Write the contents of the given int array into this IndexBufferData. Note that data conversion is handled using + * the get/put methods in IndexBufferData. + * + * @param array + * the source int array. + * @param offset + * @param length + */ + public abstract void put(int[] array, int offset, int length); + + /** * Get the underlying nio buffer. */ @Override @@ -121,6 +141,20 @@ public abstract class IndexBufferData<T extends Buffer> extends AbstractBufferDa } /** + * @see Buffer#flip(); + */ + public void flip() { + getBuffer().flip(); + } + + /** + * @see Buffer#clear(); + */ + public void clear() { + getBuffer().clear(); + } + + /** * @see Buffer#reset(); */ public void reset() { diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java index 4e4cf04..219a729 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/IntBufferData.java @@ -105,6 +105,16 @@ public class IntBufferData extends IndexBufferData<IntBuffer> implements Savable } @Override + public void put(final int[] array) { + _buffer.put(array); + } + + @Override + public void put(final int[] array, final int offset, final int length) { + _buffer.put(array, offset, length); + } + + @Override public int getByteCount() { return 4; } 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 d97c844..b81eb1c 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Mesh.java @@ -336,7 +336,7 @@ public class Mesh extends Spatial implements Renderable, Pickable { } renderer.setupVertexData(meshData.getVertexCoords()); - if (meshData.getIndexBuffer() != null) { + if (meshData.getIndices() != null) { renderer.drawElements(meshData.getIndices(), meshData.getIndexLengths(), meshData.getIndexModes(), primcount); } else { @@ -390,7 +390,7 @@ public class Mesh extends Spatial implements Renderable, Pickable { renderer.setupVertexDataVBO(meshData.getVertexCoords()); } - if (meshData.getIndexBuffer() != null) { + if (meshData.getIndices() != null) { // TODO: Maybe ask for the IndexBuffer's dynamic/static type and fall back to arrays for indices? renderer.drawElementsVBO(meshData.getIndices(), meshData.getIndexLengths(), meshData.getIndexModes(), primcount); 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 b98c7ec..90a5a8b 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/MeshData.java @@ -346,10 +346,14 @@ public class MeshData implements Savable { * @see #setTextureCoords(FloatBufferData, int) */ public void setTextureBuffer(final FloatBuffer textureBuffer, final int index) { - while (_textureCoords.size() <= index) { - _textureCoords.add(null); + if (textureBuffer != null) { + while (_textureCoords.size() <= index) { + _textureCoords.add(null); + } + _textureCoords.set(index, new FloatBufferData(textureBuffer, 2)); + } else if (index < _textureCoords.size()) { + _textureCoords.set(index, null); } - _textureCoords.set(index, new FloatBufferData(textureBuffer, 2)); refreshInterleaved(); } @@ -790,7 +794,7 @@ public class MeshData implements Savable { } for (int i = 0; i < rSize; i++) { - if (getIndexBuffer() != null) { + if (getIndices() != null) { result[i] = getIndices().get(getVertexIndex(primitiveIndex, i, section)); } else { result[i] = getVertexIndex(primitiveIndex, i, section); @@ -829,7 +833,7 @@ public class MeshData implements Savable { if (result[i] == null) { result[i] = new Vector3(); } - if (getIndexBuffer() != null) { + if (getIndices() != null) { // indexed geometry BufferUtils.populateFromBuffer(result[i], getVertexBuffer(), getIndices().get(getVertexIndex(primitiveIndex, i, section))); @@ -956,7 +960,7 @@ public class MeshData implements Savable { // Now, based on IndexMode, pick a point on that primitive final IndexMode mode = getIndexMode(section); - final boolean hasIndices = getIndexBuffer() != null; + final boolean hasIndices = getIndices() != null; switch (mode) { case Triangles: case TriangleFan: diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java index 95016bf..5d8f8f8 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/ShortBufferData.java @@ -106,6 +106,20 @@ public class ShortBufferData extends IndexBufferData<ShortBuffer> implements Sav } @Override + public void put(final int[] array) { + for (int i = 0; i < array.length; i++) { + put(array[i]); + } + } + + @Override + public void put(final int[] array, final int offset, final int length) { + for (int i = offset, max = offset + length; i < max; i++) { + put(array[i]); + } + } + + @Override public int getByteCount() { return 2; } diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Box.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Box.java index 4b4bfdd..c4f630b 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Box.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Box.java @@ -271,7 +271,7 @@ public class Box extends Mesh { * box. */ private void setIndexData() { - if (_meshData.getIndexBuffer() == null) { + if (_meshData.getIndices() == null) { final byte[] indices = { 2, 1, 0, 3, 2, 0, 6, 5, 4, 7, 6, 4, 10, 9, 8, 11, 10, 8, 14, 13, 12, 15, 14, 12, 18, 17, 16, 19, 18, 16, 22, 21, 20, 23, 22, 20 }; final ByteBuffer buf = BufferUtils.createByteBuffer(indices.length); diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Capsule.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Capsule.java index fb184d4..7dce5dd 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Capsule.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Capsule.java @@ -221,7 +221,7 @@ public class Capsule extends Mesh { } private void setIndexData() { - _meshData.getIndexBuffer().rewind(); + _meshData.getIndices().rewind(); // start with top of top dome. for (int samples = 1; samples <= radialSamples; samples++) { diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Cylinder.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Cylinder.java index 5b4c7f7..fd56cb6 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Cylinder.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Cylinder.java @@ -322,7 +322,7 @@ public class Cylinder extends Mesh { } private void setIndexData() { - _meshData.getIndexBuffer().rewind(); + _meshData.getIndices().rewind(); // generate connectivity for (int axisCount = 0, axisStart = 0; axisCount < _axisSamples - 1; axisCount++) { diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Dodecahedron.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Dodecahedron.java index 11e00e9..adf1ce5 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Dodecahedron.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Dodecahedron.java @@ -11,12 +11,12 @@ package com.ardor3d.scenegraph.shape; import java.io.IOException; -import java.nio.ByteBuffer; import java.nio.FloatBuffer; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Vector2; import com.ardor3d.math.Vector3; +import com.ardor3d.scenegraph.IndexBufferData; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.util.export.InputCapsule; import com.ardor3d.util.export.OutputCapsule; @@ -58,44 +58,44 @@ public class Dodecahedron extends Mesh { } private void setIndexData() { - final ByteBuffer indices = (ByteBuffer) _meshData.getIndexBuffer(); + final IndexBufferData<?> indices = _meshData.getIndices(); indices.rewind(); - indices.put((byte) 0).put((byte) 8).put((byte) 9); - indices.put((byte) 0).put((byte) 9).put((byte) 4); - indices.put((byte) 0).put((byte) 4).put((byte) 16); - indices.put((byte) 0).put((byte) 12).put((byte) 13); - indices.put((byte) 0).put((byte) 13).put((byte) 1); - indices.put((byte) 0).put((byte) 1).put((byte) 8); - indices.put((byte) 0).put((byte) 16).put((byte) 17); - indices.put((byte) 0).put((byte) 17).put((byte) 2); - indices.put((byte) 0).put((byte) 2).put((byte) 12); - indices.put((byte) 8).put((byte) 1).put((byte) 18); - indices.put((byte) 8).put((byte) 18).put((byte) 5); - indices.put((byte) 8).put((byte) 5).put((byte) 9); - indices.put((byte) 12).put((byte) 2).put((byte) 10); - indices.put((byte) 12).put((byte) 10).put((byte) 3); - indices.put((byte) 12).put((byte) 3).put((byte) 13); - indices.put((byte) 16).put((byte) 4).put((byte) 14); - indices.put((byte) 16).put((byte) 14).put((byte) 6); - indices.put((byte) 16).put((byte) 6).put((byte) 17); - indices.put((byte) 9).put((byte) 5).put((byte) 15); - indices.put((byte) 9).put((byte) 15).put((byte) 14); - indices.put((byte) 9).put((byte) 14).put((byte) 4); - indices.put((byte) 6).put((byte) 11).put((byte) 10); - indices.put((byte) 6).put((byte) 10).put((byte) 2); - indices.put((byte) 6).put((byte) 2).put((byte) 17); - indices.put((byte) 3).put((byte) 19).put((byte) 18); - indices.put((byte) 3).put((byte) 18).put((byte) 1); - indices.put((byte) 3).put((byte) 1).put((byte) 13); - indices.put((byte) 7).put((byte) 15).put((byte) 5); - indices.put((byte) 7).put((byte) 5).put((byte) 18); - indices.put((byte) 7).put((byte) 18).put((byte) 19); - indices.put((byte) 7).put((byte) 11).put((byte) 6); - indices.put((byte) 7).put((byte) 6).put((byte) 14); - indices.put((byte) 7).put((byte) 14).put((byte) 15); - indices.put((byte) 7).put((byte) 19).put((byte) 3); - indices.put((byte) 7).put((byte) 3).put((byte) 10); - indices.put((byte) 7).put((byte) 10).put((byte) 11); + indices.put(0).put(8).put(9); + indices.put(0).put(9).put(4); + indices.put(0).put(4).put(16); + indices.put(0).put(12).put(13); + indices.put(0).put(13).put(1); + indices.put(0).put(1).put(8); + indices.put(0).put(16).put(17); + indices.put(0).put(17).put(2); + indices.put(0).put(2).put(12); + indices.put(8).put(1).put(18); + indices.put(8).put(18).put(5); + indices.put(8).put(5).put(9); + indices.put(12).put(2).put(10); + indices.put(12).put(10).put(3); + indices.put(12).put(3).put(13); + indices.put(16).put(4).put(14); + indices.put(16).put(14).put(6); + indices.put(16).put(6).put(17); + indices.put(9).put(5).put(15); + indices.put(9).put(15).put(14); + indices.put(9).put(14).put(4); + indices.put(6).put(11).put(10); + indices.put(6).put(10).put(2); + indices.put(6).put(2).put(17); + indices.put(3).put(19).put(18); + indices.put(3).put(18).put(1); + indices.put(3).put(1).put(13); + indices.put(7).put(15).put(5); + indices.put(7).put(5).put(18); + indices.put(7).put(18).put(19); + indices.put(7).put(11).put(6); + indices.put(7).put(6).put(14); + indices.put(7).put(14).put(15); + indices.put(7).put(19).put(3); + indices.put(7).put(3).put(10); + indices.put(7).put(10).put(11); } private void setTextureData() { diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java index c6c2c13..6fb83ae 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Extrusion.java @@ -138,9 +138,9 @@ public class Extrusion extends Mesh { final int numIndices = (path.size() - 1) * 2 * shapeBuffer.limit(); IndexBufferData<?> indices; - if (_meshData.getIndexBuffer() != null && _meshData.getIndexBuffer().limit() == numIndices) { + if (_meshData.getIndices() != null && _meshData.getIndices().limit() == numIndices) { indices = _meshData.getIndices(); - indices.getBuffer().rewind(); + indices.rewind(); } else { indices = BufferUtils.createIndexBufferData(numIndices, numVertices - 1); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Hexagon.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Hexagon.java index 361fbb1..f6592ef 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Hexagon.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Hexagon.java @@ -78,7 +78,7 @@ public class Hexagon extends Mesh { */ private void setIndexData() { - _meshData.getIndexBuffer().rewind(); + _meshData.getIndices().rewind(); // tri 1 _meshData.getIndices().put(0); _meshData.getIndices().put(6); diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/OrientedBox.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/OrientedBox.java index c24b3b5..6983a9c 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/OrientedBox.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/OrientedBox.java @@ -90,7 +90,7 @@ public class OrientedBox extends Mesh { * Sets the correct indices array for the box. */ private void setIndexData() { - if (_meshData.getIndexBuffer() == null) { + if (_meshData.getIndices() == null) { _meshData.setIndexBuffer(BufferUtils.createByteBuffer(36)); for (int i = 0; i < 6; i++) { diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/RoundedBox.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/RoundedBox.java index 1f252e7..31b52d1 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/RoundedBox.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/RoundedBox.java @@ -160,7 +160,7 @@ public class RoundedBox extends Mesh { } private void setIndexData() { - if (_meshData.getIndexBuffer() == null) { + if (_meshData.getIndices() == null) { final IndexBufferData<?> buff = BufferUtils.createIndexBufferData(180, 48 - 1); final int[] data = new int[] { 0, 4, 1, 1, 4, 5, 1, 5, 3, 3, 5, 7, 3, 7, 2, 2, 7, 6, 2, 6, 0, 0, 6, 4, 4, 6, 5, 5, 6, 7 }; diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/StripBox.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/StripBox.java index 9c98bee..3515494 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/StripBox.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/StripBox.java @@ -201,7 +201,7 @@ public class StripBox extends Mesh { */ private void setIndexData() { _meshData.setIndexMode(IndexMode.TriangleStrip); - if (_meshData.getIndexBuffer() == null) { + if (_meshData.getIndices() == null) { final byte[] indices = new byte[] { 2, 3, 6, 7, 5, 3, 0, 2, 1, 6, 4, 5, 1, 0 }; final ByteBuffer buf = BufferUtils.createByteBuffer(indices.length); buf.put(indices); diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Tube.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Tube.java index 5b93988..898f9e9 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Tube.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/shape/Tube.java @@ -20,12 +20,6 @@ import com.ardor3d.util.geom.BufferUtils; public class Tube extends Mesh { - private static final long serialVersionUID = 1L; - - public static long getSerialVersionUID() { - return serialVersionUID; - } - private int _axisSamples; private int _radialSamples; @@ -137,43 +131,43 @@ public class Tube extends Mesh { // outer cylinder for (int radialCount = 0; radialCount < _radialSamples + 1; radialCount++) { for (int axisCount = 0; axisCount < _axisSamples + 1; axisCount++) { - _meshData.getVertexBuffer().put((float) (cos[radialCount % _radialSamples] * _outerRadius)).put( - (float) (axisStep * axisCount - halfHeight)).put( - (float) (sin[radialCount % _radialSamples] * _outerRadius)); + _meshData.getVertexBuffer().put((float) (cos[radialCount % _radialSamples] * _outerRadius)) + .put((float) (axisStep * axisCount - halfHeight)) + .put((float) (sin[radialCount % _radialSamples] * _outerRadius)); if (_viewInside) { - _meshData.getNormalBuffer().put((float) cos[radialCount % _radialSamples]).put(0).put( - (float) sin[radialCount % _radialSamples]); + _meshData.getNormalBuffer().put((float) cos[radialCount % _radialSamples]).put(0) + .put((float) sin[radialCount % _radialSamples]); } else { - _meshData.getNormalBuffer().put((float) -cos[radialCount % _radialSamples]).put(0).put( - (float) -sin[radialCount % _radialSamples]); + _meshData.getNormalBuffer().put((float) -cos[radialCount % _radialSamples]).put(0) + .put((float) -sin[radialCount % _radialSamples]); } - _meshData.getTextureCoords(0).getBuffer().put((float) (radialCount * inverseRadial)).put( - (float) (axisTextureStep * axisCount)); + _meshData.getTextureCoords(0).getBuffer().put((float) (radialCount * inverseRadial)) + .put((float) (axisTextureStep * axisCount)); } } // inner cylinder for (int radialCount = 0; radialCount < _radialSamples + 1; radialCount++) { for (int axisCount = 0; axisCount < _axisSamples + 1; axisCount++) { - _meshData.getVertexBuffer().put((float) (cos[radialCount % _radialSamples] * _innerRadius)).put( - (float) (axisStep * axisCount - halfHeight)).put( - (float) (sin[radialCount % _radialSamples] * _innerRadius)); + _meshData.getVertexBuffer().put((float) (cos[radialCount % _radialSamples] * _innerRadius)) + .put((float) (axisStep * axisCount - halfHeight)) + .put((float) (sin[radialCount % _radialSamples] * _innerRadius)); if (_viewInside) { - _meshData.getNormalBuffer().put((float) -cos[radialCount % _radialSamples]).put(0).put( - (float) -sin[radialCount % _radialSamples]); + _meshData.getNormalBuffer().put((float) -cos[radialCount % _radialSamples]).put(0) + .put((float) -sin[radialCount % _radialSamples]); } else { - _meshData.getNormalBuffer().put((float) cos[radialCount % _radialSamples]).put(0).put( - (float) sin[radialCount % _radialSamples]); + _meshData.getNormalBuffer().put((float) cos[radialCount % _radialSamples]).put(0) + .put((float) sin[radialCount % _radialSamples]); } - _meshData.getTextureCoords(0).getBuffer().put((float) (radialCount * inverseRadial)).put( - (float) (axisTextureStep * axisCount)); + _meshData.getTextureCoords(0).getBuffer().put((float) (radialCount * inverseRadial)) + .put((float) (axisTextureStep * axisCount)); } } // bottom edge for (int radialCount = 0; radialCount < _radialSamples; radialCount++) { - _meshData.getVertexBuffer().put((float) (cos[radialCount] * _outerRadius)).put((float) -halfHeight).put( - (float) (sin[radialCount] * _outerRadius)); - _meshData.getVertexBuffer().put((float) (cos[radialCount] * _innerRadius)).put((float) -halfHeight).put( - (float) (sin[radialCount] * _innerRadius)); + _meshData.getVertexBuffer().put((float) (cos[radialCount] * _outerRadius)).put((float) -halfHeight) + .put((float) (sin[radialCount] * _outerRadius)); + _meshData.getVertexBuffer().put((float) (cos[radialCount] * _innerRadius)).put((float) -halfHeight) + .put((float) (sin[radialCount] * _innerRadius)); if (_viewInside) { _meshData.getNormalBuffer().put(0).put(1).put(0); _meshData.getNormalBuffer().put(0).put(1).put(0); @@ -181,17 +175,17 @@ public class Tube extends Mesh { _meshData.getNormalBuffer().put(0).put(-1).put(0); _meshData.getNormalBuffer().put(0).put(-1).put(0); } - _meshData.getTextureCoords(0).getBuffer().put((float) (0.5 + 0.5 * cos[radialCount])).put( - (float) (0.5 + 0.5 * sin[radialCount])); + _meshData.getTextureCoords(0).getBuffer().put((float) (0.5 + 0.5 * cos[radialCount])) + .put((float) (0.5 + 0.5 * sin[radialCount])); _meshData.getTextureCoords(0).getBuffer().put((float) (0.5 + innerOuterRatio * 0.5 * cos[radialCount])) .put((float) (0.5 + innerOuterRatio * 0.5 * sin[radialCount])); } // top edge for (int radialCount = 0; radialCount < _radialSamples; radialCount++) { - _meshData.getVertexBuffer().put((float) (cos[radialCount] * _outerRadius)).put((float) halfHeight).put( - (float) (sin[radialCount] * _outerRadius)); - _meshData.getVertexBuffer().put((float) (cos[radialCount] * _innerRadius)).put((float) halfHeight).put( - (float) (sin[radialCount] * _innerRadius)); + _meshData.getVertexBuffer().put((float) (cos[radialCount] * _outerRadius)).put((float) halfHeight) + .put((float) (sin[radialCount] * _outerRadius)); + _meshData.getVertexBuffer().put((float) (cos[radialCount] * _innerRadius)).put((float) halfHeight) + .put((float) (sin[radialCount] * _innerRadius)); if (_viewInside) { _meshData.getNormalBuffer().put(0).put(-1).put(0); _meshData.getNormalBuffer().put(0).put(-1).put(0); @@ -199,8 +193,8 @@ public class Tube extends Mesh { _meshData.getNormalBuffer().put(0).put(1).put(0); _meshData.getNormalBuffer().put(0).put(1).put(0); } - _meshData.getTextureCoords(0).getBuffer().put((float) (0.5 + 0.5 * cos[radialCount])).put( - (float) (0.5 + 0.5 * sin[radialCount])); + _meshData.getTextureCoords(0).getBuffer().put((float) (0.5 + 0.5 * cos[radialCount])) + .put((float) (0.5 + 0.5 * sin[radialCount])); _meshData.getTextureCoords(0).getBuffer().put((float) (0.5 + innerOuterRatio * 0.5 * cos[radialCount])) .put((float) (0.5 + innerOuterRatio * 0.5 * sin[radialCount])); } @@ -208,7 +202,7 @@ public class Tube extends Mesh { } private void setIndexData() { - _meshData.getIndexBuffer().rewind(); + _meshData.getIndices().rewind(); final int outerCylinder = (_axisSamples + 1) * (_radialSamples + 1); final int bottomEdge = 2 * outerCylinder; diff --git a/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java b/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java index 9e9e343..9d5991e 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java +++ b/ardor3d-core/src/main/java/com/ardor3d/ui/text/BMFont.java @@ -234,7 +234,7 @@ public class BMFont implements Savable { xml.append(_info.padding[i]);
if (i < (_info.padding.length - 1)) {
- xml.append(",");
+ xml.append(',');
}
}
@@ -244,7 +244,7 @@ public class BMFont implements Savable { xml.append(_info.spacing[i]);
if (i < (_info.spacing.length - 1)) {
- xml.append(",");
+ xml.append(',');
}
}
@@ -859,7 +859,7 @@ public class BMFont implements Savable { void setUseBlend(final boolean blend) {
_useBlend = blend;
- if (blend == false) {
+ if (!_useBlend) {
blendState.setBlendEnabled(false);
blendState.setReference(_blendDisabledTestRef);
zBuffState.setWritable(true);
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java index 3ae77d5..0aab109 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java @@ -54,7 +54,7 @@ public class GameTaskQueue { */ public void setExecuteMultiple(final boolean executeMultiple) { _executeMultiple.set(executeMultiple); - if (executeMultiple == true) { + if (executeMultiple) { _executionTime = Integer.MAX_VALUE; } } @@ -79,7 +79,7 @@ public class GameTaskQueue { * @return -1 if executeAll is false, else min time allocated for task execution per frame */ public long getExecutionTime() { - if (_executeMultiple.get() == false) { + if (!_executeMultiple.get()) { return -1; } return _executionTime; diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java index b07df78..ce2e9c7 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMOutputCapsule.java @@ -86,7 +86,7 @@ public class DOMOutputCapsule implements OutputCapsule { } for (final byte b : value) { buf.append(b); - buf.append(" "); + buf.append(' '); } // remove last space buf.setLength(buf.length() - 1); @@ -105,9 +105,9 @@ public class DOMOutputCapsule implements OutputCapsule { for (final byte[] bs : value) { for (final byte b : bs) { buf.append(b); - buf.append(" "); + buf.append(' '); } - buf.append(" "); + buf.append(' '); } // remove last spaces buf.setLength(buf.length() - 2); @@ -137,7 +137,7 @@ public class DOMOutputCapsule implements OutputCapsule { for (final int b : value) { buf.append(b); - buf.append(" "); + buf.append(' '); } // remove last space buf.setLength(Math.max(0, buf.length() - 1)); @@ -180,7 +180,7 @@ public class DOMOutputCapsule implements OutputCapsule { } for (final float b : value) { buf.append(b); - buf.append(" "); + buf.append(' '); } // remove last space buf.setLength(buf.length() - 1); @@ -203,7 +203,7 @@ public class DOMOutputCapsule implements OutputCapsule { for (final float[] bs : value) { for (final float b : bs) { buf.append(b); - buf.append(" "); + buf.append(' '); } } // remove last space @@ -230,7 +230,7 @@ public class DOMOutputCapsule implements OutputCapsule { } for (final double b : value) { buf.append(b); - buf.append(" "); + buf.append(' '); } // remove last space buf.setLength(buf.length() - 1); @@ -273,7 +273,7 @@ public class DOMOutputCapsule implements OutputCapsule { } for (final long b : value) { buf.append(b); - buf.append(" "); + buf.append(' '); } // remove last space buf.setLength(buf.length() - 1); @@ -316,7 +316,7 @@ public class DOMOutputCapsule implements OutputCapsule { } for (final short b : value) { buf.append(b); - buf.append(" "); + buf.append(' '); } // remove last space buf.setLength(buf.length() - 1); @@ -359,7 +359,7 @@ public class DOMOutputCapsule implements OutputCapsule { } for (final boolean b : value) { buf.append(b); - buf.append(" "); + buf.append(' '); } // remove last space buf.setLength(Math.max(0, buf.length() - 1)); @@ -439,7 +439,7 @@ public class DOMOutputCapsule implements OutputCapsule { final StringBuilder buf = new StringBuilder(); for (int i = value.nextSetBit(0); i >= 0; i = value.nextSetBit(i + 1)) { buf.append(i); - buf.append(" "); + buf.append(' '); } buf.setLength(Math.max(0, buf.length() - 1)); _currentElement.setAttribute(name, buf.toString()); @@ -680,7 +680,7 @@ public class DOMOutputCapsule implements OutputCapsule { value.rewind(); while (value.hasRemaining()) { buf.append(value.get()); - buf.append(" "); + buf.append(' '); } buf.setLength(Math.max(0, buf.length() - 1)); value.position(pos); @@ -703,7 +703,7 @@ public class DOMOutputCapsule implements OutputCapsule { value.rewind(); while (value.hasRemaining()) { buf.append(value.get()); - buf.append(" "); + buf.append(' '); } buf.setLength(buf.length() - 1); value.position(pos); @@ -726,7 +726,7 @@ public class DOMOutputCapsule implements OutputCapsule { value.rewind(); while (value.hasRemaining()) { buf.append(value.get()); - buf.append(" "); + buf.append(' '); } buf.setLength(buf.length() - 1); value.position(pos); @@ -749,7 +749,7 @@ public class DOMOutputCapsule implements OutputCapsule { value.rewind(); while (value.hasRemaining()) { buf.append(value.get()); - buf.append(" "); + buf.append(' '); } buf.setLength(buf.length() - 1); value.position(pos); diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java index eef7b79..34000f0 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMSerializer.java @@ -53,7 +53,7 @@ public class DOMSerializer { public void setIndent(final int numSpaces) { final StringBuffer buffer = new StringBuffer(); for (int i = 0; i < numSpaces; i++) { - buffer.append("\t"); + buffer.append('\t'); } _indent = buffer.toString(); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java index ebe13ca..a0a3478 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/BufferUtils.java @@ -1552,6 +1552,31 @@ public final class BufferUtils { } /** + * Create a new IndexBufferData large enough to fit the contents of the given array. The specific implementation + * will be chosen based on the max value you need to store in your buffer. If that value is less than 2^8, a + * ByteBufferData is used. If it is less than 2^16, a ShortBufferData is used. Otherwise an IntBufferData is used. + * + * @param contents + * an array of index values to store in your newly created IndexBufferData. + * @param maxValue + * the largest value you will need to store in your buffer. Often this is equal to + * ("size of vertex buffer" - 1). + * @return the new IndexBufferData + */ + public static IndexBufferData<?> createIndexBufferData(final int[] contents, final int maxValue) { + final IndexBufferData<?> buffer; + if (maxValue < 256) { // 2^8 + buffer = createIndexBufferData(contents.length, ByteBufferData.class); + } else if (maxValue < 65536) { // 2^16 + buffer = createIndexBufferData(contents.length, ShortBufferData.class); + } else { + buffer = createIndexBufferData(contents.length, IntBufferData.class); + } + buffer.put(contents); + return buffer; + } + + /** * Create a new IndexBufferData of the specified size and class. * * @param size @@ -1683,13 +1708,13 @@ public final class BufferUtils { if (store == null) { store = new StringBuilder(); } - store.append("Existing buffers: ").append(bufs.size()).append("\n"); + store.append("Existing buffers: ").append(bufs.size()).append('\n'); store.append("(b: ").append(bBufs).append(" f: ").append(fBufs).append(" i: ").append(iBufs).append(" s: ") - .append(sBufs).append(" d: ").append(dBufs).append(")").append("\n"); + .append(sBufs).append(" d: ").append(dBufs).append(')').append('\n'); store.append("Total direct memory held: ").append(totalHeld / 1024).append("kb\n"); store.append("(b: ").append(bBufsM / 1024).append("kb f: ").append(fBufsM / 1024).append("kb i: ") .append(iBufsM / 1024).append("kb s: ").append(sBufsM / 1024).append("kb d: ").append(dBufsM / 1024) - .append("kb)").append("\n"); + .append("kb)").append('\n'); if (printStout) { System.out.println(store.toString()); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java index 87a3573..fdc3f7c 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/MeshCombiner.java @@ -264,9 +264,9 @@ public class MeshCombiner { totalVertices += md.getVertexCount(); // check for indices - if (useIndices || md.getIndexBuffer() != null) { + if (useIndices || md.getIndices() != null) { useIndices = true; - if (md.getIndexBuffer() != null) { + if (md.getIndices() != null) { totalIndices += md.getIndices().capacity(); } else { totalIndices += md.getVertexCount(); @@ -304,7 +304,7 @@ class IndexCombiner { public void addEntry(final MeshData source, final int vertexOffset) { // arrays or elements? - if (source.getIndexBuffer() == null) { + if (source.getIndices() == null) { // arrays... int offset = 0; int indexModeCounter = 0; diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java index aa9d32a..35c4a41 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/NormalGenerator.java @@ -723,7 +723,7 @@ public class NormalGenerator { for (int i = 0; i < 3; i++) { final Edge edge = edges[i]; if (edge == null) { - result.append("?"); + result.append('?'); } else { if (edge.newI0 > -1) { result.append(edge.newI0); @@ -735,7 +735,7 @@ public class NormalGenerator { result.append(", "); } } - result.append(")"); + result.append(')'); return result.toString(); } } diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java index 359c158..bd32181 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TabledLabelGrapher.java @@ -239,7 +239,7 @@ public class TabledLabelGrapher extends AbstractStatGrapher { final StringBuilder format = new StringBuilder(decimals > 0 ? "0.0" : "0"); for (int x = 1; x < decimals; x++) { - format.append("0"); + format.append('0'); } return new DecimalFormat(format.toString()).format(val) + post; diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java index 4b0e5d2..bc336d5 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/stat/graph/TimedAreaGrapher.java @@ -172,7 +172,7 @@ public class TimedAreaGrapher extends AbstractStatGrapher implements TableLinkab fb.rewind(); entry.area.getMeshData().setVertexBuffer(fb); entry.area.setScale(new Vector3(scaleWidth, scaleHeight, 1)); - entry.area.getMeshData().getIndexBuffer().limit(entry.verts.size()); + entry.area.getMeshData().getIndices().limit(entry.verts.size()); // - attach to root as needed if (!_graphRoot.equals(entry.area.getParent())) { @@ -272,11 +272,6 @@ public class TimedAreaGrapher extends AbstractStatGrapher implements TableLinkab area = new Mesh("a"); area.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(maxSamples * 2)); - area.getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(maxSamples * 2)); - for (int i = 0; i < maxSamples * 2; i++) { - area.getMeshData().getIndices().put(i); - } - area.getMeshData().getIndexBuffer().rewind(); area.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); area.getMeshData().setIndexMode(IndexMode.LineStrip); diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java index 56e5121..13d2554 100644 --- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java +++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/AnimationEntry.java @@ -75,7 +75,7 @@ public class AnimationEntry implements Savable { final StringBuilder sb = new StringBuilder(); for (final int frame : frames) { sb.append(frame); - sb.append(","); + sb.append(','); } return sb.substring(0, sb.length() - 1); } diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java index 48ff5ff..6917d70 100644 --- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java +++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/Particle.java @@ -250,9 +250,6 @@ public class Particle implements Savable { * (interpolating between start and end size), spin (using parent's spin speed) and current age of particle. If this * particle's age is greater than its lifespan, it is set to status DEAD. * </p> - * <p> - * Note that this only changes the parameters of the Particle, not the geometry the particle is associated with. - * </p> * * @param secondsPassed * number of seconds passed since last update. diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleMesh.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleMesh.java index c700471..2d70080 100644 --- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleMesh.java +++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleMesh.java @@ -126,7 +126,7 @@ public class ParticleMesh extends ParticleSystem { if (_particleType == ParticleSystem.ParticleType.GeomMesh && _useMeshTexCoords) { final MeshEmitter source = (MeshEmitter) getParticleEmitter(); final Mesh sourceMesh = source.getSource(); - final int index = sourceMesh.getMeshData().getIndexBuffer() != null ? sourceMesh.getMeshData() + final int index = sourceMesh.getMeshData().getIndices() != null ? sourceMesh.getMeshData() .getIndices().get(ind) : ind; BufferUtils.populateFromBuffer(temp, sourceMesh.getMeshData().getTextureCoords(0).getBuffer(), index); diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleSystem.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleSystem.java index 351470e..493e0f4 100644 --- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleSystem.java +++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/ParticleSystem.java @@ -46,8 +46,6 @@ import com.ardor3d.util.geom.BufferUtils; public abstract class ParticleSystem extends Node {
private static final Logger logger = Logger.getLogger(ParticleSystem.class.getName());
- protected static final long serialVersionUID = 2L;
-
public enum ParticleType {
Quad, Triangle, Point, Line, GeomMesh;
}
@@ -661,8 +659,8 @@ public abstract class ParticleSystem extends Node { vertices[x] = new Vector3();
final int vertIndex = mData.getVertexIndex(index, x, 0);
- BufferUtils.populateFromBuffer(vertices[x], mData.getVertexBuffer(),
- mData.getIndexBuffer() != null ? mData.getIndices().get(vertIndex) : vertIndex);
+ BufferUtils.populateFromBuffer(vertices[x], mData.getVertexBuffer(), mData.getIndices() != null ? mData
+ .getIndices().get(vertIndex) : vertIndex);
}
Triangle t = p.getTriangleModel();
if (t == null) {
diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java index 2e014d7..690532a 100644 --- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java +++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/particle/RampEntry.java @@ -166,7 +166,7 @@ public class RampEntry implements Savable { builder.append(convColorToHex(_color).toUpperCase()); builder.append(" a: "); builder.append((int) (_color.getAlpha() * 100)); - builder.append("%"); + builder.append('%'); } if (_size != DEFAULT_SIZE) { diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java index 9667b81..d23c48a 100644 --- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java +++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java @@ -11,7 +11,6 @@ package com.ardor3d.extension.effect.water;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.Stack;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -33,6 +32,7 @@ import com.ardor3d.math.type.ReadOnlyVector2; import com.ardor3d.math.type.ReadOnlyVector3;
import com.ardor3d.renderer.Camera;
import com.ardor3d.renderer.Renderer;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.util.ExtendedCamera;
import com.ardor3d.util.Timer;
@@ -52,7 +52,6 @@ public class ProjectedGrid extends Mesh { private FloatBuffer vertBuf;
private final FloatBuffer normBuf;
private final FloatBuffer texs;
- private IntBuffer indexBuffer;
private final ExtendedCamera mainCamera = new ExtendedCamera();
private final Camera projectorCamera = new Camera();
@@ -593,8 +592,8 @@ public class ProjectedGrid extends Mesh { // set up the indices
final int triangleQuantity = ((sizeX - 1) * (sizeY - 1)) * 2;
- indexBuffer = BufferUtils.createIntBuffer(triangleQuantity * 3);
- _meshData.setIndexBuffer(indexBuffer);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(triangleQuantity * 3, vertexCount - 1);
+ _meshData.setIndices(indices);
// go through entire array up to the second to last column.
for (int i = 0; i < (sizeX * (sizeY - 1)); i++) {
@@ -606,17 +605,17 @@ public class ProjectedGrid extends Mesh { // logger.info("i: "+i);
}
// set the top left corner.
- indexBuffer.put(i);
+ indices.put(i);
// set the bottom right corner.
- indexBuffer.put((1 + sizeX) + i);
+ indices.put((1 + sizeX) + i);
// set the top right corner.
- indexBuffer.put(1 + i);
+ indices.put(1 + i);
// set the top left corner
- indexBuffer.put(i);
+ indices.put(i);
// set the bottom left corner
- indexBuffer.put(sizeX + i);
+ indices.put(sizeX + i);
// set the bottom right corner
- indexBuffer.put((1 + sizeX) + i);
+ indices.put((1 + sizeX) + i);
}
}
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java index d60f204..32f638a 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleRunner.java @@ -642,7 +642,8 @@ public class ExampleRunner extends JFrame { * @see FileFilter
*/
public boolean accept(final File pathname) {
- return (pathname.isDirectory() && !pathname.getName().startsWith("."))
+ return (pathname.isDirectory() && (pathname.getName().length() == 0 || pathname.getName()
+ .charAt(0) != '.'))
|| (pathname.getName().endsWith(".class") && pathname.getName().indexOf('$') < 0);
}
};
@@ -661,7 +662,7 @@ public class ExampleRunner extends JFrame { if (name.endsWith(".class") && name.indexOf('$') < 0) {
String classname = name.substring(0, name.length() - ".class".length());
- if (classname.startsWith("/")) {
+ if (classname.length() > 0 && classname.charAt(0) == '/') {
classname = classname.substring(1);
}
classname = classname.replace('/', '.');
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LwjglHeadlessExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LwjglHeadlessExample.java index c0f147f..516b46a 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LwjglHeadlessExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/basic/LwjglHeadlessExample.java @@ -110,7 +110,8 @@ public class LwjglHeadlessExample implements Scene { */ public LwjglHeadlessExample() { // Setup our headless canvas for rendering. - settings = new DisplaySettings(800, 600, 0, 0, false); + // settings = new DisplaySettings(800, 600, 0, 0, 0, 16, 0, 4, false, false); // use this to try MSAA + settings = new DisplaySettings(800, 600, 0, 0, 0, 16, 0, 0, false, false); canvas = new LwjglHeadlessCanvas(settings, this); canvas.getRenderer().setBackgroundColor(ColorRGBA.BLACK_NO_ALPHA); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java index 6c7f15e..5020f5c 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/effect/ParallelSplitShadowMapExample.java @@ -1 +1 @@ -/**
* Copyright (c) 2008-2012 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
* 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>.
*/
package com.ardor3d.example.effect;
import com.ardor3d.bounding.BoundingBox;
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass;
import com.ardor3d.framework.Canvas;
import com.ardor3d.image.Texture;
import com.ardor3d.image.Texture2D;
import com.ardor3d.input.Key;
import com.ardor3d.input.logical.InputTrigger;
import com.ardor3d.input.logical.KeyPressedCondition;
import com.ardor3d.input.logical.TriggerAction;
import com.ardor3d.input.logical.TwoInputStates;
import com.ardor3d.light.DirectionalLight;
import com.ardor3d.light.Light;
import com.ardor3d.light.PointLight;
import com.ardor3d.math.Matrix3;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.Renderer;
import com.ardor3d.renderer.pass.BasicPassManager;
import com.ardor3d.renderer.pass.RenderPass;
import com.ardor3d.renderer.queue.RenderBucketType;
import com.ardor3d.renderer.state.BlendState;
import com.ardor3d.renderer.state.BlendState.TestFunction;
import com.ardor3d.renderer.state.CullState;
import com.ardor3d.renderer.state.MaterialState;
import com.ardor3d.renderer.state.MaterialState.ColorMaterial;
import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.scenegraph.Node;
import com.ardor3d.scenegraph.Spatial;
import com.ardor3d.scenegraph.controller.SpatialController;
import com.ardor3d.scenegraph.hint.CullHint;
import com.ardor3d.scenegraph.hint.LightCombineMode;
import com.ardor3d.scenegraph.hint.TextureCombineMode;
import com.ardor3d.scenegraph.shape.Box;
import com.ardor3d.scenegraph.shape.Quad;
import com.ardor3d.scenegraph.shape.Torus;
import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor;
import com.ardor3d.ui.text.BasicText;
import com.ardor3d.util.ReadOnlyTimer;
import com.ardor3d.util.TextureManager;
/**
* Example showing the parallel split shadow mapping technique. Requires GLSL support.
*/
@Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.ParallelSplitShadowMapExample", //
thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_ParallelSplitShadowMapExample.jpg", //
maxHeapMemory = 64)
public class ParallelSplitShadowMapExample extends ExampleBase {
/** Pssm shadow map pass. */
private ParallelSplitShadowMapPass _pssmPass;
/** Pass manager. */
private BasicPassManager _passManager;
/** Quads used for debug showing shadowmaps. */
private Quad _orthoQuad[];
/** Flag for turning on/off light movement. */
private boolean _updateLight = false;
/** Temp vec for updating light pos. */
private final Vector3 lightPosition = new Vector3(10000, 5000, 10000);
/** Text fields used to present info about the example. */
private final BasicText _exampleInfo[] = new BasicText[12];
/** Flag to make sure quads are updated on reinitialization of shadow renderer */
private boolean _quadsDirty = true;
/** Console fps output */
private double counter = 0;
private int frames = 0;
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(final String[] args) {
start(ParallelSplitShadowMapExample.class);
}
/**
* Update the PassManager and light.
*
* @param timer
* the application timer
*/
@Override
protected void updateExample(final ReadOnlyTimer timer) {
_passManager.updatePasses(timer.getTimePerFrame());
if (_updateLight) {
final double time = timer.getTimeInSeconds() * 0.2;
lightPosition.set(Math.sin(time) * 10000.0, 5000.0, Math.cos(time) * 10000.0);
}
counter += timer.getTimePerFrame();
frames++;
if (counter > 1) {
final double fps = (frames / counter);
counter = 0;
frames = 0;
System.out.printf("%7.1f FPS\n", fps);
}
}
/**
* Initialize pssm if needed. Update light position. Render scene.
*
* @param renderer
* the renderer
*/
@Override
protected void renderExample(final Renderer renderer) {
if (!_pssmPass.isInitialised()) {
_pssmPass.init(renderer);
}
updateQuadTextures(renderer);
// Update the shadowpass "light" position. Iow it's camera.
final Light light = _lightState.get(0);
if (light instanceof PointLight) {
((PointLight) light).setLocation(lightPosition);
} else if (light instanceof DirectionalLight) {
((DirectionalLight) light).setDirection(lightPosition.normalize(null).negateLocal());
}
_passManager.renderPasses(renderer);
}
/**
* Initialize pssm pass and scene.
*/
@Override
protected void initExample() {
// Setup main camera.
_canvas.setTitle("Parallel Split Shadow Maps - Example");
_canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(250, 200, -250));
_canvas.getCanvasRenderer()
.getCamera()
.setFrustumPerspective(
45.0,
(float) _canvas.getCanvasRenderer().getCamera().getWidth()
/ (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0, 10000);
_canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y);
_controlHandle.setMoveSpeed(200);
// Setup some standard states for the scene.
final CullState cullFrontFace = new CullState();
cullFrontFace.setEnabled(true);
cullFrontFace.setCullFace(CullState.Face.Back);
_root.setRenderState(cullFrontFace);
final TextureState ts = new TextureState();
ts.setEnabled(true);
ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true));
_root.setRenderState(ts);
final MaterialState ms = new MaterialState();
ms.setColorMaterial(ColorMaterial.Diffuse);
_root.setRenderState(ms);
_passManager = new BasicPassManager();
// setup some quads for debug viewing.
final RenderPass renderPass = new RenderPass();
final int quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10;
_orthoQuad = new Quad[ParallelSplitShadowMapPass._MAX_SPLITS];
for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) {
_orthoQuad[i] = new Quad("OrthoQuad", quadSize, quadSize);
_orthoQuad[i].setTranslation(new Vector3((quadSize / 2 + 5) + (quadSize + 5) * i, (quadSize / 2 + 5), 1));
_orthoQuad[i].getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
_orthoQuad[i].getSceneHints().setLightCombineMode(LightCombineMode.Off);
_orthoQuad[i].getSceneHints().setTextureCombineMode(TextureCombineMode.Replace);
_orthoQuad[i].getSceneHints().setCullHint(CullHint.Never);
renderPass.add(_orthoQuad[i]);
}
// Create scene objects.
setupTerrain();
final RenderPass rootPass = new RenderPass();
rootPass.add(_root);
_lightState.detachAll();
final DirectionalLight light = new DirectionalLight();
// final PointLight light = new PointLight();
light.setEnabled(true);
_lightState.attach(light);
// Create pssm pass
_pssmPass = new ParallelSplitShadowMapPass(light, 1024, 3);
_pssmPass.add(_root);
_pssmPass.setUseSceneTexturing(true);
_pssmPass.setUseObjectCullFace(true);
final Node occluders = setupOccluders();
_pssmPass.addOccluder(occluders);
// Populate passmanager with passes.
_passManager.add(rootPass);
_passManager.add(_pssmPass);
_passManager.add(renderPass);
// Setyp textfields for presenting example info.
final Node textNodes = new Node("Text");
renderPass.add(textNodes);
textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);
final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight();
for (int i = 0; i < _exampleInfo.length; i++) {
_exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
_exampleInfo[i].setTranslation(new Vector3(10, infoStartY - (i + 1) * 20, 0));
textNodes.attachChild(_exampleInfo[i]);
}
textNodes.updateGeometricState(0.0);
updateText();
// Register keyboard triggers for manipulating example
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setDrawShaderDebug(!_pssmPass.isDrawShaderDebug());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_updateLight = !_updateLight;
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setDrawDebug(!_pssmPass.isDrawDebug());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getNumOfSplits() > ParallelSplitShadowMapPass._MIN_SPLITS) {
_pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() - 1);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getNumOfSplits() < ParallelSplitShadowMapPass._MAX_SPLITS) {
_pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() + 1);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getShadowMapSize() > 1) {
_pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() / 2);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getShadowMapSize() < 2048) {
_pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() * 2);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final double maxShadowDistance = _pssmPass.getMaxShadowDistance();
if (maxShadowDistance > 200.0) {
_pssmPass.setMaxShadowDistance(maxShadowDistance - 100.0);
updateText();
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final double maxShadowDistance = _pssmPass.getMaxShadowDistance();
_pssmPass.setMaxShadowDistance(maxShadowDistance + 100.0);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setNumOfSplits(1);
_pssmPass.setShadowMapSize(1024);
updateText();
_quadsDirty = true;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setNumOfSplits(3);
_pssmPass.setShadowMapSize(512);
updateText();
_quadsDirty = true;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setUseSceneTexturing(!_pssmPass.isUseSceneTexturing());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setUseObjectCullFace(!_pssmPass.isUseObjectCullFace());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setEnabled(!_pssmPass.isEnabled());
updateText();
_quadsDirty = true;
}
}));
// Make sure all boundings are updated.
_root.acceptVisitor(new UpdateModelBoundVisitor(), false);
}
/**
* Setup debug quads to render pssm shadowmaps.
*/
private void updateQuadTextures(final Renderer r) {
if (!_quadsDirty) {
return;
}
_quadsDirty = false;
_pssmPass.reinit(r);
for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) {
final TextureState screen = new TextureState();
final Texture2D copy = new Texture2D();
copy.setTextureKey(_pssmPass.getShadowMapTexture(i).getTextureKey());
screen.setTexture(copy);
_orthoQuad[i].setRenderState(screen);
_orthoQuad[i].getSceneHints().setCullHint(CullHint.Never);
_orthoQuad[i].updateGeometricState(0.0);
}
for (int i = _pssmPass.getNumOfSplits(); i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) {
_orthoQuad[i].getSceneHints().setCullHint(CullHint.Always);
}
}
/**
* Update text information.
*/
private void updateText() {
_exampleInfo[0].setText("[0] Debug shader draw: " + _pssmPass.isDrawShaderDebug());
_exampleInfo[1].setText("[1] Update light: " + _updateLight);
_exampleInfo[2].setText("[2] Update main camera: " + _pssmPass.isUpdateMainCamera());
_exampleInfo[3].setText("[3] Debug draw: " + _pssmPass.isDrawDebug());
_exampleInfo[4].setText("[4/5] Number of splits: " + _pssmPass.getNumOfSplits());
_exampleInfo[5].setText("[6/7] Shadow map size: " + _pssmPass.getShadowMapSize());
_exampleInfo[6].setText("[8/9] Max shadow distance: " + _pssmPass.getMaxShadowDistance());
_exampleInfo[7].setText("[U] Setup 1 split of size 1024");
_exampleInfo[8].setText("[I] Setup 3 splits of size 512");
_exampleInfo[9].setText("[J] Use scene texturing: " + _pssmPass.isUseSceneTexturing());
_exampleInfo[10].setText("[K] Use object cull face: " + _pssmPass.isUseObjectCullFace());
_exampleInfo[11].setText("[SPACE] toggle PSSM pass: " + (_pssmPass.isEnabled() ? "enabled" : "disabled"));
}
/**
* Setup terrain.
*/
private void setupTerrain() {
final Box box = new Box("box", new Vector3(), 10000, 10, 10000);
box.setModelBound(new BoundingBox());
box.addController(new SpatialController<Box>() {
double timer = 0;
public void update(final double time, final Box caller) {
timer += time;
caller.setTranslation(Math.sin(timer) * 20.0, 0, Math.cos(timer) * 20.0);
}
});
_root.attachChild(box);
}
/**
* Setup occluders.
*/
private Node setupOccluders() {
final Node occluders = new Node("occs");
_root.attachChild(occluders);
for (int i = 0; i < 30; i++) {
final double w = Math.random() * 40 + 10;
final double y = Math.random() * 20 + 10;
final Box b = new Box("box", new Vector3(), w, y, w);
b.setModelBound(new BoundingBox());
final double x = Math.random() * 1000 - 500;
final double z = Math.random() * 1000 - 500;
b.setTranslation(new Vector3(x, y, z));
occluders.attachChild(b);
}
final Torus torusWithoutShadows = new Torus("torus", 32, 10, 15.0f, 20.0f);
torusWithoutShadows.setModelBound(new BoundingBox());
torusWithoutShadows.getSceneHints().setCastsShadows(false);
torusWithoutShadows.setTranslation(0, 50, -100);
occluders.attachChild(torusWithoutShadows);
final Torus torus = new Torus("torus", 64, 12, 10.0f, 15.0f);
torus.setModelBound(new BoundingBox());
occluders.attachChild(torus);
torus.addController(new SpatialController<Torus>() {
double timer = 0;
Matrix3 rotation = new Matrix3();
public void update(final double time, final Torus caller) {
timer += time;
caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 50.0 + 20.0, Math.cos(timer) * 40.0);
rotation.fromAngles(timer * 0.4, timer * 0.4, timer * 0.4);
caller.setRotation(rotation);
}
});
// Attach "billboard" with an alpha test.
occluders.attachChild(makeBillBoard());
return occluders;
}
private Spatial makeBillBoard() {
final Node billboard = new Node("bb");
billboard.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
final Quad q1 = new Quad("font block", 150, 200);
q1.setTranslation(0, 80, 0);
q1.setModelBound(new BoundingBox());
final CullState cs = new CullState();
cs.setCullFace(CullState.Face.None);
q1.setRenderState(cs);
billboard.attachChild(q1);
final TextureState ts = new TextureState();
ts.setEnabled(true);
ts.setTexture(TextureManager.load("fonts/OkasaSansSerif-35-medium-regular_00.png",
Texture.MinificationFilter.Trilinear, true));
billboard.setRenderState(ts);
final BlendState bs = new BlendState();
bs.setEnabled(true);
bs.setBlendEnabled(false);
bs.setTestEnabled(true);
bs.setTestFunction(TestFunction.GreaterThan);
bs.setReference(0.7f);
billboard.setRenderState(bs);
return billboard;
}
}
\ No newline at end of file +/**
* Copyright (c) 2008-2012 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
* 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>.
*/
package com.ardor3d.example.effect;
import com.ardor3d.bounding.BoundingBox;
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
import com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass;
import com.ardor3d.framework.Canvas;
import com.ardor3d.image.Texture;
import com.ardor3d.image.Texture2D;
import com.ardor3d.input.Key;
import com.ardor3d.input.logical.InputTrigger;
import com.ardor3d.input.logical.KeyPressedCondition;
import com.ardor3d.input.logical.TriggerAction;
import com.ardor3d.input.logical.TwoInputStates;
import com.ardor3d.light.DirectionalLight;
import com.ardor3d.light.Light;
import com.ardor3d.light.PointLight;
import com.ardor3d.math.Matrix3;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.Renderer;
import com.ardor3d.renderer.pass.BasicPassManager;
import com.ardor3d.renderer.pass.RenderPass;
import com.ardor3d.renderer.queue.RenderBucketType;
import com.ardor3d.renderer.state.BlendState;
import com.ardor3d.renderer.state.BlendState.TestFunction;
import com.ardor3d.renderer.state.CullState;
import com.ardor3d.renderer.state.MaterialState;
import com.ardor3d.renderer.state.MaterialState.ColorMaterial;
import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.scenegraph.Node;
import com.ardor3d.scenegraph.Spatial;
import com.ardor3d.scenegraph.controller.SpatialController;
import com.ardor3d.scenegraph.hint.CullHint;
import com.ardor3d.scenegraph.hint.LightCombineMode;
import com.ardor3d.scenegraph.hint.TextureCombineMode;
import com.ardor3d.scenegraph.shape.Box;
import com.ardor3d.scenegraph.shape.Quad;
import com.ardor3d.scenegraph.shape.Torus;
import com.ardor3d.scenegraph.visitor.UpdateModelBoundVisitor;
import com.ardor3d.ui.text.BasicText;
import com.ardor3d.util.ReadOnlyTimer;
import com.ardor3d.util.TextureManager;
/**
* Example showing the parallel split shadow mapping technique. Requires GLSL support.
*/
@Purpose(htmlDescriptionKey = "com.ardor3d.example.effect.ParallelSplitShadowMapExample", //
thumbnailPath = "com/ardor3d/example/media/thumbnails/effect_ParallelSplitShadowMapExample.jpg", //
maxHeapMemory = 64)
public class ParallelSplitShadowMapExample extends ExampleBase {
/** Pssm shadow map pass. */
private ParallelSplitShadowMapPass _pssmPass;
/** Pass manager. */
private BasicPassManager _passManager;
/** Quads used for debug showing shadowmaps. */
private Quad _orthoQuad[];
/** Flag for turning on/off light movement. */
private boolean _updateLight = false;
/** Temp vec for updating light pos. */
private final Vector3 lightPosition = new Vector3(10000, 5000, 10000);
/** Text fields used to present info about the example. */
private final BasicText _exampleInfo[] = new BasicText[12];
/** Flag to make sure quads are updated on reinitialization of shadow renderer */
private boolean _quadsDirty = true;
/** Console fps output */
private double counter = 0;
private int frames = 0;
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(final String[] args) {
start(ParallelSplitShadowMapExample.class);
}
/**
* Update the PassManager and light.
*
* @param timer
* the application timer
*/
@Override
protected void updateExample(final ReadOnlyTimer timer) {
_passManager.updatePasses(timer.getTimePerFrame());
if (_updateLight) {
final double time = timer.getTimeInSeconds() * 0.2;
lightPosition.set(Math.sin(time) * 10000.0, 5000.0, Math.cos(time) * 10000.0);
}
counter += timer.getTimePerFrame();
frames++;
if (counter > 1) {
final double fps = (frames / counter);
counter = 0;
frames = 0;
System.out.printf("%7.1f FPS\n", fps);
}
}
/**
* Initialize pssm if needed. Update light position. Render scene.
*
* @param renderer
* the renderer
*/
@Override
protected void renderExample(final Renderer renderer) {
if (!_pssmPass.isInitialised()) {
_pssmPass.init(renderer);
}
updateQuadTextures(renderer);
// Update the shadowpass "light" position. Iow it's camera.
final Light light = _lightState.get(0);
if (light instanceof PointLight) {
((PointLight) light).setLocation(lightPosition);
} else if (light instanceof DirectionalLight) {
((DirectionalLight) light).setDirection(lightPosition.normalize(null).negateLocal());
}
_passManager.renderPasses(renderer);
}
/**
* Initialize pssm pass and scene.
*/
@Override
protected void initExample() {
// Setup main camera.
_canvas.setTitle("Parallel Split Shadow Maps - Example");
_canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(250, 200, -250));
_canvas.getCanvasRenderer()
.getCamera()
.setFrustumPerspective(
45.0,
(float) _canvas.getCanvasRenderer().getCamera().getWidth()
/ (float) _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0, 10000);
_canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 0, 0), Vector3.UNIT_Y);
_controlHandle.setMoveSpeed(200);
// Setup some standard states for the scene.
final CullState cullFrontFace = new CullState();
cullFrontFace.setEnabled(true);
cullFrontFace.setCullFace(CullState.Face.Back);
_root.setRenderState(cullFrontFace);
final TextureState ts = new TextureState();
ts.setEnabled(true);
ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true));
_root.setRenderState(ts);
final MaterialState ms = new MaterialState();
ms.setColorMaterial(ColorMaterial.Diffuse);
_root.setRenderState(ms);
_passManager = new BasicPassManager();
// setup some quads for debug viewing.
final RenderPass renderPass = new RenderPass();
final int quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10;
_orthoQuad = new Quad[ParallelSplitShadowMapPass._MAX_SPLITS];
for (int i = 0; i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) {
_orthoQuad[i] = new Quad("OrthoQuad", quadSize, quadSize);
_orthoQuad[i].setTranslation(new Vector3((quadSize / 2 + 5) + (quadSize + 5) * i, (quadSize / 2 + 5), 1));
_orthoQuad[i].getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
_orthoQuad[i].getSceneHints().setLightCombineMode(LightCombineMode.Off);
_orthoQuad[i].getSceneHints().setTextureCombineMode(TextureCombineMode.Replace);
_orthoQuad[i].getSceneHints().setCullHint(CullHint.Never);
renderPass.add(_orthoQuad[i]);
}
// Create scene objects.
setupTerrain();
final RenderPass rootPass = new RenderPass();
rootPass.add(_root);
_lightState.detachAll();
final DirectionalLight light = new DirectionalLight();
// final PointLight light = new PointLight();
light.setEnabled(true);
_lightState.attach(light);
// Create pssm pass
_pssmPass = new ParallelSplitShadowMapPass(light, 1024, 3);
_pssmPass.add(_root);
_pssmPass.setUseSceneTexturing(true);
_pssmPass.setUseObjectCullFace(true);
final Node occluders = setupOccluders();
_pssmPass.addOccluder(occluders);
// Populate passmanager with passes.
_passManager.add(rootPass);
_passManager.add(_pssmPass);
_passManager.add(renderPass);
// Setup textfields for presenting example info.
final Node textNodes = new Node("Text");
renderPass.add(textNodes);
textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);
final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight();
for (int i = 0; i < _exampleInfo.length; i++) {
_exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
_exampleInfo[i].setTranslation(new Vector3(10, infoStartY - (i + 1) * 20, 0));
textNodes.attachChild(_exampleInfo[i]);
}
textNodes.updateGeometricState(0.0);
updateText();
// Register keyboard triggers for manipulating example
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setDrawShaderDebug(!_pssmPass.isDrawShaderDebug());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_updateLight = !_updateLight;
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setDrawDebug(!_pssmPass.isDrawDebug());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getNumOfSplits() > ParallelSplitShadowMapPass._MIN_SPLITS) {
_pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() - 1);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getNumOfSplits() < ParallelSplitShadowMapPass._MAX_SPLITS) {
_pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() + 1);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getShadowMapSize() > 1) {
_pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() / 2);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_pssmPass.getShadowMapSize() < 2048) {
_pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() * 2);
updateText();
_quadsDirty = true;
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final double maxShadowDistance = _pssmPass.getMaxShadowDistance();
if (maxShadowDistance > 200.0) {
_pssmPass.setMaxShadowDistance(maxShadowDistance - 100.0);
updateText();
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
final double maxShadowDistance = _pssmPass.getMaxShadowDistance();
_pssmPass.setMaxShadowDistance(maxShadowDistance + 100.0);
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setNumOfSplits(1);
_pssmPass.setShadowMapSize(1024);
updateText();
_quadsDirty = true;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setNumOfSplits(3);
_pssmPass.setShadowMapSize(512);
updateText();
_quadsDirty = true;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setUseSceneTexturing(!_pssmPass.isUseSceneTexturing());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setUseObjectCullFace(!_pssmPass.isUseObjectCullFace());
updateText();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
_pssmPass.setEnabled(!_pssmPass.isEnabled());
updateText();
_quadsDirty = true;
}
}));
// Make sure all boundings are updated.
_root.acceptVisitor(new UpdateModelBoundVisitor(), false);
}
/**
* Setup debug quads to render pssm shadowmaps.
*/
private void updateQuadTextures(final Renderer r) {
if (!_quadsDirty) {
return;
}
_quadsDirty = false;
_pssmPass.reinit(r);
for (int i = 0; i < _pssmPass.getNumOfSplits(); i++) {
final TextureState screen = new TextureState();
final Texture2D copy = new Texture2D();
copy.setTextureKey(_pssmPass.getShadowMapTexture(i).getTextureKey());
screen.setTexture(copy);
_orthoQuad[i].setRenderState(screen);
_orthoQuad[i].getSceneHints().setCullHint(CullHint.Never);
_orthoQuad[i].updateGeometricState(0.0);
}
for (int i = _pssmPass.getNumOfSplits(); i < ParallelSplitShadowMapPass._MAX_SPLITS; i++) {
_orthoQuad[i].getSceneHints().setCullHint(CullHint.Always);
}
}
/**
* Update text information.
*/
private void updateText() {
_exampleInfo[0].setText("[0] Debug shader draw: " + _pssmPass.isDrawShaderDebug());
_exampleInfo[1].setText("[1] Update light: " + _updateLight);
_exampleInfo[2].setText("[2] Update main camera: " + _pssmPass.isUpdateMainCamera());
_exampleInfo[3].setText("[3] Debug draw: " + _pssmPass.isDrawDebug());
_exampleInfo[4].setText("[4/5] Number of splits: " + _pssmPass.getNumOfSplits());
_exampleInfo[5].setText("[6/7] Shadow map size: " + _pssmPass.getShadowMapSize());
_exampleInfo[6].setText("[8/9] Max shadow distance: " + _pssmPass.getMaxShadowDistance());
_exampleInfo[7].setText("[U] Setup 1 split of size 1024");
_exampleInfo[8].setText("[I] Setup 3 splits of size 512");
_exampleInfo[9].setText("[J] Use scene texturing: " + _pssmPass.isUseSceneTexturing());
_exampleInfo[10].setText("[K] Use object cull face: " + _pssmPass.isUseObjectCullFace());
_exampleInfo[11].setText("[SPACE] toggle PSSM pass: " + (_pssmPass.isEnabled() ? "enabled" : "disabled"));
}
/**
* Setup terrain.
*/
private void setupTerrain() {
final Box box = new Box("box", new Vector3(), 10000, 10, 10000);
box.setModelBound(new BoundingBox());
box.addController(new SpatialController<Box>() {
double timer = 0;
public void update(final double time, final Box caller) {
timer += time;
caller.setTranslation(Math.sin(timer) * 20.0, 0, Math.cos(timer) * 20.0);
}
});
_root.attachChild(box);
}
/**
* Setup occluders.
*/
private Node setupOccluders() {
final Node occluders = new Node("occs");
_root.attachChild(occluders);
for (int i = 0; i < 30; i++) {
final double w = Math.random() * 40 + 10;
final double y = Math.random() * 20 + 10;
final Box b = new Box("box", new Vector3(), w, y, w);
b.setModelBound(new BoundingBox());
final double x = Math.random() * 1000 - 500;
final double z = Math.random() * 1000 - 500;
b.setTranslation(new Vector3(x, y, z));
occluders.attachChild(b);
}
final Torus torusWithoutShadows = new Torus("torus", 32, 10, 15.0f, 20.0f);
torusWithoutShadows.setModelBound(new BoundingBox());
torusWithoutShadows.getSceneHints().setCastsShadows(false);
torusWithoutShadows.setTranslation(0, 50, -100);
occluders.attachChild(torusWithoutShadows);
final Torus torus = new Torus("torus", 64, 12, 10.0f, 15.0f);
torus.setModelBound(new BoundingBox());
occluders.attachChild(torus);
torus.addController(new SpatialController<Torus>() {
double timer = 0;
Matrix3 rotation = new Matrix3();
public void update(final double time, final Torus caller) {
timer += time;
caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 50.0 + 20.0, Math.cos(timer) * 40.0);
rotation.fromAngles(timer * 0.4, timer * 0.4, timer * 0.4);
caller.setRotation(rotation);
}
});
// Attach "billboard" with an alpha test.
occluders.attachChild(makeBillBoard());
return occluders;
}
private Spatial makeBillBoard() {
final Node billboard = new Node("bb");
billboard.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
final Quad q1 = new Quad("font block", 150, 200);
q1.setTranslation(0, 80, 0);
q1.setModelBound(new BoundingBox());
final CullState cs = new CullState();
cs.setCullFace(CullState.Face.None);
q1.setRenderState(cs);
billboard.attachChild(q1);
final TextureState ts = new TextureState();
ts.setEnabled(true);
ts.setTexture(TextureManager.load("fonts/OkasaSansSerif-35-medium-regular_00.png",
Texture.MinificationFilter.Trilinear, true));
billboard.setRenderState(ts);
final BlendState bs = new BlendState();
bs.setEnabled(true);
bs.setBlendEnabled(false);
bs.setTestEnabled(true);
bs.setTestFunction(TestFunction.GreaterThan);
bs.setReference(0.7f);
billboard.setRenderState(bs);
return billboard;
}
}
\ No newline at end of file diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java index c6f3872..11fe9f4 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ExportImportExample.java @@ -13,7 +13,6 @@ package com.ardor3d.example.pipeline; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -25,6 +24,7 @@ import com.ardor3d.math.Vector3; import com.ardor3d.renderer.IndexMode;
import com.ardor3d.renderer.state.TextureState;
import com.ardor3d.renderer.state.WireframeState;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.MeshData;
import com.ardor3d.scenegraph.Node;
@@ -177,20 +177,20 @@ public class ExportImportExample extends ExampleBase { meshData.setVertexBuffer(vertexBuffer);
- final IntBuffer indexBuffer = BufferUtils.createIntBuffer(18);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(18, vertexBuffer.capacity() - 1);
// Strips
- indexBuffer.put(0).put(3).put(1).put(2);
- indexBuffer.put(4).put(7).put(5).put(6);
+ indices.put(0).put(3).put(1).put(2);
+ indices.put(4).put(7).put(5).put(6);
// Quad
- indexBuffer.put(8).put(9).put(10).put(11);
+ indices.put(8).put(9).put(10).put(11);
// Triangles
- indexBuffer.put(12).put(13).put(15);
- indexBuffer.put(13).put(15).put(14);
+ indices.put(12).put(13).put(15);
+ indices.put(13).put(15).put(14);
- meshData.setIndexBuffer(indexBuffer);
+ meshData.setIndices(indices);
// Setting sub primitive data
final int[] indexLengths = new int[] { 4, 4, 4, 6 };
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java index b1d78aa..38612f2 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/pipeline/ScenegraphTree.java @@ -70,27 +70,27 @@ public class ScenegraphTree { str.append(spatial.getName()); str.append(" - "); - str.append(spatial.getClass().getName()).append("\n"); + str.append(spatial.getClass().getName()).append('\n'); if (spatial instanceof Mesh) { final Mesh mesh = (Mesh) spatial; str.append("Primitives: "); - str.append(mesh.getMeshData().getTotalPrimitiveCount()).append("\n"); + str.append(mesh.getMeshData().getTotalPrimitiveCount()).append('\n'); str.append("Index mode: "); - str.append(mesh.getMeshData().getIndexMode(0)).append("\n"); + str.append(mesh.getMeshData().getIndexMode(0)).append('\n'); } - str.append(spatial.getTransform()).append("\n"); + str.append(spatial.getTransform()).append('\n'); if (spatial.getWorldBound() != null) { - str.append(spatial.getWorldBound()).append("\n"); + str.append(spatial.getWorldBound()).append('\n'); } - str.append("\n"); + str.append('\n'); final SceneHints sceneHints = spatial.getSceneHints(); str.append("Cull hint: "); - str.append(sceneHints.getCullHint()).append("\n"); + str.append(sceneHints.getCullHint()).append('\n'); str.append("Bucket: "); - str.append(sceneHints.getRenderBucketType()).append("\n"); + str.append(sceneHints.getRenderBucketType()).append('\n'); textArea.setText(str.toString()); } diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java index 361c39c..c9a859d 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/DegenerateTrianglesExample.java @@ -11,7 +11,6 @@ package com.ardor3d.example.renderer; import java.nio.FloatBuffer; -import java.nio.IntBuffer; import com.ardor3d.example.ExampleBase; import com.ardor3d.example.Purpose; @@ -28,6 +27,7 @@ import com.ardor3d.math.Vector3; import com.ardor3d.renderer.IndexMode; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.TextureState; +import com.ardor3d.scenegraph.IndexBufferData; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.MeshData; import com.ardor3d.scenegraph.hint.CullHint; @@ -128,7 +128,8 @@ public class DegenerateTrianglesExample extends ExampleBase { final FloatBuffer normalBuffer = BufferUtils.createVector3Buffer(totalSize); final FloatBuffer textureBuffer = BufferUtils.createVector2Buffer(totalSize); - final IntBuffer indexBuffer = BufferUtils.createIntBuffer((ySize - 1) * xSize * 2); + final IndexBufferData<?> indices = BufferUtils.createIndexBufferData((ySize - 1) * xSize * 2, + vertexBuffer.capacity() - 1); final int[] indexLengths = new int[ySize - 1]; for (int y = 0; y < ySize; y++) { @@ -142,8 +143,8 @@ public class DegenerateTrianglesExample extends ExampleBase { for (int y = 0; y < ySize - 1; y++) { for (int x = 0; x < xSize; x++) { final int index = y * xSize + x; - indexBuffer.put(index); - indexBuffer.put(index + xSize); + indices.put(index); + indices.put(index + xSize); } indexLengths[y] = xSize * 2; } @@ -152,7 +153,7 @@ public class DegenerateTrianglesExample extends ExampleBase { meshData.setNormalBuffer(normalBuffer); meshData.setTextureBuffer(textureBuffer, 0); - meshData.setIndexBuffer(indexBuffer); + meshData.setIndices(indices); meshData.setIndexLengths(indexLengths); meshData.setIndexMode(IndexMode.TriangleStrip); @@ -167,7 +168,8 @@ public class DegenerateTrianglesExample extends ExampleBase { final FloatBuffer normalBuffer = BufferUtils.createVector3Buffer(totalSize); final FloatBuffer textureBuffer = BufferUtils.createVector2Buffer(totalSize); - final IntBuffer indexBuffer = BufferUtils.createIntBuffer((ySize - 1) * xSize * 2 + (ySize - 1) * 2); + final IndexBufferData<?> indices = BufferUtils.createIndexBufferData((ySize - 1) * xSize * 2 + (ySize - 1) * 2, + vertexBuffer.capacity() - 1); for (int y = 0; y < ySize; y++) { for (int x = 0; x < xSize; x++) { @@ -180,20 +182,20 @@ public class DegenerateTrianglesExample extends ExampleBase { for (int y = 0; y < ySize - 1; y++) { for (int x = 0; x < xSize; x++) { final int index = y * xSize + x; - indexBuffer.put(index); - indexBuffer.put(index + xSize); + indices.put(index); + indices.put(index + xSize); } final int index = (y + 1) * xSize; - indexBuffer.put(index + xSize - 1); - indexBuffer.put(index); + indices.put(index + xSize - 1); + indices.put(index); } meshData.setVertexBuffer(vertexBuffer); meshData.setNormalBuffer(normalBuffer); meshData.setTextureBuffer(textureBuffer, 0); - meshData.setIndexBuffer(indexBuffer); + meshData.setIndices(indices); meshData.setIndexMode(IndexMode.TriangleStrip); return mesh; diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java index 310e39d..35486ce 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/renderer/MultiStripExample.java @@ -11,7 +11,6 @@ package com.ardor3d.example.renderer;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import com.ardor3d.example.ExampleBase;
import com.ardor3d.example.Purpose;
@@ -19,6 +18,7 @@ import com.ardor3d.intersection.PickData; import com.ardor3d.intersection.PrimitivePickResults;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.IndexMode;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.MeshData;
import com.ardor3d.util.geom.BufferUtils;
@@ -91,20 +91,20 @@ public class MultiStripExample extends ExampleBase { meshData.setVertexBuffer(vertexBuffer);
- final IntBuffer indexBuffer = BufferUtils.createIntBuffer(18);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(18, vertexBuffer.capacity() - 1);
// Strips
- indexBuffer.put(0).put(3).put(1).put(2);
- indexBuffer.put(4).put(7).put(5).put(6);
+ indices.put(0).put(3).put(1).put(2);
+ indices.put(4).put(7).put(5).put(6);
// Quad
- indexBuffer.put(8).put(9).put(10).put(11);
+ indices.put(8).put(9).put(10).put(11);
// Triangles
- indexBuffer.put(12).put(13).put(15);
- indexBuffer.put(13).put(14).put(15);
+ indices.put(12).put(13).put(15);
+ indices.put(13).put(14).put(15);
- meshData.setIndexBuffer(indexBuffer);
+ meshData.setIndices(indices);
// Setting sub primitive data
final int[] indexLengths = new int[] { 4, 4, 4, 6 };
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java index 0cfc59a..e41cae6 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java @@ -151,7 +151,7 @@ public class ObjImporter { } // ignore comments. goto next line - if (line.startsWith("#")) { + if (line.length() > 0 && line.charAt(0) == '#') { continue; } @@ -421,7 +421,7 @@ public class ObjImporter { } // ignore comments. goto next line - if (line.startsWith("#") || line.length() == 0) { + if (line.length() == 0 || line.charAt(0) == '#') { continue; } diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java index 887f415..6609544 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java @@ -12,11 +12,11 @@ package com.ardor3d.extension.model.util; import java.io.IOException;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.logging.Logger;
import com.ardor3d.scenegraph.FloatBufferData;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.Spatial;
import com.ardor3d.scenegraph.controller.ComplexSpatialController;
@@ -379,17 +379,18 @@ public class KeyframeController<T extends Spatial> extends ComplexSpatialControl dcNorms.put(mmNorms);
dcNorms.flip();
}
- if (_morphMesh.getMeshData().getIndexBuffer() != null) {
- IntBuffer dcInds = (IntBuffer) dataCopy.getMeshData().getIndexBuffer();
+ if (_morphMesh.getMeshData().getIndices() != null) {
+ IndexBufferData<?> dcInds = dataCopy.getMeshData().getIndices();
if (dcInds != null) {
- dcInds.clear();
+ dcInds.rewind();
}
- final IntBuffer mmInds = (IntBuffer) _morphMesh.getMeshData().getIndexBuffer();
+ final IndexBufferData<?> mmInds = _morphMesh.getMeshData().getIndices();
mmInds.clear();
- if (dcInds == null || dcInds.capacity() != mmInds.capacity()) {
- dcInds = BufferUtils.createIntBuffer(mmInds.capacity());
+ if (dcInds == null || dcInds.capacity() != mmInds.capacity() || dcInds.getClass() != mmInds.getClass()) {
+ dcInds = BufferUtils.createIndexBufferData(mmInds.capacity(), _morphMesh.getMeshData()
+ .getVertexBuffer().capacity() - 1);
dcInds.clear();
- dataCopy.getMeshData().setIndexBuffer(dcInds);
+ dataCopy.getMeshData().setIndices(dcInds);
}
dcInds.put(mmInds);
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java index 8a9f483..558d9fb 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/useful/TrailMesh.java @@ -19,7 +19,6 @@ import com.ardor3d.math.Vector3; import com.ardor3d.math.type.ReadOnlyVector3; import com.ardor3d.renderer.IndexMode; import com.ardor3d.scenegraph.FloatBufferData; -import com.ardor3d.scenegraph.IndexBufferData; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.util.export.InputCapsule; import com.ardor3d.util.export.OutputCapsule; @@ -299,13 +298,6 @@ public class TrailMesh extends Mesh { private void setIndexData() { getMeshData().setIndexMode(IndexMode.TriangleStrip); - if (getMeshData().getIndexBuffer() == null) { - getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(trailVertices)); - final IndexBufferData<?> indexBuf = getMeshData().getIndices(); - for (int i = 0; i < trailVertices; i++) { - indexBuf.put(i); - } - } } @Override diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java index c23b8a0..78ccd40 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java @@ -19,6 +19,11 @@ import com.ardor3d.util.Ardor3dException; public class CapsUtil { public static GLCapabilities getCapsForSettings(final DisplaySettings settings) { + return getCapsForSettings(settings, true, false, false, false); + } + + public static GLCapabilities getCapsForSettings(final DisplaySettings settings, final boolean onscreen, + final boolean bitmapRequested, final boolean pbufferRequested, final boolean fboRequested) { // Validate window dimensions. if (settings.getWidth() <= 0 || settings.getHeight() <= 0) { @@ -40,6 +45,25 @@ public class CapsUtil { caps.setSampleBuffers(settings.getSamples() != 0); caps.setStereo(settings.isStereo()); caps.setStencilBits(settings.getStencilBits()); + switch (settings.getColorDepth()) { + case 32: + case 24: + caps.setRedBits(8); + caps.setBlueBits(8); + caps.setGreenBits(8); + break; + case 16: + caps.setRedBits(4); + caps.setBlueBits(4); + caps.setGreenBits(4); + break; + } + caps.setOnscreen(onscreen); + if (!onscreen) { + caps.setBitmap(bitmapRequested); + caps.setPBuffer(pbufferRequested); + caps.setFBO(fboRequested); + } return caps; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java index 5c95cd8..58fef71 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java @@ -10,10 +10,12 @@ package com.ardor3d.framework.jogl; +import java.lang.reflect.InvocationTargetException; import java.util.concurrent.CountDownLatch; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLRunnable; + import javax.media.opengl.awt.GLCanvas; +import javax.swing.SwingUtilities; + import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; @@ -21,7 +23,7 @@ import com.ardor3d.framework.DisplaySettings; /** * FIXME there is still a deadlock when using several instances of this class in the same container, see JOGL bug 572 * Rather use JoglNewtAwtCanvas in this case. - * + * */ public class JoglAwtCanvas extends GLCanvas implements Canvas { @@ -31,12 +33,15 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { private boolean _inited = false; private final DisplaySettings _settings; - + private final JoglDrawerRunnable _drawerGLRunnable; + private final JoglInitializerRunnable _initializerRunnable; + public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) { super(CapsUtil.getCapsForSettings(settings)); _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); + _initializerRunnable = new JoglInitializerRunnable(this, settings); _settings = settings; _canvasRenderer = canvasRenderer; @@ -49,25 +54,23 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { @MainThread public void init() { - if (_inited) { + if (_inited) { return; } - - // Make the window visible to realize the OpenGL surface. - setVisible(true); - - // Request the focus here as it cannot work when the window is not visible - requestFocus(); - - _canvasRenderer.setContext(getContext()); - - invoke(true, new GLRunnable() { - @Override - public boolean run(GLAutoDrawable glAutoDrawable) { - _canvasRenderer.init(_settings, true);// true - do swap in renderer. - return true; + + // Calling setVisible(true) on the GLCanvas not from the AWT-EDT can freeze the Intel GPU under Windows + if (!SwingUtilities.isEventDispatchThread()) { + try { + SwingUtilities.invokeAndWait(_initializerRunnable); + } catch (final InterruptedException ex) { + ex.printStackTrace(); + } catch (final InvocationTargetException ex) { + ex.printStackTrace(); } - }); + } else { + _initializerRunnable.run(); + } + _inited = true; } @@ -77,7 +80,7 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { } if (isShowing()) { - invoke(true, _drawerGLRunnable); + invoke(true, _drawerGLRunnable); } if (latch != null) { latch.countDown(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java index e6d8b00..70aacb4 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java @@ -18,7 +18,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import javax.media.opengl.glu.GLU;
import com.ardor3d.annotation.MainThread;
import com.ardor3d.framework.CanvasRenderer;
@@ -27,11 +26,11 @@ import com.ardor3d.framework.Scene; import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.Camera;
+import com.ardor3d.renderer.Camera.ProjectionMode;
import com.ardor3d.renderer.ContextCapabilities;
import com.ardor3d.renderer.ContextManager;
import com.ardor3d.renderer.RenderContext;
import com.ardor3d.renderer.Renderer;
-import com.ardor3d.renderer.Camera.ProjectionMode;
import com.ardor3d.renderer.jogl.JoglContextCapabilities;
import com.ardor3d.renderer.jogl.JoglRenderer;
import com.ardor3d.util.Ardor3dException;
@@ -72,42 +71,45 @@ public class JoglCanvasRenderer implements CanvasRenderer { int value = GLContext.CONTEXT_NOT_CURRENT;
int attempt = 0;
do {
- try {
- value = _context.makeCurrent();
- } catch(GLException gle) {
- gle.printStackTrace();
- } finally {
- attempt++;
- if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) {
+ try {
+ value = _context.makeCurrent();
+ } catch (final GLException gle) {
+ gle.printStackTrace();
+ } finally {
+ attempt++;
+ if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) {
// failed, throw exception
throw new Ardor3dException("Failed to claim OpenGL context.");
}
- }
- try {
- Thread.sleep(5);
- } catch (final InterruptedException e1) {
- e1.printStackTrace();
- }
- }
- while(value == GLContext.CONTEXT_NOT_CURRENT);
- if (value == GLContext.CONTEXT_CURRENT_NEW) {
- ContextManager.getCurrentContext().contextLost();
+ }
+ try {
+ Thread.sleep(5);
+ } catch (final InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ } while (value == GLContext.CONTEXT_NOT_CURRENT);
+ if (ContextManager.getCurrentContext() != null) {
+ if (value == GLContext.CONTEXT_CURRENT_NEW) {
+ ContextManager.getCurrentContext().contextLost();
+
+ // Whenever the context is created or replaced, the GL chain
+ // is lost. Debug will have to be added if desired.
+ _debugEnabled = false;
+ }
- // Whenever the context is created or replaced, the GL chain
- // is lost. Debug will have to be added if desired.
- _debugEnabled = false;
+ if (ContextManager.getContextForKey(_context) != null) {
+ ContextManager.switchContext(_context);
+ }
}
-
- ContextManager.switchContext(_context);
}
public void releaseCurrentContext() {
- if (_context.equals(GLContext.getCurrent())) {
+ if (_context.equals(GLContext.getCurrent())) {
try {
- _context.release();
- } catch(GLException gle) {
- gle.printStackTrace();
- }
+ _context.release();
+ } catch (final GLException gle) {
+ gle.printStackTrace();
+ }
}
}
@@ -123,52 +125,53 @@ public class JoglCanvasRenderer implements CanvasRenderer { _context = GLDrawableFactory.getFactory(GLProfile.getMaxFixedFunc(true)).createExternalGLContext();
}
- _context.makeCurrent();
+ makeCurrentContext();
try {
- // Look up a shared context, if a shared JoglCanvasRenderer is given.
- RenderContext sharedContext = null;
- if (settings.getShareContext() != null) {
- sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext()
- .getContextKey());
- }
-
- final ContextCapabilities caps = createContextCapabilities();
- _currentContext = new RenderContext(_context, caps, sharedContext);
-
- ContextManager.addContext(_context, _currentContext);
- ContextManager.switchContext(_context);
-
- _renderer = new JoglRenderer();
-
- if (settings.getSamples() != 0 && caps.isMultisampleSupported()) {
- final GL gl = GLU.getCurrentGL();
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
-
- _renderer.setBackgroundColor(ColorRGBA.BLACK);
-
- if (_camera == null) {
- /** Set up how our camera sees. */
- _camera = new Camera(settings.getWidth(), settings.getHeight());
- _camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1, 1000);
- _camera.setProjectionMode(ProjectionMode.Perspective);
-
- final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f);
- final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f);
- final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f);
- final Vector3 dir = new Vector3(0.0f, 0f, -1.0f);
- /** Move our camera to a correct place and orientation. */
- _camera.setFrame(loc, left, up, dir);
- } else {
- // use new width and height to set ratio.
- _camera.setFrustumPerspective(_camera.getFovY(),
- (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(), _camera
- .getFrustumFar());
- }
+ // Look up a shared context, if a shared JoglCanvasRenderer is given.
+ RenderContext sharedContext = null;
+ if (settings.getShareContext() != null) {
+ sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext()
+ .getContextKey());
+ }
+
+ final ContextCapabilities caps = createContextCapabilities();
+ _currentContext = new RenderContext(_context, caps, sharedContext);
+
+ ContextManager.addContext(_context, _currentContext);
+ ContextManager.switchContext(_context);
+
+ _renderer = new JoglRenderer();
+
+ if (settings.getSamples() != 0 && caps.isMultisampleSupported()) {
+ final GL gl = GLContext.getCurrentGL();
+ gl.glEnable(GL.GL_MULTISAMPLE);
+ }
+
+ _renderer.setBackgroundColor(ColorRGBA.BLACK);
+
+ if (_camera == null) {
+ /** Set up how our camera sees. */
+ _camera = new Camera(settings.getWidth(), settings.getHeight());
+ _camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1,
+ 1000);
+ _camera.setProjectionMode(ProjectionMode.Perspective);
+
+ final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f);
+ final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f);
+ final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f);
+ final Vector3 dir = new Vector3(0.0f, 0f, -1.0f);
+ /** Move our camera to a correct place and orientation. */
+ _camera.setFrame(loc, left, up, dir);
+ } else {
+ // use new width and height to set ratio.
+ _camera.setFrustumPerspective(_camera.getFovY(),
+ (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(),
+ _camera.getFrustumFar());
+ }
} finally {
- _context.release();
+ releaseCurrentContext();
}
}
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglInitializerRunnable.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglInitializerRunnable.java new file mode 100644 index 0000000..2a93f38 --- /dev/null +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglInitializerRunnable.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2008-2010 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * 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>. + */ + +package com.ardor3d.framework.jogl; + +import com.ardor3d.framework.DisplaySettings; + +public class JoglInitializerRunnable implements Runnable { + + private final JoglAwtCanvas _joglAwtCanvas; + + private final DisplaySettings _settings; + + public JoglInitializerRunnable(final JoglAwtCanvas joglAwtCanvas, final DisplaySettings settings) { + _joglAwtCanvas = joglAwtCanvas; + _settings = settings; + } + + @Override + public void run() { + // Make the window visible to realize the OpenGL surface. + _joglAwtCanvas.setVisible(true); + // Force the realization + _joglAwtCanvas.display(); + if (!_joglAwtCanvas.getDelegatedDrawable().isRealized()) { + throw new RuntimeException("The heavyweight AWT drawable cannot be realized"); + } + // Request the focus here as it cannot work when the window is not visible + _joglAwtCanvas.requestFocus(); + // The OpenGL context has been created after the realization of the surface + _joglAwtCanvas.getCanvasRenderer().setContext(_joglAwtCanvas.getContext()); + // As the canvas renderer knows the OpenGL context, it can be initialized + _joglAwtCanvas.getCanvasRenderer().init(_settings, true); + } +}
\ No newline at end of file diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java index 3333d90..9490dea 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java @@ -12,10 +12,12 @@ package com.ardor3d.framework.jogl; import java.util.List; import java.util.concurrent.CountDownLatch; + import javax.media.nativewindow.util.Dimension; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLContext; import javax.media.opengl.GLRunnable; + import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.NativeCanvas; @@ -30,100 +32,105 @@ import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.util.ScreenModeUtil; - public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { - + private final JoglCanvasRenderer _canvasRenderer; private boolean _inited = false; private boolean _isClosing = false; private final DisplaySettings _settings; - + private final JoglDrawerRunnable _drawerGLRunnable; - + private final GLWindow _newtWindow; public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings) { - _newtWindow = GLWindow.create(CapsUtil.getCapsForSettings(settings)); + this(canvasRenderer, settings, true, false, false, false); + } + + public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings, + final boolean onscreen, final boolean bitmapRequested, final boolean pbufferRequested, + final boolean fboRequested) { + _newtWindow = GLWindow.create(CapsUtil.getCapsForSettings(settings, onscreen, bitmapRequested, + pbufferRequested, fboRequested)); _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); _settings = settings; - _canvasRenderer = canvasRenderer; + _canvasRenderer = canvasRenderer; setAutoSwapBufferMode(false); } - + /** - * Applies all settings not related to OpenGL (screen resolution, - * screen size, etc...) + * Applies all settings not related to OpenGL (screen resolution, screen size, etc...) * */ private void applySettings() { _newtWindow.setUndecorated(_settings.isFullScreen()); - _newtWindow.setFullscreen(_settings.isFullScreen()); - //FIXME Ardor3D does not allow to change the resolution + _newtWindow.setFullscreen(_settings.isFullScreen()); + // FIXME Ardor3D does not allow to change the resolution /** - * uses the filtering relying on resolution with the size to fetch only the screen - * mode matching with the current resolution + * uses the filtering relying on resolution with the size to fetch only the screen mode matching with the + * current resolution */ if (_settings.isFullScreen()) { - Screen screen = _newtWindow.getScreen(); - List<ScreenMode> screenModes = screen.getScreenModes(); - //the resolution is provided by the user - Dimension dimension=new Dimension(_settings.getWidth(),_settings.getHeight()); - screenModes = ScreenModeUtil.filterByResolution(screenModes,dimension); + final Screen screen = _newtWindow.getScreen(); + List<ScreenMode> screenModes = screen.getScreenModes(); + // the resolution is provided by the user + final Dimension dimension = new Dimension(_settings.getWidth(), _settings.getHeight()); + screenModes = ScreenModeUtil.filterByResolution(screenModes, dimension); screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); if (_settings.getFrequency() > 0) { - screenModes = ScreenModeUtil.filterByRate(screenModes, _settings.getFrequency()); - } else { - screenModes = ScreenModeUtil.getHighestAvailableRate(screenModes); - } + screenModes = ScreenModeUtil.filterByRate(screenModes, _settings.getFrequency()); + } else { + screenModes = ScreenModeUtil.getHighestAvailableRate(screenModes); + } screen.setCurrentScreenMode(screenModes.get(0)); } } - - public void addKeyListener(KeyListener keyListener) { + + public void addKeyListener(final KeyListener keyListener) { _newtWindow.addKeyListener(keyListener); } - - public void addMouseListener(MouseListener mouseListener) { + + public void addMouseListener(final MouseListener mouseListener) { _newtWindow.addMouseListener(mouseListener); } - - public void addWindowListener(WindowListener windowListener) { + + public void addWindowListener(final WindowListener windowListener) { _newtWindow.addWindowListener(windowListener); } - + public GLContext getContext() { return _newtWindow.getContext(); } - + public int getWidth() { return _newtWindow.getWidth(); } - + public int getHeight() { return _newtWindow.getHeight(); } - + public int getX() { return _newtWindow.getX(); } - + public int getY() { return _newtWindow.getY(); } - + public boolean isVisible() { return _newtWindow.isVisible(); } - - public void setSize(int width, int height) { + + public void setSize(final int width, final int height) { _newtWindow.setTopLevelSize(width, height); } - - public void setVisible(boolean visible) { + + public void setVisible(final boolean visible) { _newtWindow.setVisible(visible); } - - public void setAutoSwapBufferMode(boolean autoSwapBufferModeEnabled) { + + public void setAutoSwapBufferMode(final boolean autoSwapBufferModeEnabled) { _newtWindow.setAutoSwapBufferMode(autoSwapBufferModeEnabled); } @@ -138,23 +145,23 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { public void windowDestroyNotify(final WindowEvent e) { _isClosing = true; } - -// public void windowResized(final WindowEvent e) { -// _newtWindow.invoke(true, new GLRunnable() { -// -// @Override -// public boolean run(GLAutoDrawable glAutoDrawable) { -// _canvasRenderer._camera.resize(_newtWindow.getWidth(), _newtWindow.getHeight()); -// _canvasRenderer._camera.setFrustumPerspective(_canvasRenderer._camera.getFovY(), -// (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(), -// _canvasRenderer._camera.getFrustumNear(), -// _canvasRenderer._camera.getFrustumFar()); -// return true; -// } -// }); -// } + + // public void windowResized(final WindowEvent e) { + // _newtWindow.invoke(true, new GLRunnable() { + // + // @Override + // public boolean run(GLAutoDrawable glAutoDrawable) { + // _canvasRenderer._camera.resize(_newtWindow.getWidth(), _newtWindow.getHeight()); + // _canvasRenderer._camera.setFrustumPerspective(_canvasRenderer._camera.getFovY(), + // (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(), + // _canvasRenderer._camera.getFrustumNear(), + // _canvasRenderer._camera.getFrustumFar()); + // return true; + // } + // }); + // } }); - + // Set the size very early to prevent the default one from being used (typically when exiting full screen mode) setSize(_settings.getWidth(), _settings.getHeight()); // Make the window visible to realize the OpenGL surface. @@ -162,12 +169,12 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { // Request the focus here as it cannot work when the window is not visible _newtWindow.requestFocus(); applySettings(); - + _canvasRenderer.setContext(getContext()); - + _newtWindow.invoke(true, new GLRunnable() { @Override - public boolean run(GLAutoDrawable glAutoDrawable) { + public boolean run(final GLAutoDrawable glAutoDrawable) { _canvasRenderer.init(_settings, true);// true - do swap in renderer. return true; } @@ -180,7 +187,7 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { init(); } - if (/*isShowing()*/isVisible()) { + if (/* isShowing() */isVisible()) { _newtWindow.invoke(true, _drawerGLRunnable); } if (latch != null) { @@ -208,10 +215,10 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { } @Override - public void setVSyncEnabled(final boolean enabled) { + public void setVSyncEnabled(final boolean enabled) { _newtWindow.invoke(true, new GLRunnable() { @Override - public boolean run(GLAutoDrawable glAutoDrawable) { + public boolean run(final GLAutoDrawable glAutoDrawable) { _newtWindow.getGL().setSwapInterval(enabled ? 1 : 0); return false; } @@ -219,20 +226,20 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { } @Override - public void setTitle(String title) { + public void setTitle(final String title) { _newtWindow.setTitle(title); } @Override - public void setIcon(Image[] iconImages) { - //FIXME not supported by NEWT + public void setIcon(final Image[] iconImages) { + // FIXME not supported by NEWT } @Override - public void moveWindowTo(int locX, int locY) { - _newtWindow.setPosition(locX, locY); + public void moveWindowTo(final int locX, final int locY) { + _newtWindow.setPosition(locX, locY); } - + @Override public GLWindow getNewtWindow() { return _newtWindow; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java index 6ecf6bb..182e769 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java @@ -10,9 +10,12 @@ package com.ardor3d.input.jogl; +import static com.google.common.base.Preconditions.checkNotNull; + import java.util.EnumMap; import java.util.EnumSet; import java.util.LinkedList; + import com.ardor3d.annotation.GuardedBy; import com.ardor3d.framework.jogl.NewtWindowContainer; import com.ardor3d.input.ButtonState; @@ -32,9 +35,6 @@ import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.opengl.GLWindow; -import static com.google.common.base.Preconditions.checkNotNull; - - public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { @GuardedBy("this") @@ -47,11 +47,11 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { protected MouseState _lastState = null; protected final GLWindow _newtWindow; - + protected final MouseManager _manager; - + protected boolean _consumeEvents = false; - + protected final Multiset<MouseButton> _clicks = EnumMultiset.create(MouseButton.class); protected final EnumMap<MouseButton, Long> _lastClickTime = Maps.newEnumMap(MouseButton.class); protected final EnumSet<MouseButton> _clickArmed = EnumSet.noneOf(MouseButton.class); @@ -82,7 +82,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { return _currentIterator; } - + private void expireClickEvents() { if (!_clicks.isEmpty()) { for (final MouseButton mb : MouseButton.values()) { @@ -92,9 +92,9 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } } } - + @Override - public synchronized void mousePressed(MouseEvent me) { + public synchronized void mousePressed(final MouseEvent me) { final MouseButton b = getButtonForEvent(me); if (_clickArmed.contains(b)) { _clicks.setCount(b, 0); @@ -115,7 +115,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } @Override - public synchronized void mouseReleased(MouseEvent me) { + public synchronized void mouseReleased(final MouseEvent me) { initState(me); if (_consumeEvents) { me.setAttachment(InputEvent.consumedTag); @@ -137,14 +137,14 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { addNewState(me, buttons, null); } - + @Override - public synchronized void mouseDragged(MouseEvent me) { - mouseMoved(me); + public synchronized void mouseDragged(final MouseEvent me) { + mouseMoved(me); } - + @Override - public synchronized void mouseMoved(MouseEvent me) { + public synchronized void mouseMoved(final MouseEvent me) { _clickArmed.clear(); _clicks.clear(); @@ -159,7 +159,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { // check the state against the "ignore next" values if (_ignoreX != Integer.MAX_VALUE // shortcut to prevent dx/dy calculations - && (_ignoreX == getDX(me) && _ignoreY == getDY(me))) { + && (_ignoreX == getDX(me) && _ignoreY == getDY(me))) { // we matched, so we'll consider this a "mouse pointer reset move" // so reset ignore to let the next move event through. @@ -197,11 +197,11 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { _ignoreX = Integer.MAX_VALUE; _ignoreY = Integer.MAX_VALUE; } - } + } } @Override - public void mouseWheelMoved(MouseEvent me) { + public void mouseWheelMoved(final MouseEvent me) { initState(me); addNewState(me, _lastState.getButtonStates(), null); @@ -209,24 +209,24 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { me.setAttachment(InputEvent.consumedTag); } } - + private void initState(final MouseEvent mouseEvent) { if (_lastState == null) { _lastState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), 0, 0, 0, null, null); } } - + private void addNewState(final MouseEvent mouseEvent, final EnumMap<MouseButton, ButtonState> enumMap, final Multiset<MouseButton> clicks) { final MouseState newState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), getDX(mouseEvent), - getDY(mouseEvent), mouseEvent.getWheelRotation(), enumMap, clicks); + getDY(mouseEvent), (int) mouseEvent.getWheelRotation(), enumMap, clicks); synchronized (JoglNewtMouseWrapper.this) { _upcomingEvents.add(newState); } _lastState = newState; - } - + } + private int getDX(final MouseEvent me) { return me.getX() - _lastState.getX(); } @@ -234,7 +234,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { private int getDY(final MouseEvent me) { return getArdor3DY(me) - _lastState.getY(); } - + /** * @param e * our mouseEvent @@ -244,16 +244,16 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { private int getArdor3DY(final MouseEvent me) { return _newtWindow.getHeight() - me.getY(); } - + private void setStateForButton(final MouseEvent e, final EnumMap<MouseButton, ButtonState> buttons, final ButtonState buttonState) { final MouseButton button = getButtonForEvent(e); buttons.put(button, buttonState); } - + private MouseButton getButtonForEvent(final MouseEvent me) { MouseButton button; - switch(me.getButton()) { + switch (me.getButton()) { case MouseEvent.BUTTON1: button = MouseButton.LEFT; break; @@ -268,9 +268,9 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } return button; } - + private class JoglNewtMouseIterator extends AbstractIterator<MouseState> implements PeekingIterator<MouseState> { - + @Override protected MouseState computeNext() { synchronized (JoglNewtMouseWrapper.this) { @@ -281,25 +281,25 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } } } - + @Override - public synchronized void mouseClicked(MouseEvent me) { + public synchronized void mouseClicked(final MouseEvent me) { // Yes, we could use the click count here, but in the interests of this working the same way as SWT and Native, // we // will do it the same way they do it. - + } @Override - public synchronized void mouseEntered(MouseEvent me) { - // ignore this + public synchronized void mouseEntered(final MouseEvent me) { + // ignore this } @Override - public synchronized void mouseExited(MouseEvent me) { - // ignore this - } - + public synchronized void mouseExited(final MouseEvent me) { + // ignore this + } + public boolean isConsumeEvents() { return _consumeEvents; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java index 7bc4e01..bfb39bd 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java @@ -74,10 +74,11 @@ public class JoglContextCapabilities extends ContextCapabilities { _geometryShader4Supported = gl.isExtensionAvailable("GL_ARB_geometry_shader4") && _glslSupported; - _geometryInstancingSupported = gl.isExtensionAvailable("GL_EXT_draw_instanced") || gl.isExtensionAvailable("GL_VERSION_3_0"); - + _geometryInstancingSupported = gl.isExtensionAvailable("GL_EXT_draw_instanced") + || gl.isExtensionAvailable("GL_VERSION_3_0"); + _tessellationShadersSupported = gl.isExtensionAvailable("GL_ARB_tessellation_shader") && _glslSupported; - + if (_glslSupported) { gl.glGetIntegerv(GL2.GL_MAX_VERTEX_ATTRIBS_ARB, buf); _maxGLSLVertexAttribs = buf.get(0); @@ -89,6 +90,10 @@ public class JoglContextCapabilities extends ContextCapabilities { // FBO _fboSupported = gl.isExtensionAvailable("GL_EXT_framebuffer_object"); if (_fboSupported) { + + _supportsFBOMultisample = gl.isExtensionAvailable("GL_EXT_framebuffer_multisample"); + _supportsFBOBlit = gl.isExtensionAvailable("GL_EXT_framebuffer_blit"); + if (gl.isExtensionAvailable("GL_ARB_draw_buffers")) { gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, buf); _maxFBOColorAttachments = buf.get(0); @@ -122,11 +127,11 @@ public class JoglContextCapabilities extends ContextCapabilities { // Check for support of multitextures. _supportsMultiTexture = gl.isExtensionAvailable("GL_ARB_multitexture"); - // Support for texture formats - _supportsFloatTextures = gl.isExtensionAvailable("GL_ARB_texture_float"); - _supportsIntegerTextures = gl.isExtensionAvailable("GL_EXT_texture_integer"); - _supportsOneTwoComponentTextures = gl.isExtensionAvailable("GL_ARB_texture_rg"); - + // Support for texture formats + _supportsFloatTextures = gl.isExtensionAvailable("GL_ARB_texture_float"); + _supportsIntegerTextures = gl.isExtensionAvailable("GL_EXT_texture_integer"); + _supportsOneTwoComponentTextures = gl.isExtensionAvailable("GL_ARB_texture_rg"); + // Check for support of fixed function dot3 environment settings _supportsEnvDot3 = gl.isExtensionAvailable("GL_ARB_texture_env_dot3"); @@ -172,8 +177,8 @@ public class JoglContextCapabilities extends ContextCapabilities { } // Now determine the maximum number of supported texture units - _numTotalTexUnits = Math.max(_numFragmentTexCoordUnits, Math.max(_numFixedTexUnits, Math.max( - _numFragmentTexUnits, _numVertexTexUnits))); + _numTotalTexUnits = Math.max(_numFragmentTexCoordUnits, + Math.max(_numFixedTexUnits, Math.max(_numFragmentTexUnits, _numVertexTexUnits))); // Check for S3 texture compression capability. _supportsS3TCCompression = gl.isExtensionAvailable("GL_EXT_texture_compression_s3tc"); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java index 63eb6ee..2613f25 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java @@ -21,7 +21,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; -import javax.media.opengl.glu.GLU; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.Scene; @@ -76,7 +75,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { if (tex.getType() != Type.TwoDimensional) { throw new IllegalArgumentException("Unsupported type: " + tex.getType()); } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(RenderState.StateType.Texture); @@ -99,8 +98,8 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { // Initialize our texture with some default data. final int internalFormat = JoglTextureUtil.getGLInternalFormat(tex.getTextureStoreFormat()); final int dataFormat = JoglTextureUtil.getGLPixelFormatFromStoreFormat(tex.getTextureStoreFormat()); - final int pixelDataType = JoglTextureUtil.getGLPixelDataType(tex.getRenderedTexturePixelDataType()); - + final int pixelDataType = JoglTextureUtil.getGLPixelDataType(tex.getRenderedTexturePixelDataType()); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, _width, _height, 0, dataFormat, pixelDataType, null); // Setup filtering and wrap @@ -236,7 +235,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { public void copyToTexture(final Texture tex, final int x, final int y, final int width, final int height, final int xoffset, final int yoffset) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); JoglTextureStateUtil.doTextureBind(tex, 0, true); @@ -245,7 +244,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { @Override protected void clearBuffers(final int clear) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glDisable(GL.GL_SCISSOR_TEST); _parentRenderer.clearBuffers(clear); @@ -320,7 +319,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { ContextManager.getCurrentContext().enforceStates(_enforcedStates); if (_bgColorDirty) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glClearColor(_backgroundColor.getRed(), _backgroundColor.getGreen(), _backgroundColor.getBlue(), _backgroundColor.getAlpha()); @@ -357,7 +356,7 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { } } else { // XXX: Is this WGL specific query right? - if (GLU.getCurrentGL().isExtensionAvailable("WGL_ARB_render_texture")) { + if (GLContext.getCurrentGL().isExtensionAvailable("WGL_ARB_render_texture")) { logger.fine("Render to Texture Pbuffer supported!"); _useDirectRender = true; } else { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java index 7812aa6..4747dfd 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java @@ -90,12 +90,12 @@ import com.ardor3d.scene.state.jogl.JoglZBufferStateUtil; import com.ardor3d.scene.state.jogl.util.JoglRendererUtil; import com.ardor3d.scene.state.jogl.util.JoglTextureUtil; import com.ardor3d.scenegraph.AbstractBufferData; +import com.ardor3d.scenegraph.AbstractBufferData.VBOAccessMode; import com.ardor3d.scenegraph.FloatBufferData; import com.ardor3d.scenegraph.IndexBufferData; import com.ardor3d.scenegraph.Mesh; import com.ardor3d.scenegraph.Renderable; import com.ardor3d.scenegraph.Spatial; -import com.ardor3d.scenegraph.AbstractBufferData.VBOAccessMode; import com.ardor3d.scenegraph.hint.NormalsMode; import com.ardor3d.util.Ardor3dException; import com.ardor3d.util.Constants; @@ -122,7 +122,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setBackgroundColor(final ReadOnlyColorRGBA c) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); _backgroundColor.set(c); gl.glClearColor(_backgroundColor.getRed(), _backgroundColor.getGreen(), _backgroundColor.getBlue(), @@ -163,7 +163,7 @@ public class JoglRenderer extends AbstractRenderer { } public void clearBuffers(final int buffers, final boolean strict) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int clear = 0; @@ -214,7 +214,7 @@ public class JoglRenderer extends AbstractRenderer { } public void flushFrame(final boolean doSwap) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); renderBuckets(); @@ -240,7 +240,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setOrtho() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (_inOrthoMode) { throw new Ardor3dException("Already in Orthographic mode."); @@ -261,7 +261,7 @@ public class JoglRenderer extends AbstractRenderer { } public void unsetOrtho() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!_inOrthoMode) { throw new Ardor3dException("Not in Orthographic mode."); @@ -278,7 +278,7 @@ public class JoglRenderer extends AbstractRenderer { public void grabScreenContents(final ByteBuffer store, final ImageDataFormat format, final int x, final int y, final int w, final int h) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int pixFormat = JoglTextureUtil.getGLPixelFormat(format); gl.glReadPixels(x, y, w, h, pixFormat, GL.GL_UNSIGNED_BYTE, store); @@ -303,23 +303,23 @@ public class JoglRenderer extends AbstractRenderer { * re-initializes the GL context for rendering of another piece of geometry. */ protected void postdrawGeometry(final Mesh g) { - // Nothing to do here yet + // Nothing to do here yet } public void flushGraphics() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glFlush(); } public void finishGraphics() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glFinish(); } public void applyNormalsMode(final NormalsMode normalsMode, final ReadOnlyTransform worldTransform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); if (normalsMode != NormalsMode.Off) { @@ -403,17 +403,17 @@ public class JoglRenderer extends AbstractRenderer { } public void applyDefaultColor(final ReadOnlyColorRGBA defaultColor) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (defaultColor != null) { - gl.getGL2().glColor4f(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(), defaultColor - .getAlpha()); + gl.getGL2().glColor4f(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(), + defaultColor.getAlpha()); } else { gl.getGL2().glColor4f(1, 1, 1, 1); } } public void deleteVBOs(final Collection<Integer> ids) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer idBuffer = BufferUtils.createIntBuffer(ids.size()); idBuffer.clear(); for (final Integer i : ids) { @@ -428,7 +428,7 @@ public class JoglRenderer extends AbstractRenderer { } public void deleteDisplayLists(final Collection<Integer> ids) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); for (final Integer i : ids) { if (i != null && i != 0) { gl.getGL2().glDeleteLists(i, 1); @@ -441,7 +441,7 @@ public class JoglRenderer extends AbstractRenderer { return; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -492,7 +492,7 @@ public class JoglRenderer extends AbstractRenderer { final int srcOffsetX, final int srcOffsetY, final int srcOffsetZ, final int srcTotalWidth, final int srcTotalHeight, final Face dstFace) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // Ignore textures that do not have an id set if (destination.getTextureIdForContext(ContextManager.getCurrentContext().getGlContextRep()) == 0) { @@ -537,12 +537,12 @@ public class JoglRenderer extends AbstractRenderer { } // Grab pixel format - final int pixelFormat; - if (destination.getImage() != null) { - pixelFormat = JoglTextureUtil.getGLPixelFormat(destination.getImage().getDataFormat()); - } else { - pixelFormat = JoglTextureUtil.getGLPixelFormatFromStoreFormat(destination.getTextureStoreFormat()); - } + final int pixelFormat; + if (destination.getImage() != null) { + pixelFormat = JoglTextureUtil.getGLPixelFormat(destination.getImage().getDataFormat()); + } else { + pixelFormat = JoglTextureUtil.getGLPixelFormatFromStoreFormat(destination.getTextureStoreFormat()); + } // bind... JoglTextureStateUtil.doTextureBind(destination, 0, false); @@ -577,12 +577,12 @@ public class JoglRenderer extends AbstractRenderer { GL.GL_UNSIGNED_BYTE, source); break; case OneDimensional: - gl.getGL2GL3().glTexSubImage1D(GL2GL3.GL_TEXTURE_1D, 0, dstOffsetX, dstWidth, pixelFormat, GL.GL_UNSIGNED_BYTE, - source); + gl.getGL2GL3().glTexSubImage1D(GL2GL3.GL_TEXTURE_1D, 0, dstOffsetX, dstWidth, pixelFormat, + GL.GL_UNSIGNED_BYTE, source); break; case ThreeDimensional: - gl.getGL2GL3().glTexSubImage3D(GL2ES2.GL_TEXTURE_3D, 0, dstOffsetX, dstOffsetY, dstOffsetZ, dstWidth, dstHeight, - dstDepth, pixelFormat, GL.GL_UNSIGNED_BYTE, source); + gl.getGL2GL3().glTexSubImage3D(GL2ES2.GL_TEXTURE_3D, 0, dstOffsetX, dstOffsetY, dstOffsetZ, + dstWidth, dstHeight, dstDepth, pixelFormat, GL.GL_UNSIGNED_BYTE, source); break; case CubeMap: gl.glTexSubImage2D(JoglTextureStateUtil.getGLCubeMapFace(dstFace), 0, dstOffsetX, dstOffsetY, @@ -621,7 +621,7 @@ public class JoglRenderer extends AbstractRenderer { } public void checkCardError() throws Ardor3dException { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final GLU glu = new GLU(); try { @@ -645,7 +645,7 @@ public class JoglRenderer extends AbstractRenderer { } public boolean doTransforms(final ReadOnlyTransform transform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // set world matrix if (!transform.isIdentity()) { @@ -663,7 +663,7 @@ public class JoglRenderer extends AbstractRenderer { } public void undoTransforms(final ReadOnlyTransform transform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord(); JoglRendererUtil.switchMode(matRecord, GLMatrixFunc.GL_MODELVIEW); @@ -671,7 +671,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupVertexData(final FloatBufferData vertexBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer vertexBuffer = vertexBufferData != null ? vertexBufferData.getBuffer() : null; @@ -685,7 +685,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupNormalData(final FloatBufferData normalBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer normalBuffer = normalBufferData != null ? normalBufferData.getBuffer() : null; @@ -699,7 +699,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupColorData(final FloatBufferData colorBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer colorBuffer = colorBufferData != null ? colorBufferData.getBuffer() : null; @@ -713,7 +713,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupFogData(final FloatBufferData fogBufferData) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final FloatBuffer fogBuffer = fogBufferData != null ? fogBufferData.getBuffer() : null; @@ -727,7 +727,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupTextureData(final List<FloatBufferData> textureCoords) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -791,7 +791,7 @@ public class JoglRenderer extends AbstractRenderer { return; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int type = getGLDataType(indices); if (indexLengths == null) { @@ -802,8 +802,8 @@ public class JoglRenderer extends AbstractRenderer { if (primcount < 0) { gl.glDrawElements(glIndexMode, indices.getBufferLimit(), type, indices.getBuffer()); } else { - gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, indices.getBuffer(), - primcount); + gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, + indices.getBuffer(), primcount); } if (Constants.stats) { @@ -844,7 +844,7 @@ public class JoglRenderer extends AbstractRenderer { return 0; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RendererRecord rendRecord = context.getRendererRecord(); int vboID = data.getVBOID(context.getGlContextRep()); @@ -873,12 +873,11 @@ public class JoglRenderer extends AbstractRenderer { private static void updateVBO(final AbstractBufferData<? extends Buffer> data, final RendererRecord rendRecord, final int vboID, final int offsetBytes) { if (data.isNeedsRefresh()) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Buffer dataBuffer = data.getBuffer(); dataBuffer.rewind(); JoglRendererUtil.setBoundVBO(rendRecord, vboID); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offsetBytes, dataBuffer.limit() * data.getByteCount(), - dataBuffer); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offsetBytes, dataBuffer.limit() * data.getByteCount(), dataBuffer); data.setNeedsRefresh(false); } } @@ -889,7 +888,7 @@ public class JoglRenderer extends AbstractRenderer { return 0; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int vboID = data.getVBOID(context.getGlContextRep()); if (vboID != 0) { @@ -897,8 +896,7 @@ public class JoglRenderer extends AbstractRenderer { final Buffer dataBuffer = data.getBuffer(); dataBuffer.rewind(); JoglRendererUtil.setBoundElementVBO(rendRecord, vboID); - gl.glBufferSubData(GL.GL_ELEMENT_ARRAY_BUFFER, 0, dataBuffer.limit() * data.getByteCount(), - dataBuffer); + gl.glBufferSubData(GL.GL_ELEMENT_ARRAY_BUFFER, 0, dataBuffer.limit() * data.getByteCount(), dataBuffer); data.setNeedsRefresh(false); } @@ -923,7 +921,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupVertexDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -940,7 +938,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupNormalDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -957,7 +955,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupColorDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -974,7 +972,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupFogDataVBO(final FloatBufferData data) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -996,7 +994,7 @@ public class JoglRenderer extends AbstractRenderer { } public void setupTextureDataVBO(final List<FloatBufferData> textureCoords) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -1071,7 +1069,7 @@ public class JoglRenderer extends AbstractRenderer { public void setupInterleavedDataVBO(final FloatBufferData interleaved, final FloatBufferData vertexCoords, final FloatBufferData normalCoords, final FloatBufferData colorCoords, final List<FloatBufferData> textureCoords) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -1157,7 +1155,8 @@ public class JoglRenderer extends AbstractRenderer { } // send data - gl.getGL2().glTexCoordPointer(textureBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, offsetBytes); + gl.getGL2().glTexCoordPointer(textureBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, + offsetBytes); offsetBytes += textureBufferData.getBufferLimit() * 4; } } @@ -1188,7 +1187,7 @@ public class JoglRenderer extends AbstractRenderer { interleaved.getBuffer().rewind(); interleaved.getBuffer().put(bufferSize); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RendererRecord rendRecord = context.getRendererRecord(); final ContextCapabilities caps = context.getCapabilities(); @@ -1198,21 +1197,17 @@ public class JoglRenderer extends AbstractRenderer { rendRecord.invalidateVBO(); JoglRendererUtil.setBoundVBO(rendRecord, vboID); - gl - .glBufferData(GL.GL_ARRAY_BUFFER, bufferSize, null, getGLVBOAccessMode(interleaved - .getVboAccessMode())); + gl.glBufferData(GL.GL_ARRAY_BUFFER, bufferSize, null, getGLVBOAccessMode(interleaved.getVboAccessMode())); int offset = 0; if (normalCoords != null) { normalCoords.getBuffer().rewind(); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, normalCoords.getBufferLimit() * 4, normalCoords - .getBuffer()); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, normalCoords.getBufferLimit() * 4, normalCoords.getBuffer()); offset += normalCoords.getBufferLimit() * 4; } if (colorCoords != null) { colorCoords.getBuffer().rewind(); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, colorCoords.getBufferLimit() * 4, colorCoords - .getBuffer()); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, colorCoords.getBufferLimit() * 4, colorCoords.getBuffer()); offset += colorCoords.getBufferLimit() * 4; } if (textureCoords != null) { @@ -1236,8 +1231,7 @@ public class JoglRenderer extends AbstractRenderer { } if (vertexCoords != null) { vertexCoords.getBuffer().rewind(); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, vertexCoords.getBufferLimit() * 4, vertexCoords - .getBuffer()); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, vertexCoords.getBufferLimit() * 4, vertexCoords.getBuffer()); } interleaved.setNeedsRefresh(false); @@ -1245,7 +1239,7 @@ public class JoglRenderer extends AbstractRenderer { public void drawElementsVBO(final IndexBufferData<?> indices, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); @@ -1262,8 +1256,8 @@ public class JoglRenderer extends AbstractRenderer { if (primcount < 0) { gl.glDrawElements(glIndexMode, indices.getBufferLimit(), type, 0); } else { - gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, indices.getBuffer(), - primcount); + gl.getGL2GL3().glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, + indices.getBuffer(), primcount); } if (Constants.stats) { @@ -1306,7 +1300,7 @@ public class JoglRenderer extends AbstractRenderer { public void drawArrays(final FloatBufferData vertexBuffer, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (indexLengths == null) { final int glIndexMode = getGLIndexMode(indexModes[0]); @@ -1331,7 +1325,7 @@ public class JoglRenderer extends AbstractRenderer { if (primcount < 0) { gl.glDrawArrays(glIndexMode, offset, count); } else { - gl.getGL2GL3().glDrawArraysInstanced(glIndexMode, offset, count, primcount); + gl.getGL2GL3().glDrawArraysInstanced(glIndexMode, offset, count, primcount); } if (Constants.stats) { @@ -1348,7 +1342,7 @@ public class JoglRenderer extends AbstractRenderer { } private static int makeVBOId() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer idBuff = BufferUtils.createIntBuffer(1); gl.glGenBuffers(1, idBuff); @@ -1457,7 +1451,7 @@ public class JoglRenderer extends AbstractRenderer { } private void loadMatrix(final FloatBuffer matrix) { - GLU.getCurrentGL().getGL2().glLoadMatrixf(matrix); + GLContext.getCurrentGL().getGL2().glLoadMatrixf(matrix); } public FloatBuffer getModelViewMatrix(final FloatBuffer store) { @@ -1473,16 +1467,16 @@ public class JoglRenderer extends AbstractRenderer { if (result.remaining() < 16) { result = BufferUtils.createFloatBuffer(16); } - GLU.getCurrentGL().glGetFloatv(matrixType, store); + GLContext.getCurrentGL().glGetFloatv(matrixType, store); return result; } public void setViewport(final int x, final int y, final int width, final int height) { - GLU.getCurrentGL().glViewport(x, y, width, height); + GLContext.getCurrentGL().glViewport(x, y, width, height); } public void setDepthRange(final double depthRangeNear, final double depthRangeFar) { - GLU.getCurrentGL().glDepthRange(depthRangeNear, depthRangeFar); + GLContext.getCurrentGL().glDepthRange(depthRangeNear, depthRangeFar); } public void setDrawBuffer(final DrawBufferTarget target) { @@ -1531,14 +1525,14 @@ public class JoglRenderer extends AbstractRenderer { break; } - GLU.getCurrentGL().getGL2GL3().glDrawBuffer(buffer); + GLContext.getCurrentGL().getGL2GL3().glDrawBuffer(buffer); record.setDrawBufferTarget(target); } } public void setupLineParameters(final float lineWidth, final int stippleFactor, final short stipplePattern, final boolean antialiased) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final LineRecord lineRecord = ContextManager.getCurrentContext().getLineRecord(); @@ -1588,7 +1582,7 @@ public class JoglRenderer extends AbstractRenderer { final boolean useDistanceAttenuation, final FloatBuffer attenuationCoefficients, final float minPointSize, final float maxPointSize) { final RenderContext context = ContextManager.getCurrentContext(); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // TODO: make this into a pointrecord call gl.getGL2GL3().glPointSize(pointSize); @@ -1683,7 +1677,7 @@ public class JoglRenderer extends AbstractRenderer { * @return id of new display list */ public int startDisplayList() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int id = gl.getGL2().glGenLists(1); @@ -1696,14 +1690,14 @@ public class JoglRenderer extends AbstractRenderer { * Ends a display list. Will likely cause an OpenGL exception is a display list is not currently being generated. */ public void endDisplayList() { - GLU.getCurrentGL().getGL2().glEndList(); + GLContext.getCurrentGL().getGL2().glEndList(); } /** * Draw the given display list. */ public void renderDisplayList(final int displayListID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2().glCallList(displayListID); } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java index 99719df..2c68ec1 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java @@ -18,7 +18,7 @@ import java.util.logging.Logger; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.framework.Scene; import com.ardor3d.image.Texture; @@ -75,7 +75,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { throw new IllegalArgumentException("Texture type not supported: " + tex.getType()); } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(RenderState.StateType.Texture); @@ -101,8 +101,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { final int pixelDataType = JoglTextureUtil.getGLPixelDataType(tex.getRenderedTexturePixelDataType()); if (tex.getType() == Type.TwoDimensional) { - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, _width, _height, 0, dataFormat, pixelDataType, - null); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, _width, _height, 0, dataFormat, pixelDataType, null); } else { for (final Face face : Face.values()) { gl.glTexImage2D(JoglTextureStateUtil.getGLCubeMapFace(face), 0, internalFormat, _width, _height, 0, @@ -138,7 +137,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { private void render(final List<? extends Spatial> toDrawA, final Spatial toDrawB, final Scene toDrawC, final List<Texture> texs, final int clear) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int maxDrawBuffers = ContextManager.getCurrentContext().getCapabilities().getMaxFBOColorAttachments(); @@ -217,8 +216,8 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { final Texture tex = depths.removeFirst(); // Set up our depth texture if (tex.getType() == Type.TwoDimensional) { - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, - GL.GL_TEXTURE_2D, tex.getTextureIdForContext(context.getGlContextRep()), 0); + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, + tex.getTextureIdForContext(context.getGlContextRep()), 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), @@ -229,8 +228,8 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { _usingDepthRB = false; } else if (!_usingDepthRB) { // setup our default depth render buffer if not already set - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, - GL.GL_RENDERBUFFER, _depthRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, + _depthRBID); _usingDepthRB = true; } @@ -266,20 +265,18 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void setupForSingleTexDraw(final Texture tex) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final int textureId = tex.getTextureIdForContext(context.getGlContextRep()); if (tex.getTextureStoreFormat().isDepthFormat()) { // No color buffer - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, - 0); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, 0); // Setup depth texture into FBO if (tex.getType() == Type.TwoDimensional) { - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, - textureId, 0); + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, textureId, 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), textureId, 0); @@ -292,8 +289,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } else { // Set color texture into FBO if (tex.getType() == Type.TwoDimensional) { - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_TEXTURE_2D, - textureId, 0); + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_TEXTURE_2D, textureId, 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), textureId, 0); @@ -302,8 +298,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } // setup depth RB - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, - _depthRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, _depthRBID); setDrawBuffer(GL.GL_COLOR_ATTACHMENT0); setReadBuffer(GL.GL_COLOR_ATTACHMENT0); @@ -314,19 +309,19 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } private void setReadBuffer(final int attachVal) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glReadBuffer(attachVal); } private void setDrawBuffer(final int attachVal) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glDrawBuffer(attachVal); } private void setDrawBuffers(final int maxEntry) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (maxEntry <= 1) { setDrawBuffer(maxEntry != 0 ? GL.GL_COLOR_ATTACHMENT0 : GL.GL_NONE); @@ -340,7 +335,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void takedownForSingleTexDraw(final Texture tex) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // automatically generate mipmaps for our texture. if (tex.getMinificationFilter().usesMipMapLevels()) { @@ -351,19 +346,19 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void setMSFBO() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, _msfboID); } @Override protected void blitMSFBO() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, _msfboID); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, _fboID); - gl.getGL2GL3().glBlitFramebuffer(0, 0, _width, _height, 0, 0, _width, _height, GL.GL_COLOR_BUFFER_BIT - | GL.GL_DEPTH_BUFFER_BIT, GL.GL_NEAREST); + gl.getGL2GL3().glBlitFramebuffer(0, 0, _width, _height, 0, 0, _width, _height, + GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT, GL.GL_NEAREST); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); @@ -377,7 +372,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { * an id to use for log messages, particularly if there are any issues. */ public static void checkFBOComplete(final int fboID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER); switch (status) { @@ -414,7 +409,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { public void copyToTexture(final Texture tex, final int x, final int y, final int width, final int height, final int xoffset, final int yoffset) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); JoglTextureStateUtil.doTextureBind(tex, 0, true); @@ -430,7 +425,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void clearBuffers(final int clear) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.glDisable(GL.GL_SCISSOR_TEST); _parentRenderer.clearBuffers(clear); @@ -438,7 +433,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void activate() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // Lazy init if (_fboID == 0) { @@ -488,7 +483,8 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { // set up renderbuffer properties gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, _mscolorRBID); - gl.getGL2GL3().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, _samples, GL.GL_RGBA, _width, _height); + gl.getGL2GL3().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, _samples, GL.GL_RGBA, _width, + _height); gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, _msdepthRBID); gl.getGL2GL3().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, _samples, format, _width, _height); @@ -496,10 +492,10 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, 0); gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, _msfboID); - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, - GL.GL_RENDERBUFFER, _mscolorRBID); - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, - GL.GL_RENDERBUFFER, _msdepthRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, + _mscolorRBID); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, + _msdepthRBID); // check for errors checkFBOComplete(_msfboID); @@ -536,7 +532,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { @Override protected void deactivate() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (_active == 1) { final ReadOnlyColorRGBA bgColor = _parentRenderer.getBackgroundColor(); @@ -552,7 +548,7 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { } public void cleanup() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (_fboID != 0) { final IntBuffer id = BufferUtils.createIntBuffer(1); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java index 39f0221..bde9535 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java @@ -14,7 +14,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextCapabilities; @@ -37,7 +37,7 @@ public abstract class JoglBlendStateUtil { final ContextCapabilities caps = context.getCapabilities(); context.setCurrentState(StateType.Blend, state); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state.isEnabled()) { applyBlendEquations(gl, state.isBlendEnabled(), state, record, caps); @@ -128,7 +128,8 @@ public abstract class JoglBlendStateUtil { if (applyConstant && caps.isConstantBlendColorSupported()) { final ReadOnlyColorRGBA constant = state.getConstantColor(); if (!record.isValid() || (caps.isConstantBlendColorSupported() && !record.blendColor.equals(constant))) { - gl.getGL2GL3().glBlendColor(constant.getRed(), constant.getGreen(), constant.getBlue(), constant.getAlpha()); + gl.getGL2GL3().glBlendColor(constant.getRed(), constant.getGreen(), constant.getBlue(), + constant.getAlpha()); record.blendColor.set(constant); } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java index df673aa..a64cf95 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java @@ -12,7 +12,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -50,7 +50,7 @@ public abstract class JoglClipStateUtil { private static void enableClipPlane(final int planeIndex, final boolean enable, final ClipState state, final ClipStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (enable) { if (!record.isValid() || !record.planeEnabled[planeIndex]) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java index a0316e0..ca685a8 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java @@ -11,7 +11,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -23,7 +23,7 @@ import com.ardor3d.renderer.state.record.ColorMaskStateRecord; public abstract class JoglColorMaskStateUtil { public static void apply(final JoglRenderer renderer, final ColorMaskState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java index d93eb33..a2f3fd8 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java @@ -11,7 +11,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -62,7 +62,7 @@ public abstract class JoglCullStateUtil { } private static void setCullEnabled(final boolean enable, final CullState state, final CullStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.enabled != enable) { if (enable) { @@ -75,7 +75,7 @@ public abstract class JoglCullStateUtil { } private static void setCull(final int face, final CullState state, final CullStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.face != face) { gl.glCullFace(face); @@ -85,7 +85,7 @@ public abstract class JoglCullStateUtil { private static void setGLPolygonWind(final PolygonWind windOrder, final CullState state, final CullStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.windOrder != windOrder) { switch (windOrder) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java index 19b1b0f..a36649a 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java @@ -13,7 +13,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES1; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextCapabilities; @@ -30,7 +30,7 @@ import com.ardor3d.renderer.state.record.FogStateRecord; public abstract class JoglFogStateUtil { public static void apply(final JoglRenderer renderer, final FogState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -78,7 +78,7 @@ public abstract class JoglFogStateUtil { } private static void enableFog(final boolean enable, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (enable && !record.enabled) { @@ -99,13 +99,13 @@ public abstract class JoglFogStateUtil { } private static void applyFogColor(final ReadOnlyColorRGBA color, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !color.equals(record.fogColor)) { record.fogColor.set(color); record.colorBuff.clear(); - record.colorBuff.put(record.fogColor.getRed()).put(record.fogColor.getGreen()).put( - record.fogColor.getBlue()).put(record.fogColor.getAlpha()); + record.colorBuff.put(record.fogColor.getRed()).put(record.fogColor.getGreen()) + .put(record.fogColor.getBlue()).put(record.fogColor.getAlpha()); record.colorBuff.flip(); gl.getGL2ES1().glFogfv(GL2ES1.GL_FOG_COLOR, record.colorBuff); } @@ -113,7 +113,7 @@ public abstract class JoglFogStateUtil { private static void applyFogSource(final CoordinateSource source, final FogStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (caps.isFogCoordinatesSupported()) { if (!record.isValid() || !source.equals(record.source)) { @@ -127,7 +127,7 @@ public abstract class JoglFogStateUtil { } private static void applyFogMode(final DensityFunction densityFunction, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int glMode = 0; switch (densityFunction) { @@ -149,7 +149,7 @@ public abstract class JoglFogStateUtil { } private static void applyFogHint(final Quality quality, final FogStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); int glHint = 0; switch (quality) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java index 5b8d068..f71e4f5 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java @@ -16,7 +16,7 @@ import java.util.logging.Logger; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -35,7 +35,7 @@ public final class JoglFragmentProgramStateUtil { * message. */ private static void checkProgramError() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (gl.glGetError() == GL.GL_INVALID_OPERATION) { // retrieve the error position @@ -48,7 +48,7 @@ public final class JoglFragmentProgramStateUtil { } private static int create(final ByteBuffer program) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer buf = BufferUtils.createIntBuffer(1); @@ -58,8 +58,8 @@ public final class JoglFragmentProgramStateUtil { final byte array[] = new byte[program.limit()]; program.rewind(); program.get(array); - gl.getGL2().glProgramStringARB(GL2.GL_FRAGMENT_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, new String( - array)); // TODO Check cost of using non-buffer + gl.getGL2().glProgramStringARB(GL2.GL_FRAGMENT_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, + new String(array)); // TODO Check cost of using non-buffer checkProgramError(); @@ -67,7 +67,7 @@ public final class JoglFragmentProgramStateUtil { } public static void apply(final JoglRenderer renderer, final FragmentProgramState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -106,8 +106,8 @@ public final class JoglFragmentProgramStateUtil { for (int i = 0; i < state._getParameters().length; i++) { if (state._getParameters()[i] != null) { gl.getGL2().glProgramLocalParameter4fARB(GL2.GL_FRAGMENT_PROGRAM_ARB, i, - state._getParameters()[i][0], state._getParameters()[i][1], state - ._getParameters()[i][2], state._getParameters()[i][3]); + state._getParameters()[i][0], state._getParameters()[i][1], + state._getParameters()[i][2], state._getParameters()[i][3]); } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java index 3050d67..489fdd4 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java @@ -13,8 +13,8 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLContext; import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; import com.ardor3d.light.DirectionalLight; import com.ardor3d.light.Light; @@ -163,7 +163,7 @@ public abstract class JoglLightStateUtil { private static void setSingleLightEnabled(final boolean enable, final int index, final LightStateRecord record, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.isEnabled() != enable) { if (enable) { @@ -177,7 +177,7 @@ public abstract class JoglLightStateUtil { } private static void setLightEnabled(final boolean enable, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isEnabled() != enable) { if (enable) { @@ -190,7 +190,7 @@ public abstract class JoglLightStateUtil { } private static void setTwoSided(final boolean twoSided, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isTwoSidedOn() != twoSided) { if (twoSided) { @@ -203,7 +203,7 @@ public abstract class JoglLightStateUtil { } private static void setLocalViewer(final boolean localViewer, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isLocalViewer() != localViewer) { if (localViewer) { @@ -216,7 +216,7 @@ public abstract class JoglLightStateUtil { } private static void setSpecularControl(final boolean separateSpecularOn, final LightStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isSeparateSpecular() != separateSpecularOn) { if (separateSpecularOn) { @@ -229,7 +229,7 @@ public abstract class JoglLightStateUtil { } private static void setModelAmbient(final LightStateRecord record, final ReadOnlyColorRGBA globalAmbient) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !record.globalAmbient.equals(globalAmbient)) { record.lightBuffer.clear(); @@ -245,7 +245,7 @@ public abstract class JoglLightStateUtil { private static void setAmbient(final int index, final LightStateRecord record, final ReadOnlyColorRGBA ambient, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.ambient.equals(ambient)) { record.lightBuffer.clear(); @@ -254,14 +254,17 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(ambient.getBlue()); record.lightBuffer.put(ambient.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_AMBIENT, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_AMBIENT, record.lightBuffer); // TODO + // Check + // for + // float lr.ambient.set(ambient); } } private static void setDiffuse(final int index, final LightStateRecord record, final ReadOnlyColorRGBA diffuse, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.diffuse.equals(diffuse)) { record.lightBuffer.clear(); @@ -270,14 +273,17 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(diffuse.getBlue()); record.lightBuffer.put(diffuse.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_DIFFUSE, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_DIFFUSE, record.lightBuffer); // TODO + // Check + // for + // float lr.diffuse.set(diffuse); } } private static void setSpecular(final int index, final LightStateRecord record, final ReadOnlyColorRGBA specular, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.specular.equals(specular)) { record.lightBuffer.clear(); @@ -286,14 +292,17 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(specular.getBlue()); record.lightBuffer.put(specular.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPECULAR, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPECULAR, record.lightBuffer); // TODO + // Check + // for + // float lr.specular.set(specular); } } private static void setPosition(final int index, final LightStateRecord record, final float positionX, final float positionY, final float positionZ, final float positionW, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // From OpenGL Docs: // The light position is transformed by the contents of the current top @@ -321,15 +330,15 @@ public abstract class JoglLightStateUtil { gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_POSITION, record.lightBuffer); lr.position.set(positionX, positionY, positionZ, positionW); - if (!Camera.getCurrentCamera().isFrameDirty()) { - lr.modelViewMatrix.set(modelViewMatrix); - } + if (!Camera.getCurrentCamera().isFrameDirty()) { + lr.modelViewMatrix.set(modelViewMatrix); + } } } private static void setSpotDirection(final int index, final LightStateRecord record, final float directionX, final float directionY, final float directionZ, final float value) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // From OpenGL Docs: // The light position is transformed by the contents of the current top @@ -346,11 +355,14 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(directionZ); record.lightBuffer.put(value); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_DIRECTION, record.lightBuffer); // TODO Check for float + gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_DIRECTION, record.lightBuffer); // TODO + // Check + // for + // float } private static void setConstant(final int index, final float constant, final LightRecord lr, final boolean force) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (force || constant != lr.getConstant()) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_CONSTANT_ATTENUATION, constant); @@ -359,7 +371,7 @@ public abstract class JoglLightStateUtil { } private static void setLinear(final int index, final float linear, final LightRecord lr, final boolean force) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (force || linear != lr.getLinear()) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_LINEAR_ATTENUATION, linear); @@ -368,7 +380,7 @@ public abstract class JoglLightStateUtil { } private static void setQuadratic(final int index, final float quad, final LightRecord lr, final boolean force) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (force || quad != lr.getQuadratic()) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_QUADRATIC_ATTENUATION, quad); @@ -392,7 +404,7 @@ public abstract class JoglLightStateUtil { private static void setSpotExponent(final int index, final LightStateRecord record, final float exponent, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.getSpotExponent() != exponent) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_EXPONENT, exponent); @@ -402,7 +414,7 @@ public abstract class JoglLightStateUtil { private static void setSpotCutoff(final int index, final LightStateRecord record, final float cutoff, final LightRecord lr) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.getSpotCutoff() != cutoff) { gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_CUTOFF, cutoff); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java index 4a20143..9fc3490 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java @@ -11,8 +11,8 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; +import javax.media.opengl.GLContext; import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextManager; @@ -63,7 +63,7 @@ public abstract class JoglMaterialStateUtil { private static void applyColor(final ColorMaterial glMatColor, final ReadOnlyColorRGBA frontColor, final ReadOnlyColorRGBA backColor, final MaterialStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int glMat = getGLColorMaterial(glMatColor); if (frontColor.equals(backColor)) { @@ -120,11 +120,11 @@ public abstract class JoglMaterialStateUtil { case Emissive: return record.colorMaterial == ColorMaterial.Emissive; case AmbientAndDiffuse: - break; + break; case None: - break; + break; default: - break; + break; } return false; } @@ -132,7 +132,7 @@ public abstract class JoglMaterialStateUtil { private static void applyColorMaterial(final ColorMaterial colorMaterial, final MaterialFace face, final MaterialStateRecord record) { if (!record.isValid() || face != record.colorMaterialFace || colorMaterial != record.colorMaterial) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (colorMaterial == ColorMaterial.None) { gl.glDisable(GLLightingFunc.GL_COLOR_MATERIAL); @@ -151,22 +151,25 @@ public abstract class JoglMaterialStateUtil { private static void applyShininess(final float frontShininess, final float backShininess, final MaterialStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (frontShininess == backShininess) { // consolidate to one call if (!record.isValid() || frontShininess != record.frontShininess || record.backShininess != backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, frontShininess); + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, + frontShininess); record.backShininess = record.frontShininess = frontShininess; } } else { if (!record.isValid() || frontShininess != record.frontShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, frontShininess); + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, + frontShininess); record.frontShininess = frontShininess; } if (!record.isValid() || backShininess != record.backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, backShininess); + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, + backShininess); record.backShininess = backShininess; } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java index b2cd05a..ec48484 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java @@ -12,7 +12,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -55,7 +55,7 @@ public abstract class JoglOffsetStateUtil { private static void setOffsetEnabled(final OffsetType type, final boolean typeEnabled, final OffsetStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int glType = getGLType(type); if (!record.isValid() || typeEnabled != record.enabledOffsets.contains(type)) { @@ -68,7 +68,7 @@ public abstract class JoglOffsetStateUtil { } private static void setOffset(final float factor, final float units, final OffsetStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.factor != factor || record.units != units) { gl.glPolygonOffset(factor, units); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java index f254b29..bb5fa05 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java @@ -19,8 +19,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL3; -import javax.media.opengl.GL4; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -38,7 +37,7 @@ public abstract class JoglShaderObjectsStateUtil { private static final Logger logger = Logger.getLogger(JoglShaderObjectsStateUtil.class.getName()); protected static void sendToGL(final GLSLShaderObjectsState state, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state.getVertexShader() == null && state.getFragmentShader() == null) { logger.warning("Could not find shader resources!" + "(both inputbuffers are null)"); @@ -122,7 +121,8 @@ public abstract class JoglShaderObjectsStateUtil { // Compile the geometry shader final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glCompileShaderARB(state._geometryShaderID); - gl.getGL2().glGetObjectParameterivARB(state._geometryShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); + gl.getGL2().glGetObjectParameterivARB(state._geometryShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, + compiled); checkProgramError(compiled, state._geometryShaderID, state._geometryShaderName); // Attach the program @@ -132,7 +132,7 @@ public abstract class JoglShaderObjectsStateUtil { state._geometryShaderID = -1; } } - + if (caps.isTessellationShadersSupported()) { if (state.getTessellationControlShader() != null) { if (state._tessellationControlShaderID != -1) { @@ -145,19 +145,20 @@ public abstract class JoglShaderObjectsStateUtil { final byte array[] = new byte[state.getTessellationControlShader().limit()]; state.getTessellationControlShader().rewind(); state.getTessellationControlShader().get(array); - gl.getGL2().glShaderSourceARB(state._tessellationControlShaderID, 1, new String[] { new String(array) }, - new int[] { array.length }, 0); + gl.getGL2().glShaderSourceARB(state._tessellationControlShaderID, 1, + new String[] { new String(array) }, new int[] { array.length }, 0); // Compile the tessellation control shader final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glCompileShaderARB(state._tessellationControlShaderID); - gl.getGL2().glGetObjectParameterivARB(state._tessellationControlShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); + gl.getGL2().glGetObjectParameterivARB(state._tessellationControlShaderID, + GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); checkProgramError(compiled, state._tessellationControlShaderID, state._tessellationControlShaderName); // Attach the program gl.getGL2().glAttachObjectARB(state._programID, state._tessellationControlShaderID); } else if (state._tessellationControlShaderID != -1) { - removeTessControlShader(state); + removeTessControlShader(state); state._tessellationControlShaderID = -1; } if (state.getTessellationEvaluationShader() != null) { @@ -165,25 +166,27 @@ public abstract class JoglShaderObjectsStateUtil { removeTessEvalShader(state); } - state._tessellationEvaluationShaderID = gl.getGL2().glCreateShaderObjectARB(GL4.GL_TESS_CONTROL_SHADER); + state._tessellationEvaluationShaderID = gl.getGL2().glCreateShaderObjectARB(GL3.GL_TESS_CONTROL_SHADER); // Create the sources final byte array[] = new byte[state.getTessellationEvaluationShader().limit()]; state.getTessellationEvaluationShader().rewind(); state.getTessellationEvaluationShader().get(array); - gl.getGL2().glShaderSourceARB(state._tessellationEvaluationShaderID, 1, new String[] { new String(array) }, - new int[] { array.length }, 0); + gl.getGL2().glShaderSourceARB(state._tessellationEvaluationShaderID, 1, + new String[] { new String(array) }, new int[] { array.length }, 0); // Compile the tessellation control shader final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glCompileShaderARB(state._tessellationEvaluationShaderID); - gl.getGL2().glGetObjectParameterivARB(state._tessellationEvaluationShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); - checkProgramError(compiled, state._tessellationEvaluationShaderID, state._tessellationEvaluationShaderName); + gl.getGL2().glGetObjectParameterivARB(state._tessellationEvaluationShaderID, + GL2.GL_OBJECT_COMPILE_STATUS_ARB, compiled); + checkProgramError(compiled, state._tessellationEvaluationShaderID, + state._tessellationEvaluationShaderName); // Attach the program gl.getGL2().glAttachObjectARB(state._programID, state._tessellationEvaluationShaderID); } else if (state._tessellationEvaluationShaderID != -1) { - removeTessEvalShader(state); + removeTessEvalShader(state); state._tessellationEvaluationShaderID = -1; } } @@ -195,7 +198,7 @@ public abstract class JoglShaderObjectsStateUtil { } private static void checkLinkError(final int programId) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.getGL2().glGetObjectParameterivARB(programId, GL2ES2.GL_LINK_STATUS, compiled); @@ -221,7 +224,7 @@ public abstract class JoglShaderObjectsStateUtil { /** Removes the fragment shader */ private static void removeFragShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._fragmentShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._fragmentShaderID); @@ -231,7 +234,7 @@ public abstract class JoglShaderObjectsStateUtil { /** Removes the vertex shader */ private static void removeVertShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._vertexShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._vertexShaderID); @@ -241,27 +244,27 @@ public abstract class JoglShaderObjectsStateUtil { /** Removes the geometry shader */ private static void removeGeomShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._geometryShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._geometryShaderID); gl.getGL2().glDeleteObjectARB(state._geometryShaderID); } } - + /** Removes the tessellation control shader */ private static void removeTessControlShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._tessellationControlShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._tessellationControlShaderID); gl.getGL2().glDeleteObjectARB(state._tessellationControlShaderID); } } - + /** Removes the tessellation evaluation shader */ private static void removeTessEvalShader(final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (state._tessellationEvaluationShaderID != -1) { gl.getGL2().glDetachObjectARB(state._programID, state._tessellationEvaluationShaderID); @@ -278,7 +281,7 @@ public abstract class JoglShaderObjectsStateUtil { * shader's id */ private static void checkProgramError(final IntBuffer compiled, final int id, final String shaderName) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (compiled.get(0) == GL.GL_FALSE) { final IntBuffer iVal = BufferUtils.createIntBuffer(1); @@ -298,13 +301,13 @@ public abstract class JoglShaderObjectsStateUtil { logger.severe(out); - final String nameString = shaderName.equals("") ? "" : " [ " + shaderName + " ]"; + final String nameString = shaderName.equals("") ? "" : " [ " + shaderName + " ]"; throw new Ardor3dException("Error compiling GLSL shader " + nameString + ": " + out); } } public static void apply(final JoglRenderer renderer, final GLSLShaderObjectsState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java index ba3dea0..426befb 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java @@ -11,21 +11,21 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; +import javax.media.opengl.GLContext; import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.ShadingState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.ShadingState; import com.ardor3d.renderer.state.ShadingState.ShadingMode; import com.ardor3d.renderer.state.record.ShadingStateRecord; public abstract class JoglShadingStateUtil { public static void apply(final JoglRenderer renderer, final ShadingState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java index fd7204f..d624b60 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java @@ -12,14 +12,14 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.StencilState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.StencilState; import com.ardor3d.renderer.state.StencilState.StencilFunction; import com.ardor3d.renderer.state.StencilState.StencilOperation; import com.ardor3d.renderer.state.record.StencilStateRecord; @@ -27,7 +27,7 @@ import com.ardor3d.renderer.state.record.StencilStateRecord; public abstract class JoglStencilStateUtil { public static void apply(final JoglRenderer renderer, final StencilState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -40,25 +40,26 @@ public abstract class JoglStencilStateUtil { if (state.isUseTwoSided() && caps.isTwoSidedStencilSupported()) { gl.getGL2().glActiveStencilFaceEXT(GL.GL_BACK); applyMask(state.getStencilWriteMaskBack(), record, 2); - applyFunc(getGLStencilFunction(state.getStencilFunctionBack()), state.getStencilReferenceBack(), state - .getStencilFuncMaskBack(), record, 2); - applyOp(getGLStencilOp(state.getStencilOpFailBack(), caps), getGLStencilOp(state - .getStencilOpZFailBack(), caps), getGLStencilOp(state.getStencilOpZPassBack(), caps), record, 2); + applyFunc(getGLStencilFunction(state.getStencilFunctionBack()), state.getStencilReferenceBack(), + state.getStencilFuncMaskBack(), record, 2); + applyOp(getGLStencilOp(state.getStencilOpFailBack(), caps), + getGLStencilOp(state.getStencilOpZFailBack(), caps), + getGLStencilOp(state.getStencilOpZPassBack(), caps), record, 2); gl.getGL2().glActiveStencilFaceEXT(GL.GL_FRONT); applyMask(state.getStencilWriteMaskFront(), record, 1); applyFunc(getGLStencilFunction(state.getStencilFunctionFront()), state.getStencilReferenceFront(), state.getStencilFuncMaskFront(), record, 1); - applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), getGLStencilOp(state - .getStencilOpZFailFront(), caps), getGLStencilOp(state.getStencilOpZPassFront(), caps), record, - 1); + applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), + getGLStencilOp(state.getStencilOpZFailFront(), caps), + getGLStencilOp(state.getStencilOpZPassFront(), caps), record, 1); } else { applyMask(state.getStencilWriteMaskFront(), record, 0); applyFunc(getGLStencilFunction(state.getStencilFunctionFront()), state.getStencilReferenceFront(), state.getStencilFuncMaskFront(), record, 0); - applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), getGLStencilOp(state - .getStencilOpZFailFront(), caps), getGLStencilOp(state.getStencilOpZPassFront(), caps), record, - 0); + applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps), + getGLStencilOp(state.getStencilOpZFailFront(), caps), + getGLStencilOp(state.getStencilOpZPassFront(), caps), record, 0); } } @@ -119,7 +120,7 @@ public abstract class JoglStencilStateUtil { private static void setEnabled(final boolean enable, final boolean twoSided, final StencilStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (enable && !record.enabled) { @@ -141,7 +142,7 @@ public abstract class JoglStencilStateUtil { private static void setTwoSidedEnabled(final boolean enable, final StencilStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (caps.isTwoSidedStencilSupported()) { if (record.isValid()) { @@ -162,7 +163,7 @@ public abstract class JoglStencilStateUtil { } private static void applyMask(final int writeMask, final StencilStateRecord record, final int face) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // if (!record.isValid() || writeMask != record.writeMask[face]) { gl.glStencilMask(writeMask); @@ -172,7 +173,7 @@ public abstract class JoglStencilStateUtil { private static void applyFunc(final int glfunc, final int stencilRef, final int funcMask, final StencilStateRecord record, final int face) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // if (!record.isValid() || glfunc != record.func[face] || stencilRef != record.ref[face] // || funcMask != record.funcMask[face]) { @@ -185,7 +186,7 @@ public abstract class JoglStencilStateUtil { private static void applyOp(final int fail, final int zfail, final int zpass, final StencilStateRecord record, final int face) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // if (!record.isValid() || fail != record.fail[face] || zfail != record.zfail[face] // || zpass != record.zpass[face]) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java index e98ced2..0cb091c 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java @@ -20,6 +20,7 @@ import javax.media.opengl.GL2; import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.fixedfunc.GLMatrixFunc; import javax.media.opengl.glu.GLU; @@ -27,10 +28,6 @@ import javax.media.opengl.glu.gl2.GLUgl2; import com.ardor3d.image.Image; import com.ardor3d.image.Texture; -import com.ardor3d.image.Texture1D; -import com.ardor3d.image.Texture2D; -import com.ardor3d.image.Texture3D; -import com.ardor3d.image.TextureCubeMap; import com.ardor3d.image.Texture.ApplyMode; import com.ardor3d.image.Texture.CombinerFunctionAlpha; import com.ardor3d.image.Texture.CombinerFunctionRGB; @@ -40,6 +37,10 @@ import com.ardor3d.image.Texture.CombinerSource; import com.ardor3d.image.Texture.Type; import com.ardor3d.image.Texture.WrapAxis; import com.ardor3d.image.Texture.WrapMode; +import com.ardor3d.image.Texture1D; +import com.ardor3d.image.Texture2D; +import com.ardor3d.image.Texture3D; +import com.ardor3d.image.TextureCubeMap; import com.ardor3d.image.util.ImageUtils; import com.ardor3d.math.MathUtils; import com.ardor3d.math.type.ReadOnlyColorRGBA; @@ -47,8 +48,8 @@ import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.TextureState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.TextureState; import com.ardor3d.renderer.state.record.RendererRecord; import com.ardor3d.renderer.state.record.TextureRecord; import com.ardor3d.renderer.state.record.TextureStateRecord; @@ -70,7 +71,7 @@ public class JoglTextureStateUtil { return; } - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); if (context == null) { logger.warning("RenderContext is null for texture: " + texture); @@ -126,7 +127,7 @@ public class JoglTextureStateUtil { // our texture type: final Texture.Type type = texture.getType(); - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final GLU glu = new GLUgl2(); // bind our texture id to this unit. @@ -160,9 +161,8 @@ public class JoglTextureStateUtil { + image.getWidth() + " x " + image.getHeight()); } if (actualWidth > maxSize || actualHeight > maxSize) { - logger - .warning("(card unsupported) Attempted to apply texture with size bigger than max texture size [" - + maxSize + "]: " + image.getWidth() + " x " + image.getHeight()); + logger.warning("(card unsupported) Attempted to apply texture with size bigger than max texture size [" + + maxSize + "]: " + image.getWidth() + " x " + image.getHeight()); } int w = actualWidth; @@ -211,19 +211,20 @@ public class JoglTextureStateUtil { // ensure the buffer is ready for reading image.getData(0).rewind(); // send top level to card - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), image.getData(0)); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), + image.getHeight(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); break; case OneDimensional: // ensure the buffer is ready for reading image.getData(0).rewind(); // send top level to card - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), hasBorder ? 1 : 0, JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(0)); + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), + hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); break; case ThreeDimensional: if (caps.isTexture3DSupported()) { @@ -250,9 +251,10 @@ public class JoglTextureStateUtil { data.flip(); } // send top level to card - gl.getGL2GL3().glTexImage3D(GL2.GL_TEXTURE_3D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), image.getDepth(), - hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), image.getDepth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } else { logger.warning("This card does not support Texture3D."); @@ -266,19 +268,21 @@ public class JoglTextureStateUtil { // ensure the buffer is ready for reading image.getData(face.ordinal()).rewind(); // send top level to card - gl.glTexImage2D(getGLCubeMapFace(face), 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getWidth(), hasBorder ? 1 - : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), image.getData(face.ordinal())); + gl.glTexImage2D(getGLCubeMapFace(face), 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } else { logger.warning("This card does not support Cubemaps."); } break; case Rectangle: - break; + break; default: - break; + break; } } else if (texture.getMinificationFilter().usesMipMapLevels() && !image.hasMipmaps() && !texture.getTextureStoreFormat().isCompressed()) { @@ -299,16 +303,18 @@ public class JoglTextureStateUtil { image.getData(0).rewind(); if (caps.isAutomaticMipmapsSupported()) { // send top level to card - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), image.getData(0)); + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); } else { // send to card - glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(0)); + glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); } break; case OneDimensional: @@ -316,15 +322,15 @@ public class JoglTextureStateUtil { image.getData(0).rewind(); if (caps.isAutomaticMipmapsSupported()) { // send top level to card - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), hasBorder ? 1 : 0, JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(0)); + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); } else { // Note: JOGL's GLU class does not support // gluBuild1DMipmaps. - logger - .warning("non-fbo 1d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); + logger.warning("non-fbo 1d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); return; } break; @@ -354,16 +360,15 @@ public class JoglTextureStateUtil { data.flip(); } // send top level to card - gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), image.getWidth(), image.getHeight(), image - .getDepth(), hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image - .getDataFormat()), JoglTextureUtil.getGLPixelDataType(image.getDataType()), - data); + gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), image.getDepth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } else { // Note: JOGL's GLU class does not support // gluBuild3DMipmaps. - logger - .warning("non-fbo 3d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); + logger.warning("non-fbo 3d mipmap generation is not currently supported. Use DDS or a non-mipmap minification filter."); return; } } else { @@ -380,22 +385,24 @@ public class JoglTextureStateUtil { // ensure the buffer is ready for reading image.getData(face.ordinal()).rewind(); // send top level to card - gl.glTexImage2D(getGLCubeMapFace(face), 0, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), - image.getWidth(), hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image - .getDataFormat()), JoglTextureUtil.getGLPixelDataType(image - .getDataType()), image.getData(face.ordinal())); + gl.glTexImage2D(getGLCubeMapFace(face), 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } else { for (final TextureCubeMap.Face face : TextureCubeMap.Face.values()) { // ensure the buffer is ready for reading image.getData(face.ordinal()).rewind(); // send to card - glu.gluBuild2DMipmaps(getGLCubeMapFace(face), JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), - image.getWidth(), JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(face - .ordinal())); + glu.gluBuild2DMipmaps(getGLCubeMapFace(face), + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getWidth(), + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } } else { @@ -404,9 +411,9 @@ public class JoglTextureStateUtil { } break; case Rectangle: - break; + break; default: - break; + break; } if (texture.getTextureMaxLevel() >= 0) { @@ -432,7 +439,7 @@ public class JoglTextureStateUtil { } // set max mip level - gl.glTexParameteri(getGLCubeMapFace(face), GL2.GL_TEXTURE_MAX_LEVEL, max - 1); + gl.glTexParameteri(getGLCubeMapFace(face), GL2GL3.GL_TEXTURE_MAX_LEVEL, max - 1); for (int m = 0; m < max; m++) { final int width = Math.max(1, image.getWidth() >> m); @@ -442,13 +449,14 @@ public class JoglTextureStateUtil { data.limit(pos + mipSizes[m]); if (texture.getTextureStoreFormat().isCompressed()) { - gl.glCompressedTexImage2D(getGLCubeMapFace(face), m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - hasBorder ? 1 : 0, mipSizes[m], data); + gl.glCompressedTexImage2D(getGLCubeMapFace(face), m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.glTexImage2D(getGLCubeMapFace(face), m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + gl.glTexImage2D(getGLCubeMapFace(face), m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } pos += mipSizes[m]; @@ -480,12 +488,12 @@ public class JoglTextureStateUtil { case OneDimensional: gl.glTexParameteri(GL2GL3.GL_TEXTURE_1D, GL2GL3.GL_TEXTURE_MAX_LEVEL, max - 1); break; - case CubeMap: - break; - case Rectangle: - break; - default: - break; + case CubeMap: + break; + case Rectangle: + break; + default: + break; } if (type == Type.ThreeDimensional) { @@ -527,48 +535,51 @@ public class JoglTextureStateUtil { switch (type) { case TwoDimensional: if (texture.getTextureStoreFormat().isCompressed()) { - gl.glCompressedTexImage2D(GL.GL_TEXTURE_2D, m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - hasBorder ? 1 : 0, mipSizes[m], data); + gl.glCompressedTexImage2D(GL.GL_TEXTURE_2D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.glTexImage2D(GL.GL_TEXTURE_2D, m, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), width, height, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), data); + gl.glTexImage2D(GL.GL_TEXTURE_2D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } break; case OneDimensional: if (texture.getTextureStoreFormat().isCompressed()) { - gl.getGL2GL3().glCompressedTexImage1D(GL2GL3.GL_TEXTURE_1D, m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, hasBorder ? 1 - : 0, mipSizes[m], data); + gl.getGL2GL3().glCompressedTexImage1D(GL2GL3.GL_TEXTURE_1D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, m, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), width, hasBorder ? 1 : 0, JoglTextureUtil - .getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), data); + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } break; case ThreeDimensional: final int depth = Math.max(1, image.getDepth() >> m); // already checked for support above... if (texture.getTextureStoreFormat().isCompressed()) { - gl.getGL2GL3().glCompressedTexImage3D(GL2ES2.GL_TEXTURE_3D, m, JoglTextureUtil - .getGLInternalFormat(texture.getTextureStoreFormat()), width, height, - depth, hasBorder ? 1 : 0, mipSizes[m], data); + gl.getGL2GL3().glCompressedTexImage3D(GL2ES2.GL_TEXTURE_3D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, depth, hasBorder ? 1 : 0, mipSizes[m], data); } else { - gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, m, JoglTextureUtil.getGLInternalFormat(texture - .getTextureStoreFormat()), width, height, depth, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), JoglTextureUtil - .getGLPixelDataType(image.getDataType()), data); + gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, depth, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } break; case CubeMap: - break; + break; case Rectangle: - break; + break; default: - break; + break; } pos += mipSizes[m]; @@ -582,7 +593,7 @@ public class JoglTextureStateUtil { } public static void apply(final JoglRenderer renderer, final TextureState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -769,7 +780,7 @@ public class JoglTextureStateUtil { private static void disableTexturing(final TextureUnitRecord unitRecord, final TextureStateRecord record, final int unit, final Type exceptedType, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (exceptedType != Type.TwoDimensional) { if (!unitRecord.isValid() || unitRecord.enabled[Type.TwoDimensional.ordinal()]) { @@ -811,7 +822,7 @@ public class JoglTextureStateUtil { private static void disableTexturing(final TextureUnitRecord unitRecord, final TextureStateRecord record, final int unit, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!unitRecord.isValid() || unitRecord.enabled[Type.TwoDimensional.ordinal()]) { // Check we are in the right unit @@ -849,7 +860,7 @@ public class JoglTextureStateUtil { public static void applyCombineFactors(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // check that this is a valid fixed function unit. glTexEnv is only // supported for unit < GL_MAX_TEXTURE_UNITS @@ -877,7 +888,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_RGB_SCALE, texture.getCombineScaleRGB().floatValue()); + gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_RGB_SCALE, + texture.getCombineScaleRGB().floatValue()); unitRecord.envRGBScale = texture.getCombineScaleRGB(); } // Then Alpha Combine scale if (!unitRecord.isValid() || unitRecord.envAlphaScale != texture.getCombineScaleAlpha()) { @@ -885,7 +897,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_ALPHA_SCALE, texture.getCombineScaleAlpha().floatValue()); + gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_ALPHA_SCALE, + texture.getCombineScaleAlpha().floatValue()); unitRecord.envAlphaScale = texture.getCombineScaleAlpha(); } @@ -896,7 +909,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_RGB, JoglTextureUtil.getGLCombineFuncRGB(rgbCombineFunc)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_RGB, + JoglTextureUtil.getGLCombineFuncRGB(rgbCombineFunc)); unitRecord.rgbCombineFunc = rgbCombineFunc; } @@ -906,7 +920,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_RGB, JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB0 = combSrcRGB; } @@ -916,7 +931,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_RGB, JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB0 = combOpRGB; } @@ -929,7 +945,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_RGB, JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB1 = combSrcRGB; } @@ -939,7 +956,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_RGB, JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB1 = combOpRGB; } @@ -952,7 +970,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_RGB, JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB2 = combSrcRGB; } @@ -962,7 +981,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_RGB, JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB2 = combOpRGB; } @@ -976,8 +996,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_ALPHA, JoglTextureUtil - .getGLCombineFuncAlpha(alphaCombineFunc)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_ALPHA, + JoglTextureUtil.getGLCombineFuncAlpha(alphaCombineFunc)); unitRecord.alphaCombineFunc = alphaCombineFunc; } @@ -987,7 +1007,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_ALPHA, JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha0 = combSrcAlpha; } @@ -997,7 +1018,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_ALPHA, JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha0 = combOpAlpha; } @@ -1010,7 +1032,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_ALPHA, JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha1 = combSrcAlpha; } @@ -1020,7 +1043,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_ALPHA, JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha1 = combOpAlpha; } @@ -1033,7 +1057,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_ALPHA, JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha2 = combSrcAlpha; } @@ -1043,8 +1068,8 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_ALPHA, JoglTextureUtil - .getGLCombineOpAlpha(combOpAlpha)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha2 = combOpAlpha; } } @@ -1053,25 +1078,26 @@ public class JoglTextureStateUtil { public static void applyEnvMode(final ApplyMode mode, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!unitRecord.isValid() || unitRecord.envMode != mode) { checkAndSetUnit(unit, record, caps); - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, JoglTextureUtil.getGLEnvMode(mode)); + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, + JoglTextureUtil.getGLEnvMode(mode)); unitRecord.envMode = mode; } } public static void applyBlendColor(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final ReadOnlyColorRGBA texBlend = texture.getConstantColor(); if (!unitRecord.isValid() || !unitRecord.blendColor.equals(texBlend)) { checkAndSetUnit(unit, record, caps); TextureRecord.colorBuffer.clear(); - TextureRecord.colorBuffer.put(texBlend.getRed()).put(texBlend.getGreen()).put(texBlend.getBlue()).put( - texBlend.getAlpha()); + TextureRecord.colorBuffer.put(texBlend.getRed()).put(texBlend.getGreen()).put(texBlend.getBlue()) + .put(texBlend.getAlpha()); TextureRecord.colorBuffer.rewind(); gl.getGL2ES1().glTexEnvfv(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_COLOR, TextureRecord.colorBuffer); unitRecord.blendColor.set(texBlend); @@ -1080,7 +1106,7 @@ public class JoglTextureStateUtil { public static void applyLodBias(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (caps.isTextureLodBiasSupported()) { final float bias = texture.getLodBias() < caps.getMaxLodBias() ? texture.getLodBias() : caps @@ -1095,13 +1121,13 @@ public class JoglTextureStateUtil { public static void applyBorderColor(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final ReadOnlyColorRGBA texBorder = texture.getBorderColor(); if (!texRecord.isValid() || !texRecord.borderColor.equals(texBorder)) { TextureRecord.colorBuffer.clear(); - TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()).put( - texBorder.getAlpha()); + TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()) + .put(texBorder.getAlpha()); TextureRecord.colorBuffer.rewind(); gl.glTexParameterfv(getGLType(texture.getType()), GL2GL3.GL_TEXTURE_BORDER_COLOR, TextureRecord.colorBuffer); texRecord.borderColor.set(texBorder); @@ -1110,7 +1136,7 @@ public class JoglTextureStateUtil { public static void applyTextureTransforms(final Texture texture, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final boolean needsReset = !record.units[unit].identityMatrix; @@ -1141,7 +1167,7 @@ public class JoglTextureStateUtil { public static void applyTexCoordGeneration(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); switch (texture.getEnvironmentalMapMode()) { case None: @@ -1234,13 +1260,13 @@ public class JoglTextureStateUtil { gl.getGL2ES1().glTexGeni(GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenSMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.getGL2ES1().glTexGeni(GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenTMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.getGL2ES1().glTexGeni(GL2.GL_R, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenRMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_Q, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.getGL2ES1().glTexGeni(GL2.GL_Q, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); unitRecord.textureGenQMode = GL2.GL_OBJECT_LINEAR; } @@ -1261,7 +1287,7 @@ public class JoglTextureStateUtil { private static void setTextureGen(final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps, final boolean genS, final boolean genT, final boolean genR, final boolean genQ) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!unitRecord.isValid()) { checkAndSetUnit(unit, record, caps); @@ -1329,7 +1355,7 @@ public class JoglTextureStateUtil { // If we support multitexturing, specify the unit we are affecting. public static void checkAndSetUnit(final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // No need to worry about valid record, since invalidate sets record's // currentUnit to -1. @@ -1354,7 +1380,7 @@ public class JoglTextureStateUtil { */ public static void applyShadow(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Type type = texture.getType(); @@ -1398,7 +1424,7 @@ public class JoglTextureStateUtil { */ public static void applyFilter(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Type type = texture.getType(); @@ -1441,7 +1467,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final Texture3D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!caps.isTexture3DSupported()) { return; @@ -1480,7 +1506,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final Texture1D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); @@ -1524,7 +1550,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final Texture2D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); final int wrapT = getGLWrap(texture.getWrap(WrapAxis.T), caps); @@ -1553,7 +1579,7 @@ public class JoglTextureStateUtil { */ public static void applyWrap(final TextureCubeMap cubeMap, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!caps.isTextureCubeMapSupported()) { return; @@ -1581,7 +1607,7 @@ public class JoglTextureStateUtil { } public static void deleteTexture(final Texture texture) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -1603,7 +1629,7 @@ public class JoglTextureStateUtil { } public static void deleteTextureIds(final Collection<Integer> ids) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -1627,7 +1653,7 @@ public class JoglTextureStateUtil { * Useful for external jogl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); @@ -1660,9 +1686,9 @@ public class JoglTextureStateUtil { case CubeMap: return GL.GL_TEXTURE_CUBE_MAP; case Rectangle: - break; + break; default: - break; + break; } throw new IllegalArgumentException("invalid texture type: " + type); } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java index 50258b8..3cf3149 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java @@ -16,14 +16,14 @@ import java.util.logging.Logger; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.VertexProgramState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.VertexProgramState; import com.ardor3d.renderer.state.record.VertexProgramStateRecord; import com.ardor3d.util.geom.BufferUtils; @@ -35,7 +35,7 @@ public abstract class JoglVertexProgramStateUtil { * message. */ private static void checkProgramError() { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (gl.glGetError() == GL.GL_INVALID_OPERATION) { // retrieve the error position @@ -48,7 +48,7 @@ public abstract class JoglVertexProgramStateUtil { } private static int create(final ByteBuffer program) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final IntBuffer buf = BufferUtils.createIntBuffer(1); @@ -58,9 +58,8 @@ public abstract class JoglVertexProgramStateUtil { final byte array[] = new byte[program.limit()]; program.rewind(); program.get(array); - gl.getGL2() - .glProgramStringARB(GL2.GL_VERTEX_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, new String( - array)); + gl.getGL2().glProgramStringARB(GL2.GL_VERTEX_PROGRAM_ARB, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, array.length, + new String(array)); checkProgramError(); @@ -68,7 +67,7 @@ public abstract class JoglVertexProgramStateUtil { } public static void apply(final JoglRenderer renderer, final VertexProgramState state) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); @@ -97,10 +96,11 @@ public abstract class JoglVertexProgramStateUtil { // load environmental parameters... for (int i = 0; i < VertexProgramState._getEnvParameters().length; i++) { if (VertexProgramState._getEnvParameters()[i] != null) { - gl.getGL2().glProgramEnvParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i, VertexProgramState - ._getEnvParameters()[i][0], VertexProgramState._getEnvParameters()[i][1], - VertexProgramState._getEnvParameters()[i][2], VertexProgramState - ._getEnvParameters()[i][3]); + gl.getGL2().glProgramEnvParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i, + VertexProgramState._getEnvParameters()[i][0], + VertexProgramState._getEnvParameters()[i][1], + VertexProgramState._getEnvParameters()[i][2], + VertexProgramState._getEnvParameters()[i][3]); } } @@ -110,8 +110,8 @@ public abstract class JoglVertexProgramStateUtil { for (int i = 0; i < state._getParameters().length; i++) { if (state._getParameters()[i] != null) { gl.getGL2().glProgramLocalParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, i, - state._getParameters()[i][0], state._getParameters()[i][1], state - ._getParameters()[i][2], state._getParameters()[i][3]); + state._getParameters()[i][0], state._getParameters()[i][1], + state._getParameters()[i][2], state._getParameters()[i][3]); } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java index bf8b026..7172fc0 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java @@ -12,13 +12,13 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; import javax.media.opengl.GL2GL3; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; -import com.ardor3d.renderer.state.WireframeState; import com.ardor3d.renderer.state.RenderState.StateType; +import com.ardor3d.renderer.state.WireframeState; import com.ardor3d.renderer.state.record.WireframeStateRecord; public abstract class JoglWireframeStateUtil { @@ -54,7 +54,7 @@ public abstract class JoglWireframeStateUtil { } private static void applyPolyMode(final int frontMode, final int backMode, final WireframeStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (frontMode == backMode && (record.frontMode != frontMode || record.backMode != backMode)) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java index b806b02..4763ced 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java @@ -11,6 +11,7 @@ package com.ardor3d.scene.state.jogl; import javax.media.opengl.GL; +import javax.media.opengl.GLContext; import javax.media.opengl.glu.GLU; import com.ardor3d.renderer.ContextManager; @@ -67,7 +68,7 @@ public abstract class JoglZBufferStateUtil { } private static void enableDepthTest(final boolean enable, final ZBufferStateRecord record) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (enable && (!record.depthTest || !record.isValid())) { gl.glEnable(GL.GL_DEPTH_TEST); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java index 96927ae..006cdb8 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java @@ -13,9 +13,8 @@ package com.ardor3d.scene.state.jogl.shader; import java.util.logging.Logger; import javax.media.opengl.GL; -import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -104,10 +103,11 @@ public abstract class JoglShaderUtil { * shader program context ID */ public static void updateUniformLocation(final ShaderVariable variable, final int programID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (variable.variableID == -1) { - variable.variableID = gl.getGL2GL3().glGetUniformLocation(programID, variable.name); // TODO Check variable.name + variable.variableID = gl.getGL2GL3().glGetUniformLocation(programID, variable.name); // TODO Check + // variable.name if (variable.variableID == -1 && !variable.errorLogged) { logger.severe("Shader uniform [" + variable.name + "] could not be located in shader"); @@ -117,45 +117,50 @@ public abstract class JoglShaderUtil { } private static void updateShaderUniform(final ShaderVariableInt shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform1i(shaderUniform.variableID, shaderUniform.value1); } private static void updateShaderUniform(final ShaderVariableInt2 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform2i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); } private static void updateShaderUniform(final ShaderVariableInt3 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform3i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3); + gl.getGL2GL3().glUniform3i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3); } private static void updateShaderUniform(final ShaderVariableInt4 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform4i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3, - shaderUniform.value4); + gl.getGL2GL3().glUniform4i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3, shaderUniform.value4); } private static void updateShaderUniform(final ShaderVariableIntArray shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); switch (shaderUniform.size) { case 1: - gl.getGL2GL3().glUniform1iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform1iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 2: - gl.getGL2GL3().glUniform2iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform2iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 3: - gl.getGL2GL3().glUniform3iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform3iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 4: - gl.getGL2GL3().glUniform4iv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform4iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; default: throw new IllegalArgumentException("Wrong size: " + shaderUniform.size); @@ -163,45 +168,50 @@ public abstract class JoglShaderUtil { } private static void updateShaderUniform(final ShaderVariableFloat shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform1f(shaderUniform.variableID, shaderUniform.value1); } private static void updateShaderUniform(final ShaderVariableFloat2 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); gl.getGL2GL3().glUniform2f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); } private static void updateShaderUniform(final ShaderVariableFloat3 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform3f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3); + gl.getGL2GL3().glUniform3f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3); } private static void updateShaderUniform(final ShaderVariableFloat4 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); - gl.getGL2GL3().glUniform4f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3, - shaderUniform.value4); + gl.getGL2GL3().glUniform4f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3, shaderUniform.value4); } private static void updateShaderUniform(final ShaderVariableFloatArray shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); switch (shaderUniform.size) { case 1: - gl.getGL2GL3().glUniform1fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform1fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 2: - gl.getGL2GL3().glUniform2fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform2fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 3: - gl.getGL2GL3().glUniform3fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform3fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; case 4: - gl.getGL2GL3().glUniform4fv(shaderUniform.variableID, shaderUniform.value.remaining(), shaderUniform.value); + gl.getGL2GL3().glUniform4fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); break; default: throw new IllegalArgumentException("Wrong size: " + shaderUniform.size); @@ -209,28 +219,31 @@ public abstract class JoglShaderUtil { } private static void updateShaderUniform(final ShaderVariableMatrix2 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2GL3().glUniformMatrix2fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, shaderUniform.matrixBuffer); + gl.getGL2GL3().glUniformMatrix2fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); } private static void updateShaderUniform(final ShaderVariableMatrix3 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2GL3().glUniformMatrix3fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, shaderUniform.matrixBuffer); + gl.getGL2GL3().glUniformMatrix3fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); } private static void updateShaderUniform(final ShaderVariableMatrix4 shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2GL3().glUniformMatrix4fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, shaderUniform.matrixBuffer); + gl.getGL2GL3().glUniformMatrix4fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); } private static void updateShaderUniform(final ShaderVariableMatrix4Array shaderUniform) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); // count == number of matrices we are sending, or iotw, limit / 16 @@ -247,10 +260,11 @@ public abstract class JoglShaderUtil { * shader program context ID */ public static void updateAttributeLocation(final ShaderVariable variable, final int programID) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (variable.variableID == -1) { - variable.variableID = gl.getGL2GL3().glGetAttribLocation(programID, variable.name); // TODO Check variable.name + variable.variableID = gl.getGL2GL3().glGetAttribLocation(programID, variable.name); // TODO Check + // variable.name if (variable.variableID == -1 && !variable.errorLogged) { logger.severe("Shader attribute [" + variable.name + "] could not be located in shader"); @@ -307,7 +321,7 @@ public abstract class JoglShaderUtil { public static void useShaderProgram(final int id, final ShaderObjectsStateRecord record) { if (record.shaderId != id) { - GLU.getCurrentGL().getGL2().glUseProgramObjectARB(id); + GLContext.getCurrentGL().getGL2().glUseProgramObjectARB(id); record.shaderId = id; } } @@ -315,9 +329,9 @@ public abstract class JoglShaderUtil { private static void enableVertexAttribute(final ShaderVariable var, final ShaderObjectsStateRecord record) { if (!record.enabledAttributes.contains(var)) { if (var.getSize() == 1) { - GLU.getCurrentGL().getGL2GL3().glEnableVertexAttribArray(var.variableID); + GLContext.getCurrentGL().getGL2GL3().glEnableVertexAttribArray(var.variableID); } else { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); for (int i = 0, max = var.getSize(); i < max; i++) { gl.getGL2GL3().glEnableVertexAttribArray(var.variableID + i); } @@ -333,18 +347,24 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, - variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, variable.normalized, + variable.stride, 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, - variable.normalized, variable.stride, variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, variable.normalized, + variable.stride, variable.data.getBuffer()); } } private static void updateShaderAttribute(final ShaderVariablePointerFloatMatrix variable, final ShaderObjectsStateRecord record, final boolean useVBO) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final int size = variable.size; final int length = variable.data.getBuffer().capacity() / size; final RenderContext context = ContextManager.getCurrentContext(); @@ -355,12 +375,13 @@ public abstract class JoglShaderUtil { if (useVBO) { final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, 0, pos); + gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, + 0, pos); } else { variable.data.getBuffer().limit(pos + length - 1); variable.data.getBuffer().position(pos); - gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, 0, - variable.data.getBuffer()); + gl.getGL2GL3().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, + 0, variable.data.getBuffer()); } } } @@ -372,13 +393,20 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, + 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, - variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, + variable.data.getBuffer()); } } @@ -389,13 +417,20 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, + variable.stride, 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, variable.stride, - variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, + variable.stride, variable.data.getBuffer()); } } @@ -406,13 +441,20 @@ public abstract class JoglShaderUtil { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, variable.stride, 0); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, + variable.stride, 0); } else { variable.data.getBuffer().rewind(); - GLU.getCurrentGL().getGL2GL3().glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, variable.stride, - variable.data.getBuffer()); + GLContext + .getCurrentGL() + .getGL2GL3() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, + variable.stride, variable.data.getBuffer()); } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java index 88f006e..4c87387 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java @@ -13,7 +13,7 @@ package com.ardor3d.scene.state.jogl.util; import java.util.Stack; import javax.media.opengl.GL; -import javax.media.opengl.glu.GLU; +import javax.media.opengl.GLContext; import com.ardor3d.math.Rectangle2; import com.ardor3d.math.type.ReadOnlyRectangle2; @@ -22,7 +22,7 @@ import com.ardor3d.renderer.state.record.RendererRecord; public abstract class JoglRendererUtil { public static void switchMode(final RendererRecord rendRecord, final int mode) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isMatrixValid() || rendRecord.getMatrixMode() != mode) { gl.getGL2().glMatrixMode(mode); @@ -32,7 +32,7 @@ public abstract class JoglRendererUtil { } public static void setBoundVBO(final RendererRecord rendRecord, final int id) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isVboValid() || rendRecord.getCurrentVboId() != id) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, id); @@ -42,7 +42,7 @@ public abstract class JoglRendererUtil { } public static void setBoundElementVBO(final RendererRecord rendRecord, final int id) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isElementVboValid() || rendRecord.getCurrentElementVboId() != id) { gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, id); @@ -52,7 +52,7 @@ public abstract class JoglRendererUtil { } public static void applyScissors(final RendererRecord rendRecord) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); final Stack<ReadOnlyRectangle2> clips = rendRecord.getScissorClips(); if (clips.size() > 0) { @@ -93,7 +93,7 @@ public abstract class JoglRendererUtil { } public static void setClippingEnabled(final RendererRecord rendRecord, final boolean enabled) { - final GL gl = GLU.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (enabled && (!rendRecord.isClippingTestValid() || !rendRecord.isClippingTestEnabled())) { gl.glEnable(GL.GL_SCISSOR_TEST); diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglHeadlessCanvas.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglHeadlessCanvas.java index 26f8d78..895bc63 100644 --- a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglHeadlessCanvas.java +++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglHeadlessCanvas.java @@ -16,6 +16,8 @@ import java.nio.IntBuffer; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.ARBMultisample; +import org.lwjgl.opengl.EXTFramebufferBlit; +import org.lwjgl.opengl.EXTFramebufferMultisample; import org.lwjgl.opengl.EXTFramebufferObject; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @@ -36,7 +38,6 @@ import com.ardor3d.renderer.lwjgl.LwjglContextCapabilities; import com.ardor3d.renderer.lwjgl.LwjglRenderer; import com.ardor3d.renderer.lwjgl.LwjglTextureRenderer; import com.ardor3d.util.Ardor3dException; -import com.ardor3d.util.Constants; import com.ardor3d.util.geom.BufferUtils; /** @@ -57,6 +58,8 @@ public class LwjglHeadlessCanvas { protected Camera _camera; protected int _fboID, _depthRBID, _colorRBID; + protected int _msfboID, _msdepthRBID, _mscolorRBID; + protected boolean _useMSAA = false; protected IntBuffer _data; protected Pbuffer _buff; @@ -82,19 +85,11 @@ public class LwjglHeadlessCanvas { try { // Create a Pbuffer so we can have a valid gl context to work with final PixelFormat format = new PixelFormat(_settings.getAlphaBits(), _settings.getDepthBits(), - _settings.getStencilBits()).withSamples(_settings.getSamples()); + _settings.getStencilBits()); _buff = new Pbuffer(1, 1, format, null); _buff.makeCurrent(); } catch (final LWJGLException ex) { - try { - // try again without samples - final PixelFormat format = new PixelFormat(_settings.getAlphaBits(), _settings.getDepthBits(), - _settings.getStencilBits()); - _buff = new Pbuffer(1, 1, format, null); - _buff.makeCurrent(); - } catch (final LWJGLException ex2) { - ex2.printStackTrace(); - } + ex.printStackTrace(); } // Set up our Ardor3D context and capabilities objects @@ -105,6 +100,10 @@ public class LwjglHeadlessCanvas { throw new Ardor3dException("Headless requires FBO support."); } + if (caps.isFBOMultisampleSupported() && caps.isFBOBlitSupported() && _settings.getSamples() > 0) { + _useMSAA = true; + } + // Init our FBO. final IntBuffer buffer = BufferUtils.createIntBuffer(1); EXTFramebufferObject.glGenFramebuffersEXT(buffer); // generate id @@ -113,12 +112,13 @@ public class LwjglHeadlessCanvas { _fboID = buffer.get(0); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _fboID); - // initial our color renderbuffer + // initialize our color renderbuffer EXTFramebufferObject.glGenRenderbuffersEXT(buffer); // generate id _colorRBID = buffer.get(0); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _colorRBID); EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL11.GL_RGBA, width, height); + // Attach color renderbuffer to framebuffer EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, _colorRBID); @@ -129,6 +129,7 @@ public class LwjglHeadlessCanvas { EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRBID); EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL11.GL_DEPTH_COMPONENT, width, height); + // Attach depth renderbuffer to framebuffer EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRBID); @@ -136,6 +137,47 @@ public class LwjglHeadlessCanvas { // Check FBO complete LwjglTextureRenderer.checkFBOComplete(_fboID); + // Now do it all again for multisample, if requested and supported + if (_useMSAA) { + + // Init our ms FBO. + EXTFramebufferObject.glGenFramebuffersEXT(buffer); // generate id + + // Bind the ms FBO + _msfboID = buffer.get(0); + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _msfboID); + + // initialize our ms color renderbuffer + EXTFramebufferObject.glGenRenderbuffersEXT(buffer); // generate id + _mscolorRBID = buffer.get(0); + EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _mscolorRBID); + EXTFramebufferMultisample.glRenderbufferStorageMultisampleEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, + _settings.getSamples(), GL11.GL_RGBA, width, height); + + // Attach ms color renderbuffer to ms framebuffer + EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, + EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, + _mscolorRBID); + + // initialize our ms depth renderbuffer + EXTFramebufferObject.glGenRenderbuffersEXT(buffer); // generate id + _msdepthRBID = buffer.get(0); + EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _msdepthRBID); + EXTFramebufferMultisample.glRenderbufferStorageMultisampleEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, + _settings.getSamples(), GL11.GL_DEPTH_COMPONENT, width, height); + + // Attach ms depth renderbuffer to ms framebuffer + EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, + EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, + _msdepthRBID); + + // Check MS FBO complete + LwjglTextureRenderer.checkFBOComplete(_msfboID); + + // enable multisample + GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB); + } + // Setup our data buffer for storing rendered image data. _data = ByteBuffer.allocateDirect(width * height * 4).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); @@ -143,11 +185,6 @@ public class LwjglHeadlessCanvas { ContextManager.addContext(this, currentContext); ContextManager.switchContext(this); - // Turn on multisample if requested... - if (_settings.getSamples() != 0 && caps.isMultisampleSupported()) { - GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB); - } - // Setup a default bg color. _renderer.setBackgroundColor(ColorRGBA.BLACK); @@ -163,17 +200,14 @@ public class LwjglHeadlessCanvas { final Vector3 dir = new Vector3(0.0f, 0f, -1.0f); _camera.setFrame(loc, left, up, dir); - if (Constants.useMultipleContexts) { - // release our FBO until used. - EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); - } + // release our FBO(s) until used. + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); } public void draw() { - if (Constants.useMultipleContexts) { - // activate FBO - EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _fboID); - } + // bind correct fbo + EXTFramebufferObject + .glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _useMSAA ? _msfboID : _fboID); // Make sure this OpenGL context is current. ContextManager.switchContext(this); @@ -197,15 +231,25 @@ public class LwjglHeadlessCanvas { _scene.renderUnto(_renderer); _renderer.flushFrame(false); + // if we're multisampled, we need to blit to a non-multisampled fbo first + if (_useMSAA) { + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_DRAW_FRAMEBUFFER_EXT, _fboID); + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_READ_FRAMEBUFFER_EXT, _msfboID); + EXTFramebufferBlit.glBlitFramebufferEXT(0, 0, _settings.getWidth(), _settings.getHeight(), 0, 0, + _settings.getWidth(), _settings.getHeight(), GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT + | GL11.GL_STENCIL_BUFFER_BIT, GL11.GL_NEAREST); + + // get ready to read non-msaa fbo + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _fboID); + } + // read data from our color buffer _data.rewind(); GL11.glReadBuffer(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT); GL11.glReadPixels(0, 0, _settings.getWidth(), _settings.getHeight(), GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, _data); - if (Constants.useMultipleContexts) { - // release our FBO. - EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); - } + // release our FBO. + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); } public void releaseContext() throws LWJGLException { diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.java index af52d28..08f6e32 100644 --- a/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.java +++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.java @@ -80,7 +80,12 @@ public class LwjglContextCapabilities extends ContextCapabilities { // FBO _fboSupported = caps.GL_EXT_framebuffer_object; + System.err.println(caps.GL_EXT_framebuffer_multisample); if (_fboSupported) { + + _supportsFBOMultisample = caps.GL_EXT_framebuffer_multisample; + _supportsFBOBlit = caps.GL_EXT_framebuffer_blit; + if (caps.GL_ARB_draw_buffers) { GL11.glGetInteger(EXTFramebufferObject.GL_MAX_COLOR_ATTACHMENTS_EXT, buf); _maxFBOColorAttachments = buf.get(0); diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java b/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java index ea11e50..a6879cd 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java @@ -443,19 +443,19 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo final String blue = Integer.toHexString(Math.round(MathUtils.clamp(getBlue(), 0f, 1f) * 255)); final String alpha = Integer.toHexString(Math.round(MathUtils.clamp(getAlpha(), 0f, 1f) * 255)); if (red.length() < 2) { - sb.append("0"); + sb.append('0'); } sb.append(red); if (green.length() < 2) { - sb.append("0"); + sb.append('0'); } sb.append(green); if (blue.length() < 2) { - sb.append("0"); + sb.append('0'); } sb.append(blue); if (alpha.length() < 2) { - sb.append("0"); + sb.append('0'); } sb.append(alpha); return sb.toString(); @@ -995,7 +995,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo } // XXX: should we parse words too? eg 'red'... - if (!colorString.startsWith("#")) { + if (colorString.length() == 0 || colorString.charAt(0) != '#') { throw new IllegalArgumentException("must start with #."); } diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/FastMath.java b/ardor3d-math/src/main/java/com/ardor3d/math/FastMath.java index 6ef29eb..0b45885 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/FastMath.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/FastMath.java @@ -83,7 +83,7 @@ public enum FastMath { /** inverseSqrt: (0,‚àû) -> (0,‚àû) **/ public final static double inverseSqrt(double x) { final double xhalves = 0.5d * x; - x = Double.longBitsToDouble(0x5FE6EB50C7B537AAl - (Double.doubleToRawLongBits(x) >> 1)); + x = Double.longBitsToDouble(0x5FE6EB50C7B537AAL - (Double.doubleToRawLongBits(x) >> 1)); return x * (1.5d - xhalves * x * x); // more iterations possible } diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java index a13ddc4..78a9b16 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java @@ -1705,31 +1705,31 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr @Override public String toString() { final StringBuffer result = new StringBuffer("com.ardor3d.math.Matrix3\n[\n"); - result.append(" "); + result.append(' '); result.append(_m00); - result.append(" "); + result.append(' '); result.append(_m01); - result.append(" "); + result.append(' '); result.append(_m02); result.append(" \n"); - result.append(" "); + result.append(' '); result.append(_m10); - result.append(" "); + result.append(' '); result.append(_m11); - result.append(" "); + result.append(' '); result.append(_m12); result.append(" \n"); - result.append(" "); + result.append(' '); result.append(_m20); - result.append(" "); + result.append(' '); result.append(_m21); - result.append(" "); + result.append(' '); result.append(_m22); result.append(" \n"); - result.append("]"); + result.append(']'); return result.toString(); } diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java index 9b2131f..8d21433 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java @@ -2099,47 +2099,47 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr @Override public String toString() { final StringBuffer result = new StringBuffer("com.ardor3d.math.Matrix4\n[\n"); - result.append(" "); + result.append(' '); result.append(_m00); - result.append(" "); + result.append(' '); result.append(_m01); - result.append(" "); + result.append(' '); result.append(_m02); - result.append(" "); + result.append(' '); result.append(_m03); result.append(" \n"); - result.append(" "); + result.append(' '); result.append(_m10); - result.append(" "); + result.append(' '); result.append(_m11); - result.append(" "); + result.append(' '); result.append(_m12); - result.append(" "); + result.append(' '); result.append(_m13); result.append(" \n"); - result.append(" "); + result.append(' '); result.append(_m20); - result.append(" "); + result.append(' '); result.append(_m21); - result.append(" "); + result.append(' '); result.append(_m22); - result.append(" "); + result.append(' '); result.append(_m23); result.append(" \n"); - result.append(" "); + result.append(' '); result.append(_m30); - result.append(" "); + result.append(' '); result.append(_m31); - result.append(" "); + result.append(' '); result.append(_m32); - result.append(" "); + result.append(' '); result.append(_m33); result.append(" \n"); - result.append("]"); + result.append(']'); return result.toString(); } diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java index a642655..6817b5e 100644 --- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java +++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/ClipmapLevel.java @@ -11,7 +11,6 @@ package com.ardor3d.extension.terrain.client;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
import java.util.Set;
import com.ardor3d.bounding.BoundingBox;
@@ -20,9 +19,10 @@ import com.ardor3d.extension.terrain.util.Tile; import com.ardor3d.math.MathUtils;
import com.ardor3d.math.Vector3;
import com.ardor3d.renderer.Camera;
-import com.ardor3d.renderer.IndexMode;
import com.ardor3d.renderer.Camera.FrustumIntersect;
+import com.ardor3d.renderer.IndexMode;
import com.ardor3d.scenegraph.FloatBufferData;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.scenegraph.event.DirtyType;
import com.ardor3d.util.geom.BufferUtils;
@@ -181,9 +181,9 @@ public class ClipmapLevel extends Mesh { // getMeshData().setTextureBuffer(textureCoords, 0);
final int indicesSize = 4 * (3 * frameSize * frameSize + clipSideSize * clipSideSize / 2 + 4 * frameSize - 10);
- final IntBuffer indices = BufferUtils.createIntBuffer(indicesSize);
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(indicesSize, vertices.capacity() - 1);
tmpIndices = new int[indicesSize];
- getMeshData().setIndexBuffer(indices);
+ getMeshData().setIndices(indices);
// Go through all rows and fill them with vertexindices.
for (int z = 0; z < clipSideSize - 1; z++) {
@@ -332,9 +332,8 @@ public class ClipmapLevel extends Mesh { clipRegion.getTop(), clipRegion.getTop() + frameDistance);
// MxM Block 4
- fillBlock(clipRegion.getRight() - frameDistance, clipRegion.getRight(), clipRegion.getTop(), clipRegion
- .getTop()
- + frameDistance);
+ fillBlock(clipRegion.getRight() - frameDistance, clipRegion.getRight(), clipRegion.getTop(),
+ clipRegion.getTop() + frameDistance);
// MxM Block 5
fillBlock(clipRegion.getLeft(), clipRegion.getLeft() + frameDistance, clipRegion.getTop() + frameDistance,
@@ -357,14 +356,12 @@ public class ClipmapLevel extends Mesh { clipRegion.getBottom());
// MxM Block 10
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getLeft() + 2 * frameDistance, clipRegion
- .getBottom()
- - frameDistance, clipRegion.getBottom());
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getLeft() + 2 * frameDistance,
+ clipRegion.getBottom() - frameDistance, clipRegion.getBottom());
// MxM Block 11
- fillBlock(clipRegion.getRight() - 2 * frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getBottom()
- - frameDistance, clipRegion.getBottom());
+ fillBlock(clipRegion.getRight() - 2 * frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getBottom() - frameDistance, clipRegion.getBottom());
// MxM Block 12
fillBlock(clipRegion.getRight() - frameDistance, clipRegion.getRight(), clipRegion.getBottom() - frameDistance,
@@ -392,14 +389,12 @@ public class ClipmapLevel extends Mesh { // Upper Left L Shape
// Up
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getTop()
- + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getTop() + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
// Left
fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getLeft() + frameDistance
- + vertexDistance, clipRegion.getTop() + frameDistance + vertexDistance, clipRegion
- .getBottom()
- - frameDistance);
+ + vertexDistance, clipRegion.getTop() + frameDistance + vertexDistance,
+ clipRegion.getBottom() - frameDistance);
} else {
// Lower Left L Shape
@@ -409,23 +404,21 @@ public class ClipmapLevel extends Mesh { - frameDistance - vertexDistance);
// Bottom
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getBottom()
- - frameDistance - vertexDistance, clipRegion.getBottom() - frameDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getBottom() - frameDistance - vertexDistance, clipRegion.getBottom()
+ - frameDistance);
}
} else {
if ((nextFinerLevel.clipRegion.getY() - clipRegion.getY()) / vertexDistance == frameSize) {
// Upper Right L Shape
// Up
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getTop()
- + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getTop() + frameDistance, clipRegion.getTop() + frameDistance + vertexDistance);
// Right
fillBlock(clipRegion.getRight() - frameDistance - vertexDistance, clipRegion.getRight()
- - frameDistance, clipRegion.getTop() + frameDistance + vertexDistance, clipRegion
- .getBottom()
- - frameDistance);
+ - frameDistance, clipRegion.getTop() + frameDistance + vertexDistance,
+ clipRegion.getBottom() - frameDistance);
} else {
// Lower Right L Shape
@@ -435,9 +428,9 @@ public class ClipmapLevel extends Mesh { - frameDistance - vertexDistance);
// Bottom
- fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance, clipRegion
- .getBottom()
- - frameDistance - vertexDistance, clipRegion.getBottom() - frameDistance);
+ fillBlock(clipRegion.getLeft() + frameDistance, clipRegion.getRight() - frameDistance,
+ clipRegion.getBottom() - frameDistance - vertexDistance, clipRegion.getBottom()
+ - frameDistance);
}
}
}
@@ -457,7 +450,7 @@ public class ClipmapLevel extends Mesh { clipRegion.getTop() + frameDistance + clipSideSize / 2, clipRegion.getBottom() - frameDistance);
}
- final IntBuffer indices = (IntBuffer) getMeshData().getIndexBuffer();
+ final IndexBufferData<?> indices = getMeshData().getIndices();
indices.clear();
indices.put(tmpIndices, 0, getStripIndex());
indices.flip();
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java index 3b0afea..5da7e51 100644 --- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java +++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java @@ -278,7 +278,7 @@ public class Terrain extends Node implements Pickable { for (int i = _clips.size() - 1; i >= _visibleLevels; i--) {
final ClipmapLevel clip = _clips.get(i);
- clip.getMeshData().getIndexBuffer().limit(clip.getMeshData().getIndexBuffer().capacity());
+ clip.getMeshData().getIndices().limit(clip.getMeshData().getIndices().capacity());
}
_initialized = true;
diff --git a/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRGB.java b/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRGB.java index 13f530c..887a85c 100644 --- a/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRGB.java +++ b/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRGB.java @@ -12,8 +12,6 @@ package com.ardor3d.extension.terrain.util; import org.junit.Test; -import com.ardor3d.extension.terrain.util.IntColorUtils; - public class TestRGB { @Test public void testLerp() throws Exception { diff --git a/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRegion.java b/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRegion.java index 4e1c700..66f3345 100644 --- a/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRegion.java +++ b/ardor3d-terrain/src/test/java/com/ardor3d/extension/terrain/util/TestRegion.java @@ -14,8 +14,6 @@ import junit.framework.Assert; import org.junit.Test; -import com.ardor3d.extension.terrain.util.Region; - public class TestRegion { @Test public void testIntersects() throws Exception { diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java index 9d2b983..9cbab74 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java @@ -427,6 +427,12 @@ public abstract class UIComponent extends Node implements UIKeyHandler { public void setContentSize(final int width, final int height) { setContentWidth(width); setContentHeight(height); + if (_maximumContentsSize.getWidth() < width) { + _maximumContentsSize.setWidth(width); + } + if (_maximumContentsSize.getHeight() < height) { + _maximumContentsSize.setHeight(height); + } } /** @@ -437,8 +443,8 @@ public abstract class UIComponent extends Node implements UIKeyHandler { * the new height */ public void setContentHeight(final int height) { - _contentsSize.setHeight(MathUtils.clamp(height, _minimumContentsSize.getHeight(), _maximumContentsSize - .getHeight())); + _contentsSize.setHeight(MathUtils.clamp(height, _minimumContentsSize.getHeight(), + _maximumContentsSize.getHeight())); } /** @@ -607,8 +613,8 @@ public abstract class UIComponent extends Node implements UIKeyHandler { final Rectangle2 rect = getRelativeMinComponentBounds(null); final float ratio = Math.min((float) width / rect.getWidth(), (float) height / rect.getHeight()); - setLocalComponentSize(Math.round(getMinimumLocalComponentWidth() * ratio), Math - .round(getMinimumLocalComponentHeight() * ratio)); + setLocalComponentSize(Math.round(getMinimumLocalComponentWidth() * ratio), + Math.round(getMinimumLocalComponentHeight() * ratio)); } } diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java index 45fbebd..5a079b9 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java @@ -18,11 +18,12 @@ import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.IndexMode;
import com.ardor3d.renderer.Renderer;
import com.ardor3d.renderer.state.BlendState;
-import com.ardor3d.renderer.state.ShadingState;
import com.ardor3d.renderer.state.BlendState.DestinationFunction;
import com.ardor3d.renderer.state.BlendState.SourceFunction;
+import com.ardor3d.renderer.state.ShadingState;
import com.ardor3d.renderer.state.ShadingState.ShadingMode;
import com.ardor3d.scenegraph.FloatBufferData;
+import com.ardor3d.scenegraph.IndexBufferData;
import com.ardor3d.scenegraph.Mesh;
import com.ardor3d.util.geom.BufferUtils;
@@ -198,7 +199,9 @@ public class SolidBorder extends UIBorder { mesh.getMeshData().setVertexCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2));
mesh.getMeshData().setColorBuffer(BufferUtils.createColorBuffer(8));
mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip);
- mesh.getMeshData().setIndexBuffer(BufferUtils.createIntBuffer(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 }));
+ final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(10, 7);
+ indices.put(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 });
+ mesh.getMeshData().setIndices(indices);
// set up alpha blending.
final BlendState blend = new BlendState();
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java index 4e30461..bd987b5 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/TextCaret.java @@ -37,7 +37,7 @@ public class TextCaret { public TextCaret() { final MeshData md = _strip.getMeshData(); md.setVertexBuffer(BufferUtils.createVector3Buffer(4)); - md.setIndexBuffer(BufferUtils.createIntBuffer(new int[] { 0, 1, 3, 2 })); + md.setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 2 }, 3)); md.setIndexMode(IndexMode.TriangleStrip); final float[] vals = new float[] { 0, 0, 0, // 1, 0, 0, // diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java index 405ff5b..6afa78f 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/parser/ForumLikeMarkupParser.java @@ -51,13 +51,13 @@ public class ForumLikeMarkupParser implements StyleParser { index++; continue; } else { - rVal.append("\\"); + rVal.append('\\'); rVal.append(token); index += token.length() + 1; continue; } } else { - rVal.append("\\"); + rVal.append('\\'); index++; continue; } @@ -138,9 +138,9 @@ public class ForumLikeMarkupParser implements StyleParser { endSpan(StyleConstants.KEY_FAMILY, store, index, buildingSpans); } else { // not really a tag, so put it back. - rVal.append("["); + rVal.append('['); rVal.append(currTagText); - rVal.append("]"); + rVal.append(']'); tagStatus = TagStatus.NONE; } @@ -51,12 +51,12 @@ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
- <version>2.3</version>
+ <version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.1</version>
+ <version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -119,14 +119,12 @@ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.5</version>
- <scope>test</scope>
+ <version>4.10</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>2.4</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
@@ -217,7 +215,7 @@ <bottom><![CDATA[<i>Copyright © {inceptionYear}-{currentYear} Ardor Labs. All Rights Reserved.</i>]]>
</bottom>
<links>
- <link>http://java.sun.com/javase/6/docs/api</link>
+ <link>http://docs.oracle.com/javase/6/docs/api/</link>
</links>
<linksource>true</linksource>
<quiet>true</quiet>
|