diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/javax/media/j3d/GLSLShaderProgram.java | 179 | ||||
-rw-r--r-- | src/javax/media/j3d/ShaderProgramRetained.java | 1233 | ||||
-rw-r--r-- | src/main/java-templates/org/jogamp/java3d/VersionInfo.java | 340 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Alpha.java (renamed from src/javax/media/j3d/Alpha.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AlternateAppearance.java (renamed from src/javax/media/j3d/AlternateAppearance.java) | 16 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AlternateAppearanceRetained.java (renamed from src/javax/media/j3d/AlternateAppearanceRetained.java) | 24 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AmbientLight.java (renamed from src/javax/media/j3d/AmbientLight.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AmbientLightRetained.java (renamed from src/javax/media/j3d/AmbientLightRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Appearance.java (renamed from src/javax/media/j3d/Appearance.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AppearanceRetained.java (renamed from src/javax/media/j3d/AppearanceRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AssertionFailureException.java (renamed from src/javax/media/j3d/AssertionFailureException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AttributeBin.java (renamed from src/javax/media/j3d/AttributeBin.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AudioDevice.java (renamed from src/javax/media/j3d/AudioDevice.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AudioDevice3D.java (renamed from src/javax/media/j3d/AudioDevice3D.java) | 12 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AudioDevice3DL2.java (renamed from src/javax/media/j3d/AudioDevice3DL2.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AudioDeviceEnumerator.java (renamed from src/javax/media/j3d/AudioDeviceEnumerator.java) | 21 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AuralAttributes.java (renamed from src/javax/media/j3d/AuralAttributes.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AuralAttributesRetained.java (renamed from src/javax/media/j3d/AuralAttributesRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/AutoOffScreenCanvas3D.java (renamed from src/javax/media/j3d/AutoOffScreenCanvas3D.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BHInsertStructure.java (renamed from src/javax/media/j3d/BHInsertStructure.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BHInternalNode.java (renamed from src/javax/media/j3d/BHInternalNode.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BHLeafInterface.java (renamed from src/javax/media/j3d/BHLeafInterface.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BHLeafNode.java (renamed from src/javax/media/j3d/BHLeafNode.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BHNode.java (renamed from src/javax/media/j3d/BHNode.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BHTree.java (renamed from src/javax/media/j3d/BHTree.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Background.java (renamed from src/javax/media/j3d/Background.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BackgroundRetained.java (renamed from src/javax/media/j3d/BackgroundRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BackgroundSound.java (renamed from src/javax/media/j3d/BackgroundSound.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BackgroundSoundRetained.java (renamed from src/javax/media/j3d/BackgroundSoundRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BadTransformException.java (renamed from src/javax/media/j3d/BadTransformException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Behavior.java (renamed from src/javax/media/j3d/Behavior.java) | 12 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BehaviorRetained.java (renamed from src/javax/media/j3d/BehaviorRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BehaviorScheduler.java (renamed from src/javax/media/j3d/BehaviorScheduler.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BehaviorStructure.java (renamed from src/javax/media/j3d/BehaviorStructure.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Billboard.java (renamed from src/javax/media/j3d/Billboard.java) | 18 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BoundingBox.java (renamed from src/javax/media/j3d/BoundingBox.java) | 50 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BoundingLeaf.java (renamed from src/javax/media/j3d/BoundingLeaf.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BoundingLeafRetained.java (renamed from src/javax/media/j3d/BoundingLeafRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BoundingPolytope.java (renamed from src/javax/media/j3d/BoundingPolytope.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BoundingSphere.java (renamed from src/javax/media/j3d/BoundingSphere.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Bounds.java (renamed from src/javax/media/j3d/Bounds.java) | 12 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BranchGroup.java (renamed from src/javax/media/j3d/BranchGroup.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/BranchGroupRetained.java (renamed from src/javax/media/j3d/BranchGroupRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CachedFrustum.java (renamed from src/javax/media/j3d/CachedFrustum.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CachedTargets.java (renamed from src/javax/media/j3d/CachedTargets.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Canvas3D.java (renamed from src/javax/media/j3d/Canvas3D.java) | 40 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CanvasViewCache.java (renamed from src/javax/media/j3d/CanvasViewCache.java) | 16 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CanvasViewEventCatcher.java (renamed from src/javax/media/j3d/CanvasViewEventCatcher.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CapabilityBits.java (renamed from src/javax/media/j3d/CapabilityBits.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CapabilityNotSetException.java (renamed from src/javax/media/j3d/CapabilityNotSetException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Clip.java (renamed from src/javax/media/j3d/Clip.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ClipRetained.java (renamed from src/javax/media/j3d/ClipRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ColorInterpolator.java (renamed from src/javax/media/j3d/ColorInterpolator.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ColoringAttributes.java (renamed from src/javax/media/j3d/ColoringAttributes.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ColoringAttributesRetained.java (renamed from src/javax/media/j3d/ColoringAttributesRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CompileState.java (renamed from src/javax/media/j3d/CompileState.java) | 7 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CompressedGeometry.java (renamed from src/javax/media/j3d/CompressedGeometry.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CompressedGeometryHeader.java (renamed from src/javax/media/j3d/CompressedGeometryHeader.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CompressedGeometryRenderMethod.java (renamed from src/javax/media/j3d/CompressedGeometryRenderMethod.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/CompressedGeometryRetained.java (renamed from src/javax/media/j3d/CompressedGeometryRetained.java) | 7 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ConeSound.java (renamed from src/javax/media/j3d/ConeSound.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ConeSoundRetained.java (renamed from src/javax/media/j3d/ConeSoundRetained.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Context.java (renamed from src/javax/media/j3d/Context.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DanglingReferenceException.java (renamed from src/javax/media/j3d/DanglingReferenceException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DecalGroup.java (renamed from src/javax/media/j3d/DecalGroup.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DecalGroupRetained.java (renamed from src/javax/media/j3d/DecalGroupRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DefaultRenderMethod.java (renamed from src/javax/media/j3d/DefaultRenderMethod.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponent.java (renamed from src/javax/media/j3d/DepthComponent.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponentFloat.java (renamed from src/javax/media/j3d/DepthComponentFloat.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponentFloatRetained.java (renamed from src/javax/media/j3d/DepthComponentFloatRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponentInt.java (renamed from src/javax/media/j3d/DepthComponentInt.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponentIntRetained.java (renamed from src/javax/media/j3d/DepthComponentIntRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponentNative.java (renamed from src/javax/media/j3d/DepthComponentNative.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponentNativeRetained.java (renamed from src/javax/media/j3d/DepthComponentNativeRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DepthComponentRetained.java (renamed from src/javax/media/j3d/DepthComponentRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DirectionalLight.java (renamed from src/javax/media/j3d/DirectionalLight.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DirectionalLightRetained.java (renamed from src/javax/media/j3d/DirectionalLightRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DisplayListRenderMethod.java (renamed from src/javax/media/j3d/DisplayListRenderMethod.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DistanceLOD.java (renamed from src/javax/media/j3d/DistanceLOD.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Drawable.java (renamed from src/javax/media/j3d/Drawable.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/DrawingSurfaceObject.java (renamed from src/javax/media/j3d/DrawingSurfaceObject.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/EnvironmentSet.java (renamed from src/javax/media/j3d/EnvironmentSet.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/EventCatcher.java (renamed from src/javax/media/j3d/EventCatcher.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ExponentialFog.java (renamed from src/javax/media/j3d/ExponentialFog.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ExponentialFogRetained.java (renamed from src/javax/media/j3d/ExponentialFogRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Fog.java (renamed from src/javax/media/j3d/Fog.java) | 18 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/FogRetained.java (renamed from src/javax/media/j3d/FogRetained.java) | 20 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Font3D.java (renamed from src/javax/media/j3d/Font3D.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/FontExtrusion.java (renamed from src/javax/media/j3d/FontExtrusion.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/FreeListManager.java (renamed from src/javax/media/j3d/FreeListManager.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GLSLShaderProgram.java | 282 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GLSLShaderProgramRetained.java (renamed from src/javax/media/j3d/GLSLShaderProgramRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeneralizedStrip.java (renamed from src/javax/media/j3d/GeneralizedStrip.java) | 3 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeneralizedStripFlags.java (renamed from src/javax/media/j3d/GeneralizedStripFlags.java) | 3 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeneralizedVertexList.java (renamed from src/javax/media/j3d/GeneralizedVertexList.java) | 11 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Geometry.java (renamed from src/javax/media/j3d/Geometry.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryArray.java (renamed from src/javax/media/j3d/GeometryArray.java) | 28 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryArrayRetained.java (renamed from src/javax/media/j3d/GeometryArrayRetained.java) | 64 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryAtom.java (renamed from src/javax/media/j3d/GeometryAtom.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryDecompressor.java (renamed from src/javax/media/j3d/GeometryDecompressor.java) | 9 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryDecompressorRetained.java (renamed from src/javax/media/j3d/GeometryDecompressorRetained.java) | 11 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryDecompressorShape3D.java (renamed from src/javax/media/j3d/GeometryDecompressorShape3D.java) | 9 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryLock.java (renamed from src/javax/media/j3d/GeometryLock.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryRetained.java (renamed from src/javax/media/j3d/GeometryRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryService.java (renamed from src/javax/media/j3d/GeometryService.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryStripArray.java (renamed from src/javax/media/j3d/GeometryStripArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryStripArrayRetained.java (renamed from src/javax/media/j3d/GeometryStripArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryStructure.java (renamed from src/javax/media/j3d/GeometryStructure.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GeometryUpdater.java (renamed from src/javax/media/j3d/GeometryUpdater.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GraphStructureChangeListener.java (renamed from src/javax/media/j3d/GraphStructureChangeListener.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GraphicsConfigInfo.java (renamed from src/javax/media/j3d/GraphicsConfigInfo.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GraphicsConfigTemplate3D.java (renamed from src/javax/media/j3d/GraphicsConfigTemplate3D.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GraphicsContext3D.java (renamed from src/javax/media/j3d/GraphicsContext3D.java) | 27 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Group.java (renamed from src/javax/media/j3d/Group.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/GroupRetained.java (renamed from src/javax/media/j3d/GroupRetained.java) | 23 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/HashKey.java (renamed from src/javax/media/j3d/HashKey.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/HiResCoord.java (renamed from src/javax/media/j3d/HiResCoord.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IllegalRenderingStateException.java (renamed from src/javax/media/j3d/IllegalRenderingStateException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IllegalSceneGraphException.java (renamed from src/javax/media/j3d/IllegalSceneGraphException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IllegalSharingException.java (renamed from src/javax/media/j3d/IllegalSharingException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ImageComponent.java (renamed from src/javax/media/j3d/ImageComponent.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ImageComponent2D.java (renamed from src/javax/media/j3d/ImageComponent2D.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ImageComponent2DRetained.java (renamed from src/javax/media/j3d/ImageComponent2DRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ImageComponent3D.java (renamed from src/javax/media/j3d/ImageComponent3D.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ImageComponent3DRetained.java (renamed from src/javax/media/j3d/ImageComponent3DRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ImageComponentRetained.java (renamed from src/javax/media/j3d/ImageComponentRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ImageComponentUpdateInfo.java (renamed from src/javax/media/j3d/ImageComponentUpdateInfo.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedGeometryArray.java (renamed from src/javax/media/j3d/IndexedGeometryArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedGeometryArrayRetained.java (renamed from src/javax/media/j3d/IndexedGeometryArrayRetained.java) | 13 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedGeometryStripArray.java (renamed from src/javax/media/j3d/IndexedGeometryStripArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedGeometryStripArrayRetained.java (renamed from src/javax/media/j3d/IndexedGeometryStripArrayRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedLineArray.java (renamed from src/javax/media/j3d/IndexedLineArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedLineArrayRetained.java (renamed from src/javax/media/j3d/IndexedLineArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedLineStripArray.java (renamed from src/javax/media/j3d/IndexedLineStripArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedLineStripArrayRetained.java (renamed from src/javax/media/j3d/IndexedLineStripArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedObject.java (renamed from src/javax/media/j3d/IndexedObject.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedPointArray.java (renamed from src/javax/media/j3d/IndexedPointArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedPointArrayRetained.java (renamed from src/javax/media/j3d/IndexedPointArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedQuadArray.java (renamed from src/javax/media/j3d/IndexedQuadArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedQuadArrayRetained.java (renamed from src/javax/media/j3d/IndexedQuadArrayRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedTriangleArray.java (renamed from src/javax/media/j3d/IndexedTriangleArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedTriangleArrayRetained.java (renamed from src/javax/media/j3d/IndexedTriangleArrayRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedTriangleFanArray.java (renamed from src/javax/media/j3d/IndexedTriangleFanArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedTriangleFanArrayRetained.java (renamed from src/javax/media/j3d/IndexedTriangleFanArrayRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedTriangleStripArray.java (renamed from src/javax/media/j3d/IndexedTriangleStripArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedTriangleStripArrayRetained.java (renamed from src/javax/media/j3d/IndexedTriangleStripArrayRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IndexedUnorderSet.java (renamed from src/javax/media/j3d/IndexedUnorderSet.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/InputDevice.java (renamed from src/javax/media/j3d/InputDevice.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/InputDeviceBlockingThread.java (renamed from src/javax/media/j3d/InputDeviceBlockingThread.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/InputDeviceScheduler.java (renamed from src/javax/media/j3d/InputDeviceScheduler.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/IntegerFreeList.java (renamed from src/javax/media/j3d/IntegerFreeList.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Interpolator.java (renamed from src/javax/media/j3d/Interpolator.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3DBuffer.java (renamed from src/javax/media/j3d/J3DBuffer.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3DGraphics2D.java (renamed from src/javax/media/j3d/J3DGraphics2D.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3DGraphics2DImpl.java (renamed from src/javax/media/j3d/J3DGraphics2DImpl.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dClock.java (renamed from src/javax/media/j3d/J3dClock.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dDebug.java (renamed from src/javax/media/j3d/J3dDebug.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dHash.java (renamed from src/javax/media/j3d/J3dHash.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dI18N.java (renamed from src/javax/media/j3d/J3dI18N.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dMessage.java (renamed from src/javax/media/j3d/J3dMessage.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dNotification.java (renamed from src/javax/media/j3d/J3dNotification.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dQueryProps.java (renamed from src/javax/media/j3d/J3dQueryProps.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dStructure.java (renamed from src/javax/media/j3d/J3dStructure.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dThread.java (renamed from src/javax/media/j3d/J3dThread.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/J3dThreadData.java (renamed from src/javax/media/j3d/J3dThreadData.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2Context.java | 597 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java | 375 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2MatrixUtil.java | 987 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java | 233 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java | 9854 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/JoglContext.java (renamed from src/javax/media/j3d/JoglContext.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/JoglDrawable.java (renamed from src/javax/media/j3d/JoglDrawable.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/JoglDrawingSurfaceObject.java (renamed from src/javax/media/j3d/JoglDrawingSurfaceObject.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/JoglGraphicsConfiguration.java (renamed from src/javax/media/j3d/JoglGraphicsConfiguration.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/JoglPipeline.java (renamed from src/javax/media/j3d/JoglPipeline.java) | 149 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/JoglShaderObject.java (renamed from src/javax/media/j3d/JoglShaderObject.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LOD.java (renamed from src/javax/media/j3d/LOD.java) | 12 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Leaf.java (renamed from src/javax/media/j3d/Leaf.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LeafRetained.java (renamed from src/javax/media/j3d/LeafRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Light.java (renamed from src/javax/media/j3d/Light.java) | 20 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LightBin.java (renamed from src/javax/media/j3d/LightBin.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LightRetained.java (renamed from src/javax/media/j3d/LightRetained.java) | 20 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LightSet.java (renamed from src/javax/media/j3d/LightSet.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LineArray.java (renamed from src/javax/media/j3d/LineArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LineArrayRetained.java (renamed from src/javax/media/j3d/LineArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LineAttributes.java (renamed from src/javax/media/j3d/LineAttributes.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LineAttributesRetained.java (renamed from src/javax/media/j3d/LineAttributesRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LineStripArray.java (renamed from src/javax/media/j3d/LineStripArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LineStripArrayRetained.java (renamed from src/javax/media/j3d/LineStripArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LinearFog.java (renamed from src/javax/media/j3d/LinearFog.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LinearFogRetained.java (renamed from src/javax/media/j3d/LinearFogRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Link.java (renamed from src/javax/media/j3d/Link.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/LinkRetained.java (renamed from src/javax/media/j3d/LinkRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Locale.java (renamed from src/javax/media/j3d/Locale.java) | 20 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MRSWLock.java (renamed from src/javax/media/j3d/MRSWLock.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MasterControl.java (renamed from src/javax/media/j3d/MasterControl.java) | 88 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MasterControlThread.java (renamed from src/javax/media/j3d/MasterControlThread.java) | 3 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Material.java (renamed from src/javax/media/j3d/Material.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MaterialRetained.java (renamed from src/javax/media/j3d/MaterialRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MediaContainer.java (renamed from src/javax/media/j3d/MediaContainer.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MediaContainerRetained.java (renamed from src/javax/media/j3d/MediaContainerRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MemoryFreeList.java (renamed from src/javax/media/j3d/MemoryFreeList.java) | 3 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ModelClip.java (renamed from src/javax/media/j3d/ModelClip.java) | 18 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ModelClipRetained.java (renamed from src/javax/media/j3d/ModelClipRetained.java) | 20 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Morph.java (renamed from src/javax/media/j3d/Morph.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MorphRetained.java (renamed from src/javax/media/j3d/MorphRetained.java) | 22 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/MultipleParentException.java (renamed from src/javax/media/j3d/MultipleParentException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NioImageBuffer.java (renamed from src/javax/media/j3d/NioImageBuffer.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NnuId.java (renamed from src/javax/media/j3d/NnuId.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NnuIdManager.java (renamed from src/javax/media/j3d/NnuIdManager.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Node.java (renamed from src/javax/media/j3d/Node.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NodeComponent.java (renamed from src/javax/media/j3d/NodeComponent.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NodeComponentRetained.java (renamed from src/javax/media/j3d/NodeComponentRetained.java) | 33 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NodeComponentUpdate.java (renamed from src/javax/media/j3d/NodeComponentUpdate.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NodeData.java (renamed from src/javax/media/j3d/NodeData.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NodeReferenceTable.java (renamed from src/javax/media/j3d/NodeReferenceTable.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NodeRetained.java (renamed from src/javax/media/j3d/NodeRetained.java) | 9 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NoopDrawingSurfaceObject.java (renamed from src/javax/media/j3d/NoopDrawingSurfaceObject.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NoopPipeline.java (renamed from src/javax/media/j3d/NoopPipeline.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/NotificationThread.java (renamed from src/javax/media/j3d/NotificationThread.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ObjectUpdate.java (renamed from src/javax/media/j3d/ObjectUpdate.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrderedBin.java (renamed from src/javax/media/j3d/OrderedBin.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrderedChildInfo.java (renamed from src/javax/media/j3d/OrderedChildInfo.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrderedCollection.java (renamed from src/javax/media/j3d/OrderedCollection.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrderedGroup.java (renamed from src/javax/media/j3d/OrderedGroup.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrderedGroupRetained.java (renamed from src/javax/media/j3d/OrderedGroupRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrderedPath.java (renamed from src/javax/media/j3d/OrderedPath.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrderedPathElement.java (renamed from src/javax/media/j3d/OrderedPathElement.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrientedShape3D.java (renamed from src/javax/media/j3d/OrientedShape3D.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrientedShape3DRenderMethod.java (renamed from src/javax/media/j3d/OrientedShape3DRenderMethod.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/OrientedShape3DRetained.java (renamed from src/javax/media/j3d/OrientedShape3DRetained.java) | 16 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PathInterpolator.java (renamed from src/javax/media/j3d/PathInterpolator.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PhysicalBody.java (renamed from src/javax/media/j3d/PhysicalBody.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PhysicalEnvironment.java (renamed from src/javax/media/j3d/PhysicalEnvironment.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickBounds.java (renamed from src/javax/media/j3d/PickBounds.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickCone.java (renamed from src/javax/media/j3d/PickCone.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickConeRay.java (renamed from src/javax/media/j3d/PickConeRay.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickConeSegment.java (renamed from src/javax/media/j3d/PickConeSegment.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickCylinder.java (renamed from src/javax/media/j3d/PickCylinder.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickCylinderRay.java (renamed from src/javax/media/j3d/PickCylinderRay.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickCylinderSegment.java (renamed from src/javax/media/j3d/PickCylinderSegment.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickInfo.java (renamed from src/javax/media/j3d/PickInfo.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickPoint.java (renamed from src/javax/media/j3d/PickPoint.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickRay.java (renamed from src/javax/media/j3d/PickRay.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickSegment.java (renamed from src/javax/media/j3d/PickSegment.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PickShape.java (renamed from src/javax/media/j3d/PickShape.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Pipeline.java (renamed from src/javax/media/j3d/Pipeline.java) | 21 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointArray.java (renamed from src/javax/media/j3d/PointArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointArrayRetained.java (renamed from src/javax/media/j3d/PointArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointAttributes.java (renamed from src/javax/media/j3d/PointAttributes.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointAttributesRetained.java (renamed from src/javax/media/j3d/PointAttributesRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointLight.java (renamed from src/javax/media/j3d/PointLight.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointLightRetained.java (renamed from src/javax/media/j3d/PointLightRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointSound.java (renamed from src/javax/media/j3d/PointSound.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PointSoundRetained.java (renamed from src/javax/media/j3d/PointSoundRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PolygonAttributes.java (renamed from src/javax/media/j3d/PolygonAttributes.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PolygonAttributesRetained.java (renamed from src/javax/media/j3d/PolygonAttributesRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PositionInterpolator.java (renamed from src/javax/media/j3d/PositionInterpolator.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/PositionPathInterpolator.java (renamed from src/javax/media/j3d/PositionPathInterpolator.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/QuadArray.java (renamed from src/javax/media/j3d/QuadArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/QuadArrayRetained.java (renamed from src/javax/media/j3d/QuadArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Raster.java (renamed from src/javax/media/j3d/Raster.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RasterRetained.java (renamed from src/javax/media/j3d/RasterRetained.java) | 12 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderAtom.java (renamed from src/javax/media/j3d/RenderAtom.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderAtomListInfo.java (renamed from src/javax/media/j3d/RenderAtomListInfo.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderBin.java (renamed from src/javax/media/j3d/RenderBin.java) | 31 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderMethod.java (renamed from src/javax/media/j3d/RenderMethod.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderMolecule.java (renamed from src/javax/media/j3d/RenderMolecule.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Renderer.java (renamed from src/javax/media/j3d/Renderer.java) | 87 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RendererStructure.java (renamed from src/javax/media/j3d/RendererStructure.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderingAttributes.java (renamed from src/javax/media/j3d/RenderingAttributes.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderingAttributesRetained.java (renamed from src/javax/media/j3d/RenderingAttributesRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderingAttributesStructure.java (renamed from src/javax/media/j3d/RenderingAttributesStructure.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderingEnvironmentStructure.java (renamed from src/javax/media/j3d/RenderingEnvironmentStructure.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderingError.java (renamed from src/javax/media/j3d/RenderingError.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RenderingErrorListener.java (renamed from src/javax/media/j3d/RenderingErrorListener.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RestrictedAccessException.java (renamed from src/javax/media/j3d/RestrictedAccessException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RotPosPathInterpolator.java (renamed from src/javax/media/j3d/RotPosPathInterpolator.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RotPosScalePathInterpolator.java (renamed from src/javax/media/j3d/RotPosScalePathInterpolator.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RotationInterpolator.java (renamed from src/javax/media/j3d/RotationInterpolator.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/RotationPathInterpolator.java (renamed from src/javax/media/j3d/RotationPathInterpolator.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ScaleInterpolator.java (renamed from src/javax/media/j3d/ScaleInterpolator.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SceneGraphCycleException.java (renamed from src/javax/media/j3d/SceneGraphCycleException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SceneGraphObject.java (renamed from src/javax/media/j3d/SceneGraphObject.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SceneGraphObjectRetained.java (renamed from src/javax/media/j3d/SceneGraphObjectRetained.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SceneGraphPath.java (renamed from src/javax/media/j3d/SceneGraphPath.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Screen3D.java (renamed from src/javax/media/j3d/Screen3D.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ScreenViewCache.java (renamed from src/javax/media/j3d/ScreenViewCache.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Sensor.java (renamed from src/javax/media/j3d/Sensor.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SensorRead.java (renamed from src/javax/media/j3d/SensorRead.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SetLiveState.java (renamed from src/javax/media/j3d/SetLiveState.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Shader.java (renamed from src/javax/media/j3d/Shader.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAppearance.java (renamed from src/javax/media/j3d/ShaderAppearance.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAppearanceRetained.java (renamed from src/javax/media/j3d/ShaderAppearanceRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttrLoc.java (renamed from src/javax/media/j3d/ShaderAttrLoc.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttribute.java (renamed from src/javax/media/j3d/ShaderAttribute.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeArray.java (renamed from src/javax/media/j3d/ShaderAttributeArray.java) | 34 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeArrayRetained.java (renamed from src/javax/media/j3d/ShaderAttributeArrayRetained.java) | 32 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeBinding.java (renamed from src/javax/media/j3d/ShaderAttributeBinding.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeBindingRetained.java (renamed from src/javax/media/j3d/ShaderAttributeBindingRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeObject.java (renamed from src/javax/media/j3d/ShaderAttributeObject.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeObjectRetained.java (renamed from src/javax/media/j3d/ShaderAttributeObjectRetained.java) | 18 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeRetained.java (renamed from src/javax/media/j3d/ShaderAttributeRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeSet.java (renamed from src/javax/media/j3d/ShaderAttributeSet.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeSetRetained.java (renamed from src/javax/media/j3d/ShaderAttributeSetRetained.java) | 43 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeValue.java (renamed from src/javax/media/j3d/ShaderAttributeValue.java) | 22 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderAttributeValueRetained.java (renamed from src/javax/media/j3d/ShaderAttributeValueRetained.java) | 32 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderBin.java (renamed from src/javax/media/j3d/ShaderBin.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderConstants.java (renamed from src/javax/media/j3d/ShaderConstants.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderError.java (renamed from src/javax/media/j3d/ShaderError.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderErrorListener.java (renamed from src/javax/media/j3d/ShaderErrorListener.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderId.java (renamed from src/javax/media/j3d/ShaderId.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderProgram.java (renamed from src/javax/media/j3d/ShaderProgram.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderProgramId.java (renamed from src/javax/media/j3d/ShaderProgramId.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderProgramRetained.java | 1316 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ShaderRetained.java (renamed from src/javax/media/j3d/ShaderRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Shape3D.java (renamed from src/javax/media/j3d/Shape3D.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Shape3DCompileRetained.java (renamed from src/javax/media/j3d/Shape3DCompileRetained.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Shape3DRetained.java (renamed from src/javax/media/j3d/Shape3DRetained.java) | 29 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SharedGroup.java (renamed from src/javax/media/j3d/SharedGroup.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SharedGroupRetained.java (renamed from src/javax/media/j3d/SharedGroupRetained.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Sound.java (renamed from src/javax/media/j3d/Sound.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SoundException.java (renamed from src/javax/media/j3d/SoundException.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SoundRetained.java (renamed from src/javax/media/j3d/SoundRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SoundScheduler.java (renamed from src/javax/media/j3d/SoundScheduler.java) | 34 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SoundSchedulerAtom.java (renamed from src/javax/media/j3d/SoundSchedulerAtom.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SoundStructure.java (renamed from src/javax/media/j3d/SoundStructure.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Soundscape.java (renamed from src/javax/media/j3d/Soundscape.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SoundscapeRetained.java (renamed from src/javax/media/j3d/SoundscapeRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SourceCodeShader.java (renamed from src/javax/media/j3d/SourceCodeShader.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SourceCodeShaderRetained.java (renamed from src/javax/media/j3d/SourceCodeShaderRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SparseArray.java | 584 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SpotLight.java (renamed from src/javax/media/j3d/SpotLight.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SpotLightRetained.java (renamed from src/javax/media/j3d/SpotLightRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/StructureUpdateThread.java (renamed from src/javax/media/j3d/StructureUpdateThread.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Switch.java (renamed from src/javax/media/j3d/Switch.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SwitchRetained.java (renamed from src/javax/media/j3d/SwitchRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SwitchState.java (renamed from src/javax/media/j3d/SwitchState.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/SwitchValueInterpolator.java (renamed from src/javax/media/j3d/SwitchValueInterpolator.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Targets.java (renamed from src/javax/media/j3d/Targets.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TargetsInterface.java (renamed from src/javax/media/j3d/TargetsInterface.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TexCoordGeneration.java (renamed from src/javax/media/j3d/TexCoordGeneration.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TexCoordGenerationRetained.java (renamed from src/javax/media/j3d/TexCoordGenerationRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Text3D.java (renamed from src/javax/media/j3d/Text3D.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Text3DRenderMethod.java (renamed from src/javax/media/j3d/Text3DRenderMethod.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Text3DRetained.java (renamed from src/javax/media/j3d/Text3DRetained.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Texture.java (renamed from src/javax/media/j3d/Texture.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Texture2D.java (renamed from src/javax/media/j3d/Texture2D.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Texture2DRetained.java (renamed from src/javax/media/j3d/Texture2DRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Texture3D.java (renamed from src/javax/media/j3d/Texture3D.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Texture3DRetained.java (renamed from src/javax/media/j3d/Texture3DRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureAttributes.java (renamed from src/javax/media/j3d/TextureAttributes.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureAttributesRetained.java (renamed from src/javax/media/j3d/TextureAttributesRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureBin.java (renamed from src/javax/media/j3d/TextureBin.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureCubeMap.java (renamed from src/javax/media/j3d/TextureCubeMap.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureCubeMapRetained.java (renamed from src/javax/media/j3d/TextureCubeMapRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureRetained.java (renamed from src/javax/media/j3d/TextureRetained.java) | 10 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureUnitState.java (renamed from src/javax/media/j3d/TextureUnitState.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TextureUnitStateRetained.java (renamed from src/javax/media/j3d/TextureUnitStateRetained.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TimerThread.java (renamed from src/javax/media/j3d/TimerThread.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Transform3D.java (renamed from src/javax/media/j3d/Transform3D.java) | 38 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransformGroup.java (renamed from src/javax/media/j3d/TransformGroup.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransformGroupData.java (renamed from src/javax/media/j3d/TransformGroupData.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransformGroupRetained.java (renamed from src/javax/media/j3d/TransformGroupRetained.java) | 30 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransformInterpolator.java (renamed from src/javax/media/j3d/TransformInterpolator.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransformStructure.java (renamed from src/javax/media/j3d/TransformStructure.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransparencyAttributes.java (renamed from src/javax/media/j3d/TransparencyAttributes.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransparencyAttributesRetained.java (renamed from src/javax/media/j3d/TransparencyAttributesRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransparencyInterpolator.java (renamed from src/javax/media/j3d/TransparencyInterpolator.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransparencySortGeom.java (renamed from src/javax/media/j3d/TransparencySortGeom.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransparencySortMap.java (renamed from src/javax/media/j3d/TransparencySortMap.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TransparentRenderingInfo.java (renamed from src/javax/media/j3d/TransparentRenderingInfo.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TriangleArray.java (renamed from src/javax/media/j3d/TriangleArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TriangleArrayRetained.java (renamed from src/javax/media/j3d/TriangleArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TriangleFanArray.java (renamed from src/javax/media/j3d/TriangleFanArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TriangleFanArrayRetained.java (renamed from src/javax/media/j3d/TriangleFanArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TriangleStripArray.java (renamed from src/javax/media/j3d/TriangleStripArray.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/TriangleStripArrayRetained.java (renamed from src/javax/media/j3d/TriangleStripArrayRetained.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/UnorderList.java (renamed from src/javax/media/j3d/UnorderList.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/UpdateTargets.java (renamed from src/javax/media/j3d/UpdateTargets.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Utils.java (renamed from src/javax/media/j3d/Utils.java) | 6 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/VertexArrayRenderMethod.java (renamed from src/javax/media/j3d/VertexArrayRenderMethod.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/View.java (renamed from src/javax/media/j3d/View.java) | 15 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ViewCache.java (renamed from src/javax/media/j3d/ViewCache.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ViewPlatform.java (renamed from src/javax/media/j3d/ViewPlatform.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ViewPlatformRetained.java (renamed from src/javax/media/j3d/ViewPlatformRetained.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ViewSpecificGroup.java (renamed from src/javax/media/j3d/ViewSpecificGroup.java) | 14 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/ViewSpecificGroupRetained.java (renamed from src/javax/media/j3d/ViewSpecificGroupRetained.java) | 8 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/VirtualUniverse.java (renamed from src/javax/media/j3d/VirtualUniverse.java) | 77 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupAnd.java (renamed from src/javax/media/j3d/WakeupAnd.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupAndOfOrs.java (renamed from src/javax/media/j3d/WakeupAndOfOrs.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupCondition.java (renamed from src/javax/media/j3d/WakeupCondition.java) | 50 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupCriteriaEnumerator.java (renamed from src/javax/media/j3d/WakeupCriteriaEnumerator.java) | 40 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupCriterion.java (renamed from src/javax/media/j3d/WakeupCriterion.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupIndexedList.java (renamed from src/javax/media/j3d/WakeupIndexedList.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnAWTEvent.java (renamed from src/javax/media/j3d/WakeupOnAWTEvent.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnActivation.java (renamed from src/javax/media/j3d/WakeupOnActivation.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnBehaviorPost.java (renamed from src/javax/media/j3d/WakeupOnBehaviorPost.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnCollisionEntry.java (renamed from src/javax/media/j3d/WakeupOnCollisionEntry.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnCollisionExit.java (renamed from src/javax/media/j3d/WakeupOnCollisionExit.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnCollisionMovement.java (renamed from src/javax/media/j3d/WakeupOnCollisionMovement.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnDeactivation.java (renamed from src/javax/media/j3d/WakeupOnDeactivation.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnElapsedFrames.java (renamed from src/javax/media/j3d/WakeupOnElapsedFrames.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnElapsedTime.java (renamed from src/javax/media/j3d/WakeupOnElapsedTime.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnElapsedTimeHeap.java (renamed from src/javax/media/j3d/WakeupOnElapsedTimeHeap.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnSensorEntry.java (renamed from src/javax/media/j3d/WakeupOnSensorEntry.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnSensorExit.java (renamed from src/javax/media/j3d/WakeupOnSensorExit.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnTransformChange.java (renamed from src/javax/media/j3d/WakeupOnTransformChange.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnViewPlatformEntry.java (renamed from src/javax/media/j3d/WakeupOnViewPlatformEntry.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOnViewPlatformExit.java (renamed from src/javax/media/j3d/WakeupOnViewPlatformExit.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOr.java (renamed from src/javax/media/j3d/WakeupOr.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/WakeupOrOfAnds.java (renamed from src/javax/media/j3d/WakeupOrOfAnds.java) | 2 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors.html (renamed from src/javax/media/j3d/doc-files/Behaviors.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors1.gif (renamed from src/javax/media/j3d/doc-files/Behaviors1.gif) | bin | 9067 -> 9067 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors2.gif (renamed from src/javax/media/j3d/doc-files/Behaviors2.gif) | bin | 2223 -> 2223 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors3.gif (renamed from src/javax/media/j3d/doc-files/Behaviors3.gif) | bin | 2189 -> 2189 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors4.gif (renamed from src/javax/media/j3d/doc-files/Behaviors4.gif) | bin | 2452 -> 2452 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors5.gif (renamed from src/javax/media/j3d/doc-files/Behaviors5.gif) | bin | 4743 -> 4743 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors6.gif (renamed from src/javax/media/j3d/doc-files/Behaviors6.gif) | bin | 4535 -> 4535 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors7.gif (renamed from src/javax/media/j3d/doc-files/Behaviors7.gif) | bin | 4463 -> 4463 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors8.gif (renamed from src/javax/media/j3d/doc-files/Behaviors8.gif) | bin | 22297 -> 22297 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Concepts.html (renamed from src/javax/media/j3d/doc-files/Concepts.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Concepts1.gif (renamed from src/javax/media/j3d/doc-files/Concepts1.gif) | bin | 19058 -> 19058 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Concepts2.gif (renamed from src/javax/media/j3d/doc-files/Concepts2.gif) | bin | 14546 -> 14546 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/DAG.gif (renamed from src/javax/media/j3d/doc-files/DAG.gif) | bin | 19099 -> 19099 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/HelloUniverse.html (renamed from src/javax/media/j3d/doc-files/HelloUniverse.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Immediate.html (renamed from src/javax/media/j3d/doc-files/Immediate.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Immediate1.gif (renamed from src/javax/media/j3d/doc-files/Immediate1.gif) | bin | 17085 -> 17085 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/Rendering.html (renamed from src/javax/media/j3d/doc-files/Rendering.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphOverview.html (renamed from src/javax/media/j3d/doc-files/SceneGraphOverview.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing.html (renamed from src/javax/media/j3d/doc-files/SceneGraphSharing.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing1.gif (renamed from src/javax/media/j3d/doc-files/SceneGraphSharing1.gif) | bin | 22601 -> 22601 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing2.gif (renamed from src/javax/media/j3d/doc-files/SceneGraphSharing2.gif) | bin | 17159 -> 17159 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing3.gif (renamed from src/javax/media/j3d/doc-files/SceneGraphSharing3.gif) | bin | 13186 -> 13186 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing4.gif (renamed from src/javax/media/j3d/doc-files/SceneGraphSharing4.gif) | bin | 12419 -> 12419 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing5.gif (renamed from src/javax/media/j3d/doc-files/SceneGraphSharing5.gif) | bin | 10695 -> 10695 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewBranch.gif (renamed from src/javax/media/j3d/doc-files/ViewBranch.gif) | bin | 19210 -> 19210 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel.html (renamed from src/javax/media/j3d/doc-files/ViewModel.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel1.gif (renamed from src/javax/media/j3d/doc-files/ViewModel1.gif) | bin | 19585 -> 19585 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel10.gif (renamed from src/javax/media/j3d/doc-files/ViewModel10.gif) | bin | 29787 -> 29787 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel11.gif (renamed from src/javax/media/j3d/doc-files/ViewModel11.gif) | bin | 15569 -> 15569 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel12.gif (renamed from src/javax/media/j3d/doc-files/ViewModel12.gif) | bin | 15520 -> 15520 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel13.gif (renamed from src/javax/media/j3d/doc-files/ViewModel13.gif) | bin | 14982 -> 14982 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel14.gif (renamed from src/javax/media/j3d/doc-files/ViewModel14.gif) | bin | 11968 -> 11968 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel2.gif (renamed from src/javax/media/j3d/doc-files/ViewModel2.gif) | bin | 17085 -> 17085 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel3.gif (renamed from src/javax/media/j3d/doc-files/ViewModel3.gif) | bin | 22430 -> 22430 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel4.gif (renamed from src/javax/media/j3d/doc-files/ViewModel4.gif) | bin | 16502 -> 16502 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel5.gif (renamed from src/javax/media/j3d/doc-files/ViewModel5.gif) | bin | 9524 -> 9524 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel6.gif (renamed from src/javax/media/j3d/doc-files/ViewModel6.gif) | bin | 10590 -> 10590 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel7.gif (renamed from src/javax/media/j3d/doc-files/ViewModel7.gif) | bin | 10958 -> 10958 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel8.gif (renamed from src/javax/media/j3d/doc-files/ViewModel8.gif) | bin | 16583 -> 16583 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel9.gif (renamed from src/javax/media/j3d/doc-files/ViewModel9.gif) | bin | 14194 -> 14194 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/VirtualUniverse.gif (renamed from src/javax/media/j3d/doc-files/VirtualUniverse.gif) | bin | 19123 -> 19123 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/VirtualUniverse.html (renamed from src/javax/media/j3d/doc-files/VirtualUniverse.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/intro.gif (renamed from src/javax/media/j3d/doc-files/intro.gif) | bin | 19452 -> 19452 bytes | |||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/doc-files/intro.html (renamed from src/javax/media/j3d/doc-files/intro.html) | 0 | ||||
-rw-r--r-- | src/main/javadoc/org/jogamp/java3d/package.html (renamed from src/javax/media/j3d/package.html) | 2 | ||||
-rw-r--r-- | src/main/resources/org/jogamp/java3d/ExceptionStrings.properties (renamed from src/javax/media/j3d/ExceptionStrings.properties) | 0 |
458 files changed, 16038 insertions, 2650 deletions
diff --git a/src/javax/media/j3d/GLSLShaderProgram.java b/src/javax/media/j3d/GLSLShaderProgram.java deleted file mode 100644 index 6e5ef02..0000000 --- a/src/javax/media/j3d/GLSLShaderProgram.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -package javax.media.j3d; - -/** - * The GLSLShaderProgram object is a concrete implementation of a - * ShaderProgram node component for the OpenGL GLSL shading language. - * - * @see SourceCodeShader - * - * @since Java 3D 1.4 - */ - -public class GLSLShaderProgram extends ShaderProgram { - - /** - * Constructs a GLSL shader program node component. - * - * <br> - * TODO: ADD MORE DOCUMENTATION HERE. - */ - public GLSLShaderProgram() { - } - - // Implement abstract setVertexAttrNames method (inherit javadoc from parent class) - @Override - public void setVertexAttrNames(String[] vertexAttrNames) { - checkForLiveOrCompiled(); - - if (vertexAttrNames != null) { - for (int i = 0; i < vertexAttrNames.length; i++) { - if (vertexAttrNames[i] == null) { - throw new NullPointerException(); - } - } - } - - ((GLSLShaderProgramRetained)this.retained).setVertexAttrNames(vertexAttrNames); - } - - // Implement abstract getVertexAttrNames method (inherit javadoc from parent class) - @Override - public String[] getVertexAttrNames() { - - if (isLiveOrCompiled()) { - if(!this.getCapability(ALLOW_NAMES_READ)) { - throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram0")); - } - } - - return ((GLSLShaderProgramRetained)this.retained).getVertexAttrNames(); - - } - - // Implement abstract setShaderAttrNames method (inherit javadoc from parent class) - @Override - public void setShaderAttrNames(String[] shaderAttrNames) { - checkForLiveOrCompiled(); - - if (shaderAttrNames != null) { - for (int i = 0; i < shaderAttrNames.length; i++) { - if (shaderAttrNames[i] == null) { - throw new NullPointerException(); - } - } - } - - ((GLSLShaderProgramRetained)this.retained).setShaderAttrNames(shaderAttrNames); - } - - // Implement abstract getShaderAttrNames method (inherit javadoc from parent class) - @Override - public String[] getShaderAttrNames() { - - if (isLiveOrCompiled()) { - if(!this.getCapability(ALLOW_NAMES_READ)) { - throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram0")); - } - } - - return ((GLSLShaderProgramRetained)this.retained).getShaderAttrNames(); - - } - - /** - * Copies the specified array of shaders into this shader - * program. This method makes a shallow copy of the array. The - * array of shaders may be null or empty (0 length), but the - * elements of the array must be non-null. The shading language of - * each shader in the array must be - * <code>SHADING_LANGUAGE_GLSL</code>. Each shader in the array must - * be a SourceCodeShader. - * - * @param shaders array of Shader objects to be copied into this - * ShaderProgram - * - * @exception CapabilityNotSetException if appropriate capability is - * not set and this object is part of live or compiled scene graph - * - * @exception IllegalArgumentException if the shading language of - * any shader in the shaders array is <em>not</em> - * <code>SHADING_LANGUAGE_GLSL</code>. - * - * @exception ClassCastException if any shader in the shaders - * array is <em>not</em> a SourceCodeShader. - * - * @exception NullPointerException if any element in the - * shaders array is null. - */ - @Override - public void setShaders(Shader[] shaders) { - checkForLiveOrCompiled(); - - if(shaders != null) { - // Check shaders for valid shading language and class type - for (int i = 0; i < shaders.length; i++) { - if (shaders[i].getShadingLanguage() != Shader.SHADING_LANGUAGE_GLSL) { - throw new IllegalArgumentException(J3dI18N.getString("GLSLShaderProgram2")); - } - - // Try to cast shader to SourceCodeShader; it will throw - // ClassCastException if it isn't. - SourceCodeShader shad = (SourceCodeShader)shaders[i]; - } - - } - - ((GLSLShaderProgramRetained)this.retained).setShaders(shaders); - } - - // Implement abstract getShaders method (inherit javadoc from parent class) - @Override - public Shader[] getShaders() { - - if (isLiveOrCompiled()) { - if(!this.getCapability(ALLOW_SHADERS_READ)) { - throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram1")); - } - } - - return ((GLSLShaderProgramRetained)this.retained).getShaders(); - } - - /** - * Creates a retained mode GLSLShaderProgramRetained object that this - * GLSLShaderProgram component object will point to. - */ - @Override - void createRetained() { - this.retained = new GLSLShaderProgramRetained(); - this.retained.setSource(this); - } - - -} diff --git a/src/javax/media/j3d/ShaderProgramRetained.java b/src/javax/media/j3d/ShaderProgramRetained.java deleted file mode 100644 index ec63b3a..0000000 --- a/src/javax/media/j3d/ShaderProgramRetained.java +++ /dev/null @@ -1,1233 +0,0 @@ -/* - * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -package javax.media.j3d; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -/** - * The ShaderProgramRetained object is a component object of an AppearanceRetained - * object that defines the shader properties used when programmable shader is - * enabled. ShaderProgramRetained object is an abstract class. All shader program - * objects must be created as either a GLSLShaderProgramRetained object or a - * CgShaderProgramRetained object. - */ -abstract class ShaderProgramRetained extends NodeComponentRetained { - - // Each element in the array corresponds to a unique renderer if shared - // context or a unique canvas otherwise. - protected ShaderProgramData shaderProgramData[]; - - // Flag indicating whether an UNSUPPORTED_LANGUAGE_ERROR has - // already been reported for this shader program object. It is - // set in verifyShaderProgram and cleared in setLive or clearLive. - // TODO KCR: Add code to clear this in setLive or clearLive - private boolean unsupportedErrorReported = false; - - // Flag indicating whether a LINK_ERROR has occurred for this shader program - // object. It is set in updateNative to indicate that the linkShaderProgram - // operation failed. It is cleared in setLive or clearLive. - // TODO KCR: Add code to clear this in setLive or clearLive - private boolean linkErrorOccurred = false; - - // an array of shaders used by this shader program - protected ShaderRetained[] shaders; - - // an array of vertex attribute names - protected String[] vertexAttrNames; - - // an array of (uniform) shader attribute names - protected String[] shaderAttrNames; - -// Set of ShaderAttribute objects for which we have already reported an error -private HashSet<ShaderAttribute> shaderAttrErrorSet = null; - - // need to synchronize access from multiple rendering threads - Object resourceLock = new Object(); - - // Package-scope default constructor - ShaderProgramRetained() { - } - - /** - * Sets the vertex attribute names array for this ShaderProgram - * object. Each element in the array specifies the shader - * attribute name that is bound to the corresponding numbered - * vertex attribute within a GeometryArray object that uses this - * shader program. Array element 0 specifies the name of - * GeometryArray vertex attribute 0, array element 1 specifies the - * name of GeometryArray vertex attribute 1, and so forth. - * The array of names may be null or empty (0 length), but the - * elements of the array must be non-null. - * - * @param vertexAttrNames array of vertex attribute names for this - * shader program. A copy of this array is made. - */ - void setVertexAttrNames(String[] vertexAttrNames) { - if (vertexAttrNames == null) { - this.vertexAttrNames = null; - } - else { - this.vertexAttrNames = vertexAttrNames.clone(); - } - } - - - /** - * Retrieves the vertex attribute names array from this - * ShaderProgram object. - * - * @return a copy of this ShaderProgram's array of vertex attribute names. - */ - String[] getVertexAttrNames() { - - if (vertexAttrNames == null) { - return null; - } - - return vertexAttrNames.clone(); - - } - - - /** - * Sets the shader attribute names array for this ShaderProgram - * object. Each element in the array specifies a shader - * attribute name that may be set via a ShaderAttribute object. - * Only those attributes whose names that appear in the shader - * attribute names array can be set for a given shader program. - * The array of names may be null or empty (0 length), but the - * elements of the array must be non-null. - * - * @param shaderAttrNames array of shader attribute names for this - * shader program. A copy of this array is made. - */ - void setShaderAttrNames(String[] shaderAttrNames) { - if (shaderAttrNames == null) { - this.shaderAttrNames = null; - } - else { - this.shaderAttrNames = shaderAttrNames.clone(); - } - } - - - /** - * Retrieves the shader attribute names array from this - * ShaderProgram object. - * - * @return a copy of this ShaderProgram's array of shader attribute names. - */ - - String[] getShaderAttrNames() { - - if (shaderAttrNames == null) { - return null; - } - - return shaderAttrNames.clone(); - - } - - - - /** - * Copies the specified array of shaders into this shader - * program. This method makes a shallow copy of the array. The - * array of shaders may be null or empty (0 length), but the - * elements of the array must be non-null. The shading - * language of each shader in the array must match the - * subclass. Subclasses may impose additional restrictions. - * - * @param shaders array of Shader objects to be copied into this - * ShaderProgram - * - * @exception CapabilityNotSetException if appropriate capability is - * not set and this object is part of live or compiled scene graph - * - * @exception IllegalArgumentException if the shading language of - * any shader in the shaders array doesn't match the type of the - * subclass. - */ - void setShaders(Shader[] shaders) { - - if (shaders == null) { - this.shaders = null; - return; - } - - this.shaders = new ShaderRetained[shaders.length]; - - // Copy vertex and fragment shader - for (int i = 0; i < shaders.length; i++) { - this.shaders[i] = (ShaderRetained)shaders[i].retained; - } - - } - - /** - * Retrieves the array of shaders from this shader program. A - * shallow copy of the array is returned. The return value may - * be null. - * - * @return a copy of this ShaderProgram's array of Shader objects - * - */ - Shader[] getShaders() { - - if (shaders == null) { - return null; - } else { - Shader shads[] = - new Shader[shaders.length]; - for (int i = 0; i < shaders.length; i++) { - if (shaders[i] != null) { - shads[i] = (Shader) shaders[i].source; - } else { - shads[i] = null; - } - } - return shads; - } - } - - /** - * Method to create the native shader. - */ - abstract ShaderError createShader(Context ctx, ShaderRetained shader, ShaderId[] shaderIdArr); - - /** - * Method to destroy the native shader. - */ - abstract ShaderError destroyShader(Context ctx, ShaderId shaderId); - - /** - * Method to compile the native shader. - */ - abstract ShaderError compileShader(Context ctx, ShaderId shaderId, String source); - - /** - * Method to create the native shader program. - */ - abstract ShaderError createShaderProgram(Context ctx, ShaderProgramId[] shaderProgramIdArr); - - /** - * Method to destroy the native shader program. - */ - abstract ShaderError destroyShaderProgram(Context ctx, ShaderProgramId shaderProgramId); - - /** - * Method to link the native shader program. - */ - abstract ShaderError linkShaderProgram(Context ctx, ShaderProgramId shaderProgramId, ShaderId[] shaderIds); - - /** - * Method to bind a vertex attribute name to the specified index. - */ - abstract ShaderError bindVertexAttrName(Context ctx, ShaderProgramId shaderProgramId, String attrName, int attrIndex); - - /** - * Method to lookup a list of (uniform) shader attribute names and return - * information about the attributes. - */ - abstract void lookupShaderAttrNames(Context ctx, ShaderProgramId shaderProgramId, String[] attrNames, AttrNameInfo[] attrNameInfoArr); - - /* - * Method to lookup a list of vertex attribute names. - */ - abstract void lookupVertexAttrNames(Context ctx, ShaderProgramId shaderProgramId, String[] attrNames, boolean[] errArr); - - /** - * Method to use the native shader program. - */ - abstract ShaderError enableShaderProgram(Context ctx, ShaderProgramId shaderProgramId); - - /** - * Method to disable the native shader program. - */ - abstract ShaderError disableShaderProgram(Context ctx); - - // ShaderAttributeValue methods - - abstract ShaderError setUniform1i(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int value); - - abstract ShaderError setUniform1f(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - float value); - - abstract ShaderError setUniform2i(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int[] value); - - abstract ShaderError setUniform2f(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - float[] value); - - abstract ShaderError setUniform3i(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int[] value); - - abstract ShaderError setUniform3f(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - float[] value); - - abstract ShaderError setUniform4i(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int[] value); - - abstract ShaderError setUniform4f(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - float[] value); - - abstract ShaderError setUniformMatrix3f(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - float[] value); - - abstract ShaderError setUniformMatrix4f(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - float[] value); - - - // ShaderAttributeArray methods - - abstract ShaderError setUniform1iArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - int[] value); - - abstract ShaderError setUniform1fArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - float[] value); - - abstract ShaderError setUniform2iArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - int[] value); - - abstract ShaderError setUniform2fArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - float[] value); - - abstract ShaderError setUniform3iArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - int[] value); - - abstract ShaderError setUniform3fArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - float[] value); - - abstract ShaderError setUniform4iArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - int[] value); - - abstract ShaderError setUniform4fArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - float[] value); - - abstract ShaderError setUniformMatrix3fArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - float[] value); - - abstract ShaderError setUniformMatrix4fArray(Context ctx, - ShaderProgramId shaderProgramId, - ShaderAttrLoc uniformLocation, - int numElements, - float[] value); - - - /** - * Method to return a flag indicating whether this - * ShaderProgram is supported on the specified Canvas. - */ - abstract boolean isSupported(Canvas3D cv); - - - @Override - void setLive(boolean backgroundGroup, int refCount) { - - // System.err.println("ShaderProgramRetained.setLive()"); - - if (shaders != null) { - for (int i = 0; i < shaders.length; i++){ - shaders[i].setLive(backgroundGroup, refCount); - } - } - - super.doSetLive(backgroundGroup, refCount); - super.markAsLive(); - - } - - @Override - void clearLive(int refCount) { - - // System.err.println("ShaderProgramRetained.clearLive()"); - - super.clearLive(refCount); - - if (shaders != null) { - for (int i = 0; i < shaders.length; i++) { - shaders[i].clearLive(refCount); - } - } - } - - /** - * Method to enable the native shader program. - */ - private ShaderError enableShaderProgram(Canvas3D cv, int cvRdrIndex) { - assert(cvRdrIndex >= 0); - synchronized(resourceLock) { - return enableShaderProgram(cv.ctx, - shaderProgramData[cvRdrIndex].getShaderProgramId()); - } - - } - - /** - * Method to disable the native shader program. - */ - private ShaderError disableShaderProgram(Canvas3D cv) { - return disableShaderProgram(cv.ctx); - } - - /** - * Initializes a mirror object. - */ - @Override - synchronized void initMirrorObject() { - - // Create mirror copy of shaders - if (this.shaders == null) { - ((ShaderProgramRetained)mirror).shaders = null; - } - else { - ((ShaderProgramRetained)mirror).shaders = new ShaderRetained[this.shaders.length]; - // Copy vertex and fragment shader - for (int i = 0; i < this.shaders.length; i++) { - ((ShaderProgramRetained)mirror).shaders[i] = - (ShaderRetained)this.shaders[i].mirror; - } - } - ((ShaderProgramRetained)mirror).shaderProgramData = null; - - // Create mirror copy of vertex attribute names - if (this.vertexAttrNames == null) { - ((ShaderProgramRetained)mirror).vertexAttrNames = null; - } - else { - ((ShaderProgramRetained)mirror).vertexAttrNames = this.vertexAttrNames.clone(); - } - - // Create mirror copy of shader attribute names - if (this.shaderAttrNames == null) { - ((ShaderProgramRetained)mirror).shaderAttrNames = null; - } - else { - ((ShaderProgramRetained)mirror).shaderAttrNames = this.shaderAttrNames.clone(); - } - - // Clear shader attribute error set - ((ShaderProgramRetained)mirror).shaderAttrErrorSet = null; - } - - /** - * Update the "component" field of the mirror object with the given "value" - */ - @Override - synchronized void updateMirrorObject(int component, Object value) { - - // ShaderProgram can't be modified once it is live. - assert(false); - System.err.println("ShaderProgramRetained : updateMirrorObject NOT IMPLEMENTED YET"); - } - - /** - * Method to create a ShaderProgramData object for the specified - * canvas/renderer if it doesn't already exist. - * - * Issue 378 : reset the ShaderProgramData object if the context - * has been recreated for the particular canvas / renderer. - */ - private void createShaderProgramData(int cvRdrIndex, long ctxTimeStamp) { - // Create shaderProgram resources if it has not been done. - synchronized(resourceLock) { - if(shaderProgramData == null) { - // We rely on Java to initial the array elements to null. - shaderProgramData = new ShaderProgramData[cvRdrIndex+1]; - } - else if(shaderProgramData.length <= cvRdrIndex) { - // We rely on Java to initial the array elements to null. - ShaderProgramData[] tempSPData = new ShaderProgramData[cvRdrIndex+1]; - System.arraycopy(shaderProgramData, 0, - tempSPData, 0, - shaderProgramData.length); - shaderProgramData = tempSPData; - } - - if(shaderProgramData[cvRdrIndex] == null) { - shaderProgramData[cvRdrIndex] = new ShaderProgramData(); - } else if (shaderProgramData[cvRdrIndex].getCtxTimeStamp() != ctxTimeStamp) { - // Issue 378 - reset the shader program data for this canvas / renderer - // if the context has been recreated - shaderProgramData[cvRdrIndex].reset(); - } - shaderProgramData[cvRdrIndex].setCtxTimeStamp(ctxTimeStamp); - } - } - - /** - * Method to create the native shader program. We must already have - * called createShaderProgramData for this cvRdrIndex. - */ - private ShaderError createShaderProgram(Canvas3D cv, int cvRdrIndex) { - // Create shaderProgram resources if it has not been done. - synchronized(resourceLock) { - assert shaderProgramData[cvRdrIndex].getShaderProgramId() == null; - - ShaderProgramId[] spIdArr = new ShaderProgramId[1]; - ShaderError err = createShaderProgram(cv.ctx, spIdArr); - if(err != null) { - return err; - } - shaderProgramData[cvRdrIndex].setShaderProgramId(spIdArr[0]); - } - - return null; - } - - /** - * Method to link the native shader program. - */ - private ShaderError linkShaderProgram(Canvas3D cv, int cvRdrIndex, - ShaderRetained[] shaders) { - synchronized(resourceLock) { - ShaderId[] shaderIds = new ShaderId[shaders.length]; - for(int i=0; i<shaders.length; i++) { - synchronized(shaders[i]) { - shaderIds[i] = shaders[i].shaderData[cvRdrIndex].getShaderId(); - } - } - ShaderError err = - linkShaderProgram(cv.ctx, - shaderProgramData[cvRdrIndex].getShaderProgramId(), - shaderIds); - if(err != null) { - return err; - } - shaderProgramData[cvRdrIndex].setLinked(true); - } - - return null; - } - - - private ShaderError bindVertexAttrName(Canvas3D cv, int cvRdrIndex, String attrName, int attrIndex) { - assert(attrName != null); - synchronized(resourceLock) { - ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); -// System.err.println("attrName = " + attrName); - ShaderError err = bindVertexAttrName(cv.ctx, shaderProgramId, attrName, attrIndex); - if (err != null) { - return err; - } - } - return null; - } - - private void lookupVertexAttrNames(Canvas3D cv, int cvRdrIndex, String[] attrNames) { - synchronized(resourceLock) { - ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); - - boolean[] errArr = new boolean[attrNames.length]; - lookupVertexAttrNames(cv.ctx, shaderProgramId, attrNames, errArr); - - for (int i = 0; i < attrNames.length; i++) { - // Report non-fatal error if detected - if (errArr[i]) { - String errMsg = "Vertex Attribute name lookup failed: " + attrNames[i]; - ShaderError err = new ShaderError(ShaderError.VERTEX_ATTRIBUTE_LOOKUP_ERROR, errMsg); - err.setShaderProgram((ShaderProgram)this.source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - } - } - } - } - - - private void lookupShaderAttrNames(Canvas3D cv, int cvRdrIndex, String[] attrNames) { - synchronized(resourceLock) { - ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); - - AttrNameInfo[] attrNameInfoArr = new AttrNameInfo[attrNames.length]; - lookupShaderAttrNames(cv.ctx, shaderProgramId, attrNames, attrNameInfoArr); - - for (int i = 0; i < attrNames.length; i++) { - shaderProgramData[cvRdrIndex].setAttrNameInfo(attrNames[i], attrNameInfoArr[i]); - - // Report non-fatal error if location is invalid - if (attrNameInfoArr[i].getLocation() == null) { - String errMsg = "Attribute name lookup failed: " + attrNames[i]; - ShaderError err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_LOOKUP_ERROR, errMsg); - err.setShaderProgram((ShaderProgram)this.source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - } - } - } - } - - - /** - * Method to return the shaderProgram data for the specified canvas or renderer - */ - private ShaderProgramData getShaderProgramData(int cvRdrIndex) { - synchronized(resourceLock) { - return shaderProgramData[cvRdrIndex]; - } - } - - /** - * Method to create the native shader. We must already have - * called createShaderData for this cvRdrIndex. - */ - private ShaderError createShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) { - - // Create shaderProgram resources if it has not been done. - synchronized(shader.resourceLock) { - if (shader.shaderData[cvRdrIndex].getShaderId() != null) { - // We have already created the shaderId for this Canvas. - return null; - } - - ShaderId[] shaderIdArr = new ShaderId[1]; - ShaderError err = createShader(cv.ctx, shader, shaderIdArr); - if(err != null) { - return err; - } - shader.shaderData[cvRdrIndex].setShaderId(shaderIdArr[0]); - } - return null; - } - - /** - * Method to compile the native shader. - */ - private ShaderError compileShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) { - - synchronized(shader.resourceLock) { - - if (shader.shaderData[cvRdrIndex].isCompiled()) { - // We have already compiled the shaderId for this Canvas. - return null; - } - - String source = ((SourceCodeShaderRetained)shader).getShaderSource(); - ShaderError err = compileShader(cv.ctx, shader.shaderData[cvRdrIndex].getShaderId(), source); - if(err != null) { - return err; - } - shader.shaderData[cvRdrIndex].setCompiled(true); - } - - return null; - } - - /** - * Send a message to the notification thread, which will call the - * shader error listeners. - */ - void notifyErrorListeners(Canvas3D cv, ShaderError err) { - J3dNotification notification = new J3dNotification(); - notification.type = J3dNotification.SHADER_ERROR; - notification.universe = cv.view.universe; - notification.args[0] = err; - VirtualUniverse.mc.sendNotification(notification); - } - - - /** - * This method checks whether this ShaderProgram is supported on - * the specified Canvas. If it isn't supported, it will report a - * ShaderError unless an error has already been reported for this - * shader program. - */ - private boolean verifyShaderProgramSupported(Canvas3D cv) { - boolean supported = isSupported(cv); - if (!supported && !unsupportedErrorReported) { - String errorMsg = J3dI18N.getString("ShaderProgramRetained0"); - ShaderError err = new ShaderError(ShaderError.UNSUPPORTED_LANGUAGE_ERROR, errorMsg); - err.setShaderProgram((ShaderProgram)this.source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - unsupportedErrorReported = true; - } - return supported; - } - - /** - * Method to destroy the native shader. - */ - void destroyShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) { - if (!verifyShaderProgramSupported(cv)) { - return; - } - - // Destroy shader resource if it exists - synchronized(shader.resourceLock) { - // Check whether an entry in the shaderData array has been allocated - if (shader.shaderData == null || - shader.shaderData.length <= cvRdrIndex || - shader.shaderData[cvRdrIndex] == null) { - return; - } - - // Nothing to do if the shaderId is null - if (shader.shaderData[cvRdrIndex].getShaderId() == null) { - return; - } - - // Destroy the native resource and set the ID to null for this canvas/renderer - // Ignore any possible shader error, because there is no meaningful way to report it - destroyShader(cv.ctx, shader.shaderData[cvRdrIndex].getShaderId()); - shader.shaderData[cvRdrIndex].reset(); - } - } - - - /** - * Method to destroy the native shader program. - */ - void destroyShaderProgram(Canvas3D cv, int cvRdrIndex) { - if (!verifyShaderProgramSupported(cv)) { - return; - } - - // Destroy shaderProgram resource if it exists - synchronized(resourceLock) { - assert(shaderProgramData != null && - shaderProgramData.length > cvRdrIndex && - shaderProgramData[cvRdrIndex] != null); - -// // Check whether an entry in the shaderProgramData array has been allocated -// if (shaderProgramData == null || -// shaderProgramData.length <= cvRdrIndex || -// shaderProgramData[cvRdrIndex] == null) { -// return; -// } - - ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); - // Nothing to do if the shaderProgramId is null - if (shaderProgramId == null) { - return; - } - - // Destroy the native resource, set the ID to null for this canvas/renderer, - // and clear the bit in the resourceCreationMask - // Ignore any possible shader error, because there is no meaningful way to report it - destroyShaderProgram(cv.ctx, shaderProgramId); - // Reset this ShaderProgramData object. - shaderProgramData[cvRdrIndex].reset(); - } - } - - - /** - * updateNative is called while traversing the RenderBin to - * update the shader program state - */ - void updateNative(Canvas3D cv, boolean enable) { - // System.err.println("ShaderProgramRetained.updateNative : "); - - final boolean useSharedCtx = cv.useSharedCtx && cv.screen.renderer.sharedCtx != null; - int cvRdrIndex; - long ctxTimeStamp; - - if (useSharedCtx) { - cvRdrIndex = cv.screen.renderer.rendererId; - ctxTimeStamp = cv.screen.renderer.sharedCtxTimeStamp; - } else { - cvRdrIndex = cv.canvasId; - ctxTimeStamp = cv.ctxTimeStamp; - } - - // Create ShaderProgramData object for this canvas/renderer if it doesn't already exist - createShaderProgramData(cvRdrIndex, ctxTimeStamp); - - // Check whether this shader program type is supported for this canvas - if (!verifyShaderProgramSupported(cv)) { - return; - } - - // Just disable shader program and return if enable parameter is set to false - if (!enable) { - // Given the current design, disableShaderProgram cannot return a non-null value, - // so no need to check it - disableShaderProgram(cv); - return; - } - - // Just disable shader program and return if array of shaders is empty, - // or if a previous attempt to link resulted in an error - if (shaders == null || shaders.length == 0 || linkErrorOccurred) { - disableShaderProgram(cv); - return; - } - - boolean loadShaderProgram = false; // flag indicating whether to reload all shaderProgram states - if (getShaderProgramData(cvRdrIndex).getShaderProgramId() == null) { - loadShaderProgram = true; - } - - //System.err.println(".... loadShaderProgram = " + loadShaderProgram); - //System.err.println(".... resourceCreationMask= " + resourceCreationMask); - - ShaderError err = null; - boolean errorOccurred = false; - if (loadShaderProgram) { - if (useSharedCtx) { - // TODO : Need to test useSharedCtx case. ** Untested case ** - cv.makeCtxCurrent(cv.screen.renderer.sharedCtx); - } - - // Create shader resources if not already done - for(int i=0; i < shaders.length; i++) { - // Create ShaderProgramData object for this canvas/renderer if it doesn't already exist - shaders[i].createShaderData(cvRdrIndex, ctxTimeStamp); - - if (shaders[i].compileErrorOccurred) { - errorOccurred = true; - } - else { - err = createShader(cv, cvRdrIndex, shaders[i]); - if (err != null) { - err.setShaderProgram((ShaderProgram)this.source); - err.setShader((Shader)shaders[i].source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - errorOccurred = true; - } - else { - err = compileShader(cv, cvRdrIndex, shaders[i]); - if (err != null) { - err.setShaderProgram((ShaderProgram)this.source); - err.setShader((Shader)shaders[i].source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - destroyShader(cv, cvRdrIndex, shaders[i]); - shaders[i].compileErrorOccurred = true; - errorOccurred = true; - } - } - } - } - - // Create shader program - if (!errorOccurred) { - err = createShaderProgram(cv, cvRdrIndex); - if (err != null) { - err.setShaderProgram((ShaderProgram)this.source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - errorOccurred = true; - } - } - - boolean linked = getShaderProgramData(cvRdrIndex).isLinked(); - if (!linked) { - // Bind vertex attribute names - if (!errorOccurred) { - if (vertexAttrNames != null) { -// System.err.println("vertexAttrNames.length = " + vertexAttrNames.length); - for (int i = 0; i < vertexAttrNames.length; i++) { - err = bindVertexAttrName(cv, cvRdrIndex, vertexAttrNames[i], i); - // Report non-fatal error, if one was detected - if (err != null) { - err.setShaderProgram((ShaderProgram)this.source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - } - } - } - } - - // Link shader program - if (!errorOccurred) { - err = linkShaderProgram(cv, cvRdrIndex, shaders); - if (err != null) { - err.setShaderProgram((ShaderProgram)this.source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - destroyShaderProgram(cv, cvRdrIndex); - linkErrorOccurred = true; - errorOccurred = true; - } - } - - // lookup vertex attribute names - if (!errorOccurred) { - if (vertexAttrNames != null) { - lookupVertexAttrNames(cv, cvRdrIndex, vertexAttrNames); - } - } - - // Lookup shader attribute names - if (!errorOccurred) { - if (shaderAttrNames != null) { -// System.err.println("shaderAttrNames.length = " + shaderAttrNames.length); - lookupShaderAttrNames(cv, cvRdrIndex, shaderAttrNames); - } - } - } - - // Restore current context if we changed it to the shareCtx - if (useSharedCtx) { - cv.makeCtxCurrent(cv.ctx); - } - - // If compilation or link error occured, disable shader program and return - if (errorOccurred) { - disableShaderProgram(cv); - return; - } - } - - // Now we can enable the shader program - enableShaderProgram(cv, cvRdrIndex); - } - - /** - * Update native value for ShaderAttributeValue class - */ - ShaderError setUniformAttrValue(Context ctx, ShaderProgramId shaderProgramId, - ShaderAttrLoc loc, ShaderAttributeValueRetained sav) { - - switch (sav.getClassType()) { - case ShaderAttributeObjectRetained.TYPE_INTEGER: - return setUniform1i(ctx, shaderProgramId, loc, - ((int[])sav.attrWrapper.getRef())[0]); - - case ShaderAttributeObjectRetained.TYPE_FLOAT: - return setUniform1f(ctx, shaderProgramId, loc, - ((float[])sav.attrWrapper.getRef())[0]); - - case ShaderAttributeObjectRetained.TYPE_TUPLE2I: - return setUniform2i(ctx, shaderProgramId, loc, - (int[])sav.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE2F: - return setUniform2f(ctx, shaderProgramId, loc, - (float[])sav.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE3I: - return setUniform3i(ctx, shaderProgramId, loc, - (int[])sav.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE3F: - return setUniform3f(ctx, shaderProgramId, loc, - (float[])sav.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE4I: - return setUniform4i(ctx, shaderProgramId, loc, - (int[])sav.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE4F: - return setUniform4f(ctx, shaderProgramId, loc, - (float[])sav.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_MATRIX3F: - return setUniformMatrix3f(ctx, shaderProgramId, loc, - (float[])sav.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_MATRIX4F: - return setUniformMatrix4f(ctx, shaderProgramId, loc, - (float[])sav.attrWrapper.getRef()); - - default: - // Should never get here - assert false : "Unrecognized ShaderAttributeValue classType"; - return null; - } - } - - /** - * Update native value for ShaderAttributeArray class - */ - ShaderError setUniformAttrArray(Context ctx, ShaderProgramId shaderProgramId, - ShaderAttrLoc loc, ShaderAttributeArrayRetained saa) { - - switch (saa.getClassType()) { - case ShaderAttributeObjectRetained.TYPE_INTEGER: - return setUniform1iArray(ctx, shaderProgramId, loc, saa.length(), - ((int[])saa.attrWrapper.getRef())); - - case ShaderAttributeObjectRetained.TYPE_FLOAT: - return setUniform1fArray(ctx, shaderProgramId, loc, saa.length(), - ((float[])saa.attrWrapper.getRef())); - - case ShaderAttributeObjectRetained.TYPE_TUPLE2I: - return setUniform2iArray(ctx, shaderProgramId, loc, saa.length(), - (int[])saa.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE2F: - return setUniform2fArray(ctx, shaderProgramId, loc, saa.length(), - (float[])saa.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE3I: - return setUniform3iArray(ctx, shaderProgramId, loc, saa.length(), - (int[])saa.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE3F: - return setUniform3fArray(ctx, shaderProgramId, loc, saa.length(), - (float[])saa.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE4I: - return setUniform4iArray(ctx, shaderProgramId, loc, saa.length(), - (int[])saa.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_TUPLE4F: - return setUniform4fArray(ctx, shaderProgramId, loc, saa.length(), - (float[])saa.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_MATRIX3F: - return setUniformMatrix3fArray(ctx, shaderProgramId, loc, saa.length(), - (float[])saa.attrWrapper.getRef()); - - case ShaderAttributeObjectRetained.TYPE_MATRIX4F: - return setUniformMatrix4fArray(ctx, shaderProgramId, loc, saa.length(), - (float[])saa.attrWrapper.getRef()); - - default: - // Should never get here - assert false : "Unrecognized ShaderAttributeArray classType"; - return null; - } - - } - - - void setShaderAttributes(Canvas3D cv, ShaderAttributeSetRetained attributeSet) { - final boolean useSharedCtx = cv.useSharedCtx && cv.screen.renderer.sharedCtx != null; - final int cvRdrIndex = useSharedCtx ? cv.screen.renderer.rendererId : cv.canvasId; - ShaderProgramData spData = getShaderProgramData(cvRdrIndex); - - // Just return if shader program wasn't linked successfully - if (!spData.isLinked()) { - return; - } - - ShaderProgramId shaderProgramId = spData.getShaderProgramId(); - - Iterator<ShaderAttributeRetained> attrs = attributeSet.getAttrs().values().iterator(); - while (attrs.hasNext()) { - ShaderError err = null; - ShaderAttributeRetained saRetained = attrs.next(); - - // Lookup attribute info for the specified attrName; null means - // that the name does not appear in the ShaderProgram, so we will - // report an error. - AttrNameInfo attrNameInfo = spData.getAttrNameInfo(saRetained.getAttributeName()); - if(attrNameInfo == null) { -// System.err.println("ShaderProgramRetained : attrLocation (" + saRetained.getAttributeName() + ") is null."); - String errMsg = "Attribute name not set in ShaderProgram: " + saRetained.getAttributeName(); // TODO: I18N - err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_NAME_NOT_SET_ERROR, errMsg); - } else { - ShaderAttrLoc loc = attrNameInfo.getLocation(); - if (loc != null) { - if (saRetained instanceof ShaderAttributeValueRetained) { - ShaderAttributeValueRetained savRetained = (ShaderAttributeValueRetained)saRetained; - if (attrNameInfo.isArray() || - (savRetained.getClassType() != attrNameInfo.getType())) { - String errMsg = "Attribute type mismatch: " + savRetained.getAttributeName(); // TODO: I18N - err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); - } - else { - err = setUniformAttrValue(cv.ctx, shaderProgramId, loc, savRetained); - } - } else if (saRetained instanceof ShaderAttributeArrayRetained) { - ShaderAttributeArrayRetained saaRetained = (ShaderAttributeArrayRetained)saRetained; - if (!attrNameInfo.isArray() || - (saaRetained.getClassType() != attrNameInfo.getType())) { - String errMsg = "Attribute type mismatch: " + saaRetained.getAttributeName(); // TODO: I18N - err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); - } - else { - err = setUniformAttrArray(cv.ctx, shaderProgramId, loc, saaRetained); - } - } else if (saRetained instanceof ShaderAttributeBindingRetained) { - assert false; - throw new RuntimeException("not implemented"); - } else { - assert false; - } - } - } - - if (err != null) { - // Before reporting the ShaderAttribute error, check - // whether it has already been reported for this ShaderProgram - if (shaderAttrErrorSet == null) { - shaderAttrErrorSet = new HashSet<ShaderAttribute>(); - } - if (shaderAttrErrorSet.add((ShaderAttribute) saRetained.source)) { - err.setShaderProgram((ShaderProgram)this.source); - err.setShaderAttributeSet((ShaderAttributeSet)attributeSet.source); - err.setShaderAttribute((ShaderAttribute)saRetained.source); - err.setCanvas3D(cv); - notifyErrorListeners(cv, err); - } - } - } - } - - class ShaderProgramData extends Object { - - // issue 378 - time stamp of context creation for this Canvas - private long ctxTimeStamp; - - // shaderProgramId use by native code. - private ShaderProgramId shaderProgramId = null; - - // linked flag for native. - private boolean linked = false; - - // A map of locations for ShaderAttributes. -private HashMap<String, AttrNameInfo> attrNameInfoMap = new HashMap<String, AttrNameInfo>(); - - /** ShaderProgramData Constructor */ - ShaderProgramData() { - } - - void reset() { - ctxTimeStamp = 0L; - shaderProgramId = null; - linked = false; - attrNameInfoMap.clear(); - } - - long getCtxTimeStamp() { - return ctxTimeStamp; - } - - void setCtxTimeStamp(long ctxTimeStamp) { - this.ctxTimeStamp = ctxTimeStamp; - } - - void setShaderProgramId(ShaderProgramId shaderProgramId) { - this.shaderProgramId = shaderProgramId; - } - - ShaderProgramId getShaderProgramId() { - return this.shaderProgramId; - } - - void setLinked(boolean linked) { - this.linked = linked; - } - - boolean isLinked() { - return linked; - } - -void setAttrNameInfo(String shaderAttribute, AttrNameInfo attrNameInfo) { - assert (shaderAttribute != null); - attrNameInfoMap.put(shaderAttribute, attrNameInfo); -} - -AttrNameInfo getAttrNameInfo(String shaderAttribute) { - return attrNameInfoMap.get(shaderAttribute); -} - - } - - // Data associated with an attribute name - class AttrNameInfo { - void setLocation(ShaderAttrLoc loc) { - this.loc = loc; - } - - ShaderAttrLoc getLocation() { - return loc; - } - - void setType(int type) { - this.type = type; - } - - int getType() { - return type; - } - - boolean isArray() { - return isArray; - } - - void setArray(boolean isArray) { - this.isArray = isArray; - } - - // Location of attribute name in linked shader program - private ShaderAttrLoc loc; - - // boolean indicating whether the attribute is an array - private boolean isArray; - - // type of shader attribute - private int type; - } - -} diff --git a/src/main/java-templates/org/jogamp/java3d/VersionInfo.java b/src/main/java-templates/org/jogamp/java3d/VersionInfo.java new file mode 100644 index 0000000..36de115 --- /dev/null +++ b/src/main/java-templates/org/jogamp/java3d/VersionInfo.java @@ -0,0 +1,340 @@ +/* + * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +package org.jogamp.java3d; + +/** + * The VersionInfo class contains strings that describe the implementation + * and specification version of the org.jogamp.java3d pacakge. These strings + * are made available as properties obtained from the VirtualUniverse class. + * + * <h4>NOTE TO DEVELOPERS:</h4> + * + * <p> + * Developers are strongly encouraged to do the following whenever they + * modify the 3D graphics API for the Java platform: + * + * <ol> + * <li>The VENDOR_DEVELOPER string should be modified to + * indicate the name of the individuals or organizations who have + * modified the source code.</li> + * + * <li>The VERSION_DEV_STRING may be modified to indicate + * additional information about the particular build, but this is + * not required.</li> + * + * <li>The strings denoted as being unmodifiable should <i>not</i> be + * modified.</li> + * </ol> + * + * <p> + * The tags of the form ${string} are populated by Maven when the project is built + * + * @see VirtualUniverse#getProperties + */ +class VersionInfo extends Object { + /** + * Developer who has modified the 3D graphics API for the Java platform. + * This string should be modified to indicate the name of the + * individual(s) or organization(s) who modified the code. + */ + private static final String VENDOR_DEVELOPER = null; + + + /** + * An optional string appended to the end of the version string, + * after the time stamp. A space will be automatically prepended + * to this string. This string should be null if no dev string is + * desired. + */ + private static final String VERSION_DEV_STRING = null; + + // ------------------------------------------------------------------- + // ------------------------------------------------------------------- + // END OF DEVELOPER-MODIFIABLE PARAMETERS + // ------------------------------------------------------------------- + // ------------------------------------------------------------------- + + + // ------------------------------------------------------------------- + // The following set of constants should not be modified by developers. + // ------------------------------------------------------------------- + + /** + * Constant that indicates whether or not this is a debug build. + */ + static final boolean isDebug = ${is_debug}; + + /** + * This static final variable is used to enable debugging and + * assertion checking during the development phase of a particular + * version of 3D graphics API for the Java platform. It is disabled + * for "opt" production builds (beta, release candidate, fcs, and + * patch builds). It is enabled for all "debug" builds and for daily + * and stable "opt" builds. + * + * <p> + * This parameter is controlled by ant via the build.xml file. The + * default value is true. + */ + static final boolean isDevPhase = ${is_dev_phase}; + + /** + * This static final variable is used indicate a production + * (beta, release candidate, fcs, or patch) build. + * <p> + * This parameter is controlled by ant via the build.xml file. The + * default value is false. + */ + static final boolean isProduction = ${is_production}; + + /** + * If this flag is set to true, the verbose buildtime string + * will be appended to the version string) + * <p> + * This parameter is controlled by ant via the build.xml file. The + * default value is true. + */ + private static final boolean useVerboseBuildTime = ${use_verbose_buildtime}; + + /** + * String identifying the type of build, one of: + * "daily", "stable", "beta", "fcs", or "patch". The default value + * is "daily". + */ + private static final String BUILD_TYPE = "${build.type}"; + + /** + * String identifying the build number in the format + * "buildNN", where "NN" is the sequential build number, for + * example, build47. This string contain only letters and + * numbers, It must not contain any other characters or spaces. + * + * For production builds, this string appears parenthetically, + * after the first space. + */ + private static final String VERSION_BUILD = "${version_build}"; + + /** + * String identifying the particular build of the 3D API, for + * example, "-beta1", "-build47", "-rc1", "_01", etc. Note that + * this includes the leading dash or underscore. It will typically + * be empty for FCS builds. This string may only contain letters, + * numbers, periods, dashes, or underscores. It must not contain + * any other characters or spaces. + * + * This us used as part of the j3d.version that appears before the + * optional first space. + */ + private static final String VERSION_SUFFIX = "${version_suffix}"; + + /** + * Date stamp + * + * This is only used for daily builds. + */ + private static final String BUILDTIME = "${buildtime}"; + + /** + * Specification version (major and minor version only). This + * string must not be modified by developers. + */ + private static final String SPECIFICATION_VERSION = "1.7"; + + /** + * Specification vendor. + */ + private static final String SPECIFICATION_VENDOR = "${build.spec.vendor}"; + + /** + * Primary implementation vendor. + */ + private static final String VENDOR_PRIMARY = "${build.impl.vendor}"; + + /** + * Base version number. This is the major.minor.subminor version + * number. Version qualifiers are specified separately. The + * major and minor version <i>must</i> be the same as the specification + * version. + */ + private static final String VERSION_BASE = "${project.version}"; + + /** + * Boolean flag indicating that the version of the 3D API is + * experimental. This must <i>not</i> be modified by developers. + * All non-official builds <i>must</i> contain the string + * <code>"experimental"</code> as part of the release name that + * appears before the optional first space. + */ + private static final boolean isExperimental = !isProduction; + + /** + * The composite version string. This is composed in the static + * initializer for this class. + */ + private static final String VERSION; + + /** + * The composite version string. This is composed in the static + * initializer for this class. + */ + private static final String VERSION_FULL; + + /** + * The composite vendor string. This is composed in the static + * initializer for this class. + */ + private static final String VENDOR; + + /** + * Verbose time and date stamp appended to the end of the version string. + * This is appended to the version string + * after the build identifier (and after the first space, which + * will automatically be added) and before the optional dev + * string. This string is only used for non-fcs builds. + */ + private static final String BUILDTIME_VERBOSE = "${buildtime_verbose}"; + + private static boolean isNonEmpty(String str) { + if ((str == null) || (str.length() == 0)) { + return false; + } + else { + return true; + } + } + + // The static initializer composes the version and vendor strings + static { + final boolean isPatchBuild = BUILD_TYPE.equals("patch"); + final boolean isFcsBuild = BUILD_TYPE.equals("fcs"); + final boolean isBetaBuild = BUILD_TYPE.equals("beta"); + final boolean isStableBuild = BUILD_TYPE.equals("stable"); + final boolean isDailyBuild = BUILD_TYPE.equals("daily"); + + // Assign the vendor by concatenating primary and developer + // vendor strings + String tmpVendor = VENDOR_PRIMARY; + if (isNonEmpty(VENDOR_DEVELOPER)) { + tmpVendor += " & " + VENDOR_DEVELOPER; + } + + String tmpVersionFull = VERSION_BASE; + String tmpVersion = VERSION_BASE; + if (isNonEmpty(VERSION_SUFFIX)) { + if (isPatchBuild) { + tmpVersionFull += "_"; + tmpVersion += "_"; + } + else { + tmpVersionFull += "-"; + tmpVersion += "_"; + } + tmpVersionFull += VERSION_SUFFIX; + tmpVersion += VERSION_SUFFIX; + } + + if (isDailyBuild && isNonEmpty(BUILDTIME)) { + tmpVersionFull += "-" + BUILDTIME; + } + + if (isExperimental) { + tmpVersionFull += "-experimental"; + } + + // Append the optional fields that follow the first space + + if (isProduction) { + if (isFcsBuild) { + tmpVersionFull += " fcs"; + tmpVersion += " fcs"; + } + else if (isPatchBuild) { + tmpVersionFull += " fcs+patch"; + tmpVersion += " fcs+patch"; + } + + if (isNonEmpty(VERSION_BUILD)) { + tmpVersionFull += " (" + VERSION_BUILD + ")"; + tmpVersion += " (" + VERSION_BUILD + ")"; + } + } + + if (useVerboseBuildTime && isNonEmpty(BUILDTIME_VERBOSE)) { + tmpVersionFull += " " + BUILDTIME_VERBOSE; + } + + if (isNonEmpty(VERSION_DEV_STRING)) { + tmpVersionFull += " " + VERSION_DEV_STRING; + } + + VERSION_FULL = tmpVersionFull; + VERSION = tmpVersion; + VENDOR = tmpVendor; + } + + /** + * Returns the specification version string. + * @return the specification version string + */ + static String getSpecificationVersion() { + return SPECIFICATION_VERSION; + } + + /** + * Returns the specification vendor string. + * @return the specification vendor string + */ + static String getSpecificationVendor() { + return SPECIFICATION_VENDOR; + } + + + /** + * Returns the implementation version string. + * @return the implementation version string + */ + static String getVersion() { + return VERSION; + } + + /** + * Returns the implementation version string. + * @return the implementation version string + */ + static String getVersionFull() { + return VERSION_FULL; + } + + /** + * Returns the implementation vendor string. + * @return the implementation vendor string + */ + static String getVendor() { + return VENDOR; + } + +} diff --git a/src/javax/media/j3d/Alpha.java b/src/main/java/org/jogamp/java3d/Alpha.java index 8f3cb2f..23f0320 100644 --- a/src/javax/media/j3d/Alpha.java +++ b/src/main/java/org/jogamp/java3d/Alpha.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/AlternateAppearance.java b/src/main/java/org/jogamp/java3d/AlternateAppearance.java index 48b9066..eeb2e73 100644 --- a/src/javax/media/j3d/AlternateAppearance.java +++ b/src/main/java/org/jogamp/java3d/AlternateAppearance.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** @@ -365,14 +365,14 @@ public class AlternateAppearance extends Leaf { /** - * Returns an enumeration of this AlternateAppearance node's list + * Returns an iterator of this AlternateAppearance node's list * of scopes. - * @return an Enumeration object containing all nodes in this + * @return an Iterator object containing all nodes in this * AlternateAppearance node's list of scopes. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ -public Enumeration<Group> getAllScopes() { +public Iterator<Group> getAllScopes() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_SCOPE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance11")); @@ -538,10 +538,10 @@ public Enumeration<Group> getAllScopes() { rt.initInfluencingBounds(attr.getInfluencingBounds()); - Enumeration<Group> elm = attr.getAllScopes(); - while (elm.hasMoreElements()) { + Iterator<Group> elm = attr.getAllScopes(); + while (elm.hasNext()) { // this reference will set correctly in updateNodeReferences() callback - rt.initAddScope(elm.nextElement()); + rt.initAddScope(elm.next()); } // correct value will set in updateNodeReferences diff --git a/src/javax/media/j3d/AlternateAppearanceRetained.java b/src/main/java/org/jogamp/java3d/AlternateAppearanceRetained.java index 636bc13..8f143a3 100644 --- a/src/javax/media/j3d/AlternateAppearanceRetained.java +++ b/src/main/java/org/jogamp/java3d/AlternateAppearanceRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; @@ -349,16 +349,16 @@ Vector<GroupRetained> scopes = new Vector<GroupRetained>(); } /** - * Returns an enumeration object of the scoperen. - * @return an enumeration object of the scoperen + * Returns an iterator object of the scoperen. + * @return an iterator object of the scoperen */ -Enumeration<Group> getAllScopes() { - Enumeration<GroupRetained> elm = scopes.elements(); +Iterator<Group> getAllScopes() { + Iterator<GroupRetained> elm = scopes.iterator(); Vector<Group> v = new Vector<Group>(scopes.size()); - while (elm.hasMoreElements()) { - v.add((Group)elm.nextElement().source); + while (elm.hasNext()) { + v.add((Group)elm.next().source); } - return v.elements(); + return v.iterator(); } /** @@ -811,10 +811,10 @@ Enumeration<Group> getAllScopes() { // setInfluencingBounds(alternate appearance.getInfluencingBounds()); -// Enumeration elm = alternate appearance.getAllScopes(); -// while (elm.hasMoreElements()) { +// Iterator elm = alternate appearance.getAllScopes(); +// while (elm.hasNext()) { // // this reference will set correctly in updateNodeReferences() callback -// addScope((Group) elm.nextElement()); +// addScope((Group) elm.next()); // } // // this reference will set correctly in updateNodeReferences() callback diff --git a/src/javax/media/j3d/AmbientLight.java b/src/main/java/org/jogamp/java3d/AmbientLight.java index 588ea51..60de63c 100644 --- a/src/javax/media/j3d/AmbientLight.java +++ b/src/main/java/org/jogamp/java3d/AmbientLight.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * An ambient light source object. Ambient light is that light diff --git a/src/javax/media/j3d/AmbientLightRetained.java b/src/main/java/org/jogamp/java3d/AmbientLightRetained.java index dcc7c22..1317ac9 100644 --- a/src/javax/media/j3d/AmbientLightRetained.java +++ b/src/main/java/org/jogamp/java3d/AmbientLightRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/Appearance.java b/src/main/java/org/jogamp/java3d/Appearance.java index a26eb84..31f37b1 100644 --- a/src/javax/media/j3d/Appearance.java +++ b/src/main/java/org/jogamp/java3d/Appearance.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; @@ -319,7 +319,11 @@ public class Appearance extends NodeComponent { * state variables. All component object references are initialized * to null. */ - public Appearance() { + public Appearance() { + //Note use of this constructor before Canvas3D or Universe will result in a null pipeline and no warning + if(!(this instanceof ShaderAppearance) && Pipeline.getPipeline() instanceof Jogl2es2Pipeline) + System.err.println("Appearance will display nothing when using the Jogl2es2 Pipeline, consider using a ShaderAppearance"); + // Just use default values // set default read capabilities setDefaultReadCapabilities(readCapabilities); diff --git a/src/javax/media/j3d/AppearanceRetained.java b/src/main/java/org/jogamp/java3d/AppearanceRetained.java index 987e911..a09c59a 100644 --- a/src/javax/media/j3d/AppearanceRetained.java +++ b/src/main/java/org/jogamp/java3d/AppearanceRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/AssertionFailureException.java b/src/main/java/org/jogamp/java3d/AssertionFailureException.java index 2135e12..26016ae 100644 --- a/src/javax/media/j3d/AssertionFailureException.java +++ b/src/main/java/org/jogamp/java3d/AssertionFailureException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates an assertion failure. diff --git a/src/javax/media/j3d/AttributeBin.java b/src/main/java/org/jogamp/java3d/AttributeBin.java index 95ce52a..655a129 100644 --- a/src/javax/media/j3d/AttributeBin.java +++ b/src/main/java/org/jogamp/java3d/AttributeBin.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/AudioDevice.java b/src/main/java/org/jogamp/java3d/AudioDevice.java index 1aab9fc..913edb8 100644 --- a/src/javax/media/j3d/AudioDevice.java +++ b/src/main/java/org/jogamp/java3d/AudioDevice.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** @@ -130,7 +130,7 @@ package javax.media.j3d; * with the Java3D sound scheduler by associating this device with a * PhysicalEnvironment. The setAudioDevice method introduces new devices * to the Java3D environment and the allAudioDevices method produces an - * enumeration that allows examining all available devices within a Java3D + * iterator that allows examining all available devices within a Java3D * environment. See PhysicalEnvironment class for more details.</UL> * <P> * General Rules for calling AudioDevice methods: diff --git a/src/javax/media/j3d/AudioDevice3D.java b/src/main/java/org/jogamp/java3d/AudioDevice3D.java index 7f152e4..4976298 100644 --- a/src/javax/media/j3d/AudioDevice3D.java +++ b/src/main/java/org/jogamp/java3d/AudioDevice3D.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** diff --git a/src/javax/media/j3d/AudioDevice3DL2.java b/src/main/java/org/jogamp/java3d/AudioDevice3DL2.java index 337328c..2748c06 100644 --- a/src/javax/media/j3d/AudioDevice3DL2.java +++ b/src/main/java/org/jogamp/java3d/AudioDevice3DL2.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/AudioDeviceEnumerator.java b/src/main/java/org/jogamp/java3d/AudioDeviceEnumerator.java index dbab9b3..621c057 100644 --- a/src/javax/media/j3d/AudioDeviceEnumerator.java +++ b/src/main/java/org/jogamp/java3d/AudioDeviceEnumerator.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; import java.util.NoSuchElementException; /** @@ -36,7 +36,7 @@ import java.util.NoSuchElementException; * execution environment of the currently running Java 3D application. */ -class AudioDeviceEnumerator implements Enumeration { +class AudioDeviceEnumerator implements Iterator<AudioDevice> { boolean endOfList; // NOTE: list length always equals one or zero AudioDevice device; @@ -60,7 +60,7 @@ class AudioDeviceEnumerator implements Enumeration { * @return true if the enumerator has more elements, false otherwise */ @Override - public boolean hasMoreElements() { + public boolean hasNext() { if(endOfList == false) return true; else @@ -72,12 +72,19 @@ class AudioDeviceEnumerator implements Enumeration { * @return the next element in this enumerator */ @Override - public Object nextElement() { - if (this.hasMoreElements()) { + public AudioDevice next() { + if (this.hasNext()) { endOfList = true; - return ((Object) device); + return device; } else { throw new NoSuchElementException(J3dI18N.getString("AudioDeviceEnumerator0")); } } + + @Override + public void remove() + { + throw new UnsupportedOperationException(); + + } } diff --git a/src/javax/media/j3d/AuralAttributes.java b/src/main/java/org/jogamp/java3d/AuralAttributes.java index 563bc3a..bf5e027 100644 --- a/src/javax/media/j3d/AuralAttributes.java +++ b/src/main/java/org/jogamp/java3d/AuralAttributes.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; +import org.jogamp.vecmath.Point2f; /** * The AuralAttributes object is a component object of a Soundscape node that diff --git a/src/javax/media/j3d/AuralAttributesRetained.java b/src/main/java/org/jogamp/java3d/AuralAttributesRetained.java index f5e3d6a..c595cc9 100644 --- a/src/javax/media/j3d/AuralAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/AuralAttributesRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; +import org.jogamp.vecmath.Point2f; /** * The AuralAttributesRetained object defines all rendering state that can diff --git a/src/javax/media/j3d/AutoOffScreenCanvas3D.java b/src/main/java/org/jogamp/java3d/AutoOffScreenCanvas3D.java index 0fc0a60..694395f 100644 --- a/src/javax/media/j3d/AutoOffScreenCanvas3D.java +++ b/src/main/java/org/jogamp/java3d/AutoOffScreenCanvas3D.java @@ -13,7 +13,7 @@ * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). */ -package javax.media.j3d; +package org.jogamp.java3d; /** * An interface used to tag Canavs3d subclasses as being offsceen. diff --git a/src/javax/media/j3d/BHInsertStructure.java b/src/main/java/org/jogamp/java3d/BHInsertStructure.java index b64bfb5..f5078db 100644 --- a/src/javax/media/j3d/BHInsertStructure.java +++ b/src/main/java/org/jogamp/java3d/BHInsertStructure.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Random; diff --git a/src/javax/media/j3d/BHInternalNode.java b/src/main/java/org/jogamp/java3d/BHInternalNode.java index 1272e58..4bddc88 100644 --- a/src/javax/media/j3d/BHInternalNode.java +++ b/src/main/java/org/jogamp/java3d/BHInternalNode.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class BHInternalNode extends BHNode { diff --git a/src/javax/media/j3d/BHLeafInterface.java b/src/main/java/org/jogamp/java3d/BHLeafInterface.java index 195169f..3f623cc 100644 --- a/src/javax/media/j3d/BHLeafInterface.java +++ b/src/main/java/org/jogamp/java3d/BHLeafInterface.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; interface BHLeafInterface { diff --git a/src/javax/media/j3d/BHLeafNode.java b/src/main/java/org/jogamp/java3d/BHLeafNode.java index 2fcedbb..468e824 100644 --- a/src/javax/media/j3d/BHLeafNode.java +++ b/src/main/java/org/jogamp/java3d/BHLeafNode.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class BHLeafNode extends BHNode { diff --git a/src/javax/media/j3d/BHNode.java b/src/main/java/org/jogamp/java3d/BHNode.java index 23c4a93..cfb71bf 100644 --- a/src/javax/media/j3d/BHNode.java +++ b/src/main/java/org/jogamp/java3d/BHNode.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; abstract class BHNode { diff --git a/src/javax/media/j3d/BHTree.java b/src/main/java/org/jogamp/java3d/BHTree.java index 260448c..2bb3357 100644 --- a/src/javax/media/j3d/BHTree.java +++ b/src/main/java/org/jogamp/java3d/BHTree.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Vector; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point4d; class BHTree { diff --git a/src/javax/media/j3d/Background.java b/src/main/java/org/jogamp/java3d/Background.java index e7cf50b..5bdf03f 100644 --- a/src/javax/media/j3d/Background.java +++ b/src/main/java/org/jogamp/java3d/Background.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The Background leaf node defines a solid background color diff --git a/src/javax/media/j3d/BackgroundRetained.java b/src/main/java/org/jogamp/java3d/BackgroundRetained.java index 847d8de..500518e 100644 --- a/src/javax/media/j3d/BackgroundRetained.java +++ b/src/main/java/org/jogamp/java3d/BackgroundRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** diff --git a/src/javax/media/j3d/BackgroundSound.java b/src/main/java/org/jogamp/java3d/BackgroundSound.java index 8ca0de0..2c44b7b 100644 --- a/src/javax/media/j3d/BackgroundSound.java +++ b/src/main/java/org/jogamp/java3d/BackgroundSound.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A BackgroundSound node defines an unattenuated, nonspatialized sound diff --git a/src/javax/media/j3d/BackgroundSoundRetained.java b/src/main/java/org/jogamp/java3d/BackgroundSoundRetained.java index 6f026f6..d2373f4 100644 --- a/src/javax/media/j3d/BackgroundSoundRetained.java +++ b/src/main/java/org/jogamp/java3d/BackgroundSoundRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * BackgroundSound is a class for sounds that are not spatially rendered. diff --git a/src/javax/media/j3d/BadTransformException.java b/src/main/java/org/jogamp/java3d/BadTransformException.java index c7c2c5c..635873e 100644 --- a/src/javax/media/j3d/BadTransformException.java +++ b/src/main/java/org/jogamp/java3d/BadTransformException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates an attempt to use a Tranform3D object that is diff --git a/src/javax/media/j3d/Behavior.java b/src/main/java/org/jogamp/java3d/Behavior.java index f0e5501..1032177 100644 --- a/src/javax/media/j3d/Behavior.java +++ b/src/main/java/org/jogamp/java3d/Behavior.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** * The Behavior leaf node provides a framework for adding user-defined @@ -133,7 +133,7 @@ import java.util.Enumeration; * <P> * <UL> * <LI>Code to decode and extract references from the WakeupCondition - * enumeration that caused the object's awakening.</LI> + * iterator that caused the object's awakening.</LI> * <LI>Code to perform the manipulations associated with the * WakeupCondition</LI> * <LI>Code to establish this behavior's new WakeupCondition</LI> @@ -150,7 +150,7 @@ import java.util.Enumeration; * node provides the Java 3D behavior scheduler with a WakeupCondition * object. When that object's WakeupCondition has been satisfied, the * behavior scheduler hands that same WakeupCondition back to the - * Behavior via an enumeration. + * Behavior via an iterator. * * <P> * <b>WakeupCriterion Object</b> @@ -238,10 +238,10 @@ public abstract class Behavior extends Leaf { * <br> * NOTE: Applications should <i>not</i> call this method. It is called * by the Java 3D behavior scheduler. - * @param criteria an enumeration of triggered wakeup criteria for this + * @param criteria an iterator of triggered wakeup criteria for this * behavior */ - public abstract void processStimulus(Enumeration criteria); + public abstract void processStimulus(Iterator<WakeupCriterion> criteria); /** * Set the Behavior's scheduling region to the specified bounds. diff --git a/src/javax/media/j3d/BehaviorRetained.java b/src/main/java/org/jogamp/java3d/BehaviorRetained.java index b82b09d..db52181 100644 --- a/src/javax/media/j3d/BehaviorRetained.java +++ b/src/main/java/org/jogamp/java3d/BehaviorRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Behavior is an abstract class that contains the framework for all diff --git a/src/javax/media/j3d/BehaviorScheduler.java b/src/main/java/org/jogamp/java3d/BehaviorScheduler.java index 1a43a34..1f0219d 100644 --- a/src/javax/media/j3d/BehaviorScheduler.java +++ b/src/main/java/org/jogamp/java3d/BehaviorScheduler.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.logging.Level; diff --git a/src/javax/media/j3d/BehaviorStructure.java b/src/main/java/org/jogamp/java3d/BehaviorStructure.java index dc10a13..7a213ca 100644 --- a/src/javax/media/j3d/BehaviorStructure.java +++ b/src/main/java/org/jogamp/java3d/BehaviorStructure.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.AWTEvent; import java.awt.event.ComponentEvent; @@ -33,8 +33,8 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.Arrays; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * A behavior structure is a object that organizes behaviors, diff --git a/src/javax/media/j3d/Billboard.java b/src/main/java/org/jogamp/java3d/Billboard.java index 0372062..c9c24d3 100644 --- a/src/javax/media/j3d/Billboard.java +++ b/src/main/java/org/jogamp/java3d/Billboard.java @@ -24,15 +24,15 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; -import javax.vecmath.AxisAngle4d; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.AxisAngle4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** * The Billboard behavior node operates on the TransformGroup node @@ -306,11 +306,11 @@ public class Billboard extends Behavior { /** * Process stimulus method that computes appropriate transform. - * @param criteria an enumeration of the criteria that caused the + * @param criteria an iterator of the criteria that caused the * stimulus */ @Override - public void processStimulus(Enumeration criteria) { + public void processStimulus(Iterator<WakeupCriterion> criteria) { double angle = 0.0; double sign; diff --git a/src/javax/media/j3d/BoundingBox.java b/src/main/java/org/jogamp/java3d/BoundingBox.java index 304e43b..aa7e739 100644 --- a/src/javax/media/j3d/BoundingBox.java +++ b/src/main/java/org/jogamp/java3d/BoundingBox.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector4d; /** * This class defines an axis aligned bounding box which is used for @@ -1754,22 +1754,30 @@ public void setUpper(Point3d p1) { int i = 5; while (i>=0){ Vector4d vc = frustum.clipPlanes[i--]; - if ((( upper.x*vc.x + upper.y*vc.y + - upper.z*vc.z + vc.w ) < 0.0 ) && - (( upper.x*vc.x + lower.y*vc.y + - upper.z*vc.z + vc.w ) < 0.0 ) && - (( upper.x*vc.x + lower.y*vc.y + - lower.z*vc.z + vc.w ) < 0.0 ) && - (( upper.x*vc.x + upper.y*vc.y + - lower.z*vc.z + vc.w ) < 0.0 ) && - (( lower.x*vc.x + upper.y*vc.y + - upper.z*vc.z + vc.w ) < 0.0 ) && - (( lower.x*vc.x + lower.y*vc.y + - upper.z*vc.z + vc.w ) < 0.0 ) && - (( lower.x*vc.x + lower.y*vc.y + - lower.z*vc.z + vc.w ) < 0.0 ) && - (( lower.x*vc.x + upper.y*vc.y + - lower.z*vc.z + vc.w ) < 0.0 )) { + + double upxxvcx = upper.x*vc.x; + double loxxvcx = lower.x*vc.x; + double upyxvcy = upper.y*vc.y; + double loyxvcy = lower.y*vc.y; + double upzxvcz = upper.z*vc.z; + double lozxvcz = lower.z*vc.z; + + if ((( upxxvcx + upyxvcy + + upzxvcz + vc.w ) < 0.0 ) && + (( upxxvcx + loyxvcy + + upzxvcz + vc.w ) < 0.0 ) && + (( upxxvcx + loyxvcy + + lozxvcz + vc.w ) < 0.0 ) && + (( upxxvcx + upyxvcy + + lozxvcz + vc.w ) < 0.0 ) && + (( loxxvcx + upyxvcy + + upzxvcz + vc.w ) < 0.0 ) && + (( loxxvcx + loyxvcy + + upzxvcz + vc.w ) < 0.0 ) && + (( loxxvcx + loyxvcy + + lozxvcz + vc.w ) < 0.0 ) && + (( loxxvcx + upyxvcy + + lozxvcz + vc.w ) < 0.0 )) { // all corners outside this frustum plane // System.err.println("*** all corners outside this frustum plane"); return false; diff --git a/src/javax/media/j3d/BoundingLeaf.java b/src/main/java/org/jogamp/java3d/BoundingLeaf.java index 3037abe..336c4b0 100644 --- a/src/javax/media/j3d/BoundingLeaf.java +++ b/src/main/java/org/jogamp/java3d/BoundingLeaf.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/BoundingLeafRetained.java b/src/main/java/org/jogamp/java3d/BoundingLeafRetained.java index 309922f..28f31c3 100644 --- a/src/javax/media/j3d/BoundingLeafRetained.java +++ b/src/main/java/org/jogamp/java3d/BoundingLeafRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/BoundingPolytope.java b/src/main/java/org/jogamp/java3d/BoundingPolytope.java index 37d47c0..6002418 100644 --- a/src/javax/media/j3d/BoundingPolytope.java +++ b/src/main/java/org/jogamp/java3d/BoundingPolytope.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector4d; /** * A BoundingPolytope defines a polyhedral bounding region using the diff --git a/src/javax/media/j3d/BoundingSphere.java b/src/main/java/org/jogamp/java3d/BoundingSphere.java index f3e01f5..11b58c6 100644 --- a/src/javax/media/j3d/BoundingSphere.java +++ b/src/main/java/org/jogamp/java3d/BoundingSphere.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector4d; /** * This class defines a spherical bounding region which is defined by a diff --git a/src/javax/media/j3d/Bounds.java b/src/main/java/org/jogamp/java3d/Bounds.java index 9672859..4601a7b 100644 --- a/src/javax/media/j3d/Bounds.java +++ b/src/main/java/org/jogamp/java3d/Bounds.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Matrix3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Matrix3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector4d; /** * The abstract base class for bounds objects. Bounds objects define diff --git a/src/javax/media/j3d/BranchGroup.java b/src/main/java/org/jogamp/java3d/BranchGroup.java index 41fc93a..1129d45 100644 --- a/src/javax/media/j3d/BranchGroup.java +++ b/src/main/java/org/jogamp/java3d/BranchGroup.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** @@ -242,7 +242,7 @@ public class BranchGroup extends Group { * (in addition to one of the above)</li> * </ul> * - * @see Locale#pickAll(int,int,javax.media.j3d.PickShape) + * @see Locale#pickAll(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 @@ -347,7 +347,7 @@ public class BranchGroup extends Group { * (in addition to one of the above)</li> * </ul> * - * @see Locale#pickAllSorted(int,int,javax.media.j3d.PickShape) + * @see Locale#pickAllSorted(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 @@ -445,7 +445,7 @@ public class BranchGroup extends Group { * (in addition to one of the above)</li> * </ul> * - * @see Locale#pickClosest(int,int,javax.media.j3d.PickShape) + * @see Locale#pickClosest(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 @@ -541,7 +541,7 @@ public class BranchGroup extends Group { * (in addition to one of the above)</li> * </ul> * - * @see Locale#pickAny(int,int,javax.media.j3d.PickShape) + * @see Locale#pickAny(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 diff --git a/src/javax/media/j3d/BranchGroupRetained.java b/src/main/java/org/jogamp/java3d/BranchGroupRetained.java index 47372d0..e61d897 100644 --- a/src/javax/media/j3d/BranchGroupRetained.java +++ b/src/main/java/org/jogamp/java3d/BranchGroupRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/CachedFrustum.java b/src/main/java/org/jogamp/java3d/CachedFrustum.java index c3d6e90..0d6d08d 100644 --- a/src/javax/media/j3d/CachedFrustum.java +++ b/src/main/java/org/jogamp/java3d/CachedFrustum.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector4d; /** * The CachedFrustum class is used to pre compute data for a set of view diff --git a/src/javax/media/j3d/CachedTargets.java b/src/main/java/org/jogamp/java3d/CachedTargets.java index 0723d4c..ac7f95c 100644 --- a/src/javax/media/j3d/CachedTargets.java +++ b/src/main/java/org/jogamp/java3d/CachedTargets.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class CachedTargets { // cached targets, used by J3d threads diff --git a/src/javax/media/j3d/Canvas3D.java b/src/main/java/org/jogamp/java3d/Canvas3D.java index 8824191..a4f2b95 100644 --- a/src/javax/media/j3d/Canvas3D.java +++ b/src/main/java/org/jogamp/java3d/Canvas3D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.AWTEvent; import java.awt.Canvas; @@ -47,10 +47,10 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import javax.vecmath.Color3f; -import javax.vecmath.Point2d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point2d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector4d; /** @@ -797,6 +797,8 @@ ArrayList<Integer> textureIdResourceFreeList = new ArrayList<Integer>(); // Max number of vertex attrs (not counting coord, etc.) int maxVertexAttrs = 0; + + int maxVaryingVectors = 0; // End of variables set by createNewContext()/createQueryContext() @@ -1230,16 +1232,15 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine if (!firstPaintCalled && added && validCanvas && validGraphicsMode()) { - final Graphics2D g2d = (Graphics2D) g; final AffineTransform t = g2d.getTransform(); try { - Dimension scaledSize = getSize(); - xscale = t.getScaleX(); - yscale = t.getScaleY(); - newSize = new Dimension((int)(scaledSize.getWidth()*xscale), (int)(scaledSize.getHeight()*yscale)); - newPosition = getLocationOnScreen(); + Dimension scaledSize = getSize(); + xscale = t.getScaleX(); + yscale = t.getScaleY(); + newSize = new Dimension((int)(scaledSize.getWidth()*xscale), (int)(scaledSize.getHeight()*yscale)); + newPosition = getLocationOnScreen(); } catch (IllegalComponentStateException e) { return; } @@ -1876,8 +1877,11 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine } } - if ((offScreenCanvasSize.width != width) || - (offScreenCanvasSize.height != height)) { + //PJ we MUST recreate the drawable when a new offscreen buffer is requested, as the previous is + // already realized and will fail on a createNewContext call + //if ((offScreenCanvasSize.width != width) || + // (offScreenCanvasSize.height != height)) + { if (drawable != null) { // Fix for Issue 18 and Issue 175 @@ -1897,9 +1901,9 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine } } - else if (ctx != null) { - removeCtx(); - } + //else if (ctx != null) { + // removeCtx(); + //} if (freeCanvasId) { sendFreeCanvasId(); @@ -3748,8 +3752,12 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine keys.add("textureImageUnitsCombinedMax"); values.add(new Integer(maxCombinedTextureImageUnits)); + keys.add("maxVaryingVectors"); + values.add(new Integer(maxVaryingVectors)); + keys.add("vertexAttrsMax"); values.add(new Integer(maxVertexAttrs)); + keys.add("shadingLanguageGLSL"); values.add(new Boolean(shadingLanguageGLSL)); diff --git a/src/javax/media/j3d/CanvasViewCache.java b/src/main/java/org/jogamp/java3d/CanvasViewCache.java index 0360d3c..8195302 100644 --- a/src/javax/media/j3d/CanvasViewCache.java +++ b/src/main/java/org/jogamp/java3d/CanvasViewCache.java @@ -24,17 +24,17 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Rectangle; -import javax.vecmath.Matrix4d; -import javax.vecmath.Point2d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.SingularMatrixException; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Matrix4d; +import org.jogamp.vecmath.Point2d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.SingularMatrixException; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector4d; /** * The CanvasViewCache class is used to cache all data, both API data diff --git a/src/javax/media/j3d/CanvasViewEventCatcher.java b/src/main/java/org/jogamp/java3d/CanvasViewEventCatcher.java index 478a84c..966f359 100644 --- a/src/javax/media/j3d/CanvasViewEventCatcher.java +++ b/src/main/java/org/jogamp/java3d/CanvasViewEventCatcher.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Dimension; import java.awt.IllegalComponentStateException; @@ -66,7 +66,7 @@ class CanvasViewEventCatcher extends ComponentAdapter { // see comment below try { - Dimension size = canvas.getSize(); + Dimension size = canvas.getSize(); canvas.newSize = new Dimension((int)(size.getWidth()*canvas.xscale), (int)(size.getHeight()*canvas.yscale)); canvas.newPosition = canvas.getLocationOnScreen(); } catch (IllegalComponentStateException ex) {} @@ -94,7 +94,7 @@ class CanvasViewEventCatcher extends ComponentAdapter { try { Dimension size = canvas.getSize(); canvas.newSize = new Dimension((int)(size.getWidth()*canvas.xscale), (int)(size.getHeight()*canvas.yscale)); - canvas.newPosition = canvas.getLocationOnScreen(); + canvas.newPosition = canvas.getLocationOnScreen(); } catch (IllegalComponentStateException ex) {} } diff --git a/src/javax/media/j3d/CapabilityBits.java b/src/main/java/org/jogamp/java3d/CapabilityBits.java index d601ff7..0e8ef07 100644 --- a/src/javax/media/j3d/CapabilityBits.java +++ b/src/main/java/org/jogamp/java3d/CapabilityBits.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * This CapabilityBits class provides a global namespace for all diff --git a/src/javax/media/j3d/CapabilityNotSetException.java b/src/main/java/org/jogamp/java3d/CapabilityNotSetException.java index f3f15d5..5cefd0d 100644 --- a/src/javax/media/j3d/CapabilityNotSetException.java +++ b/src/main/java/org/jogamp/java3d/CapabilityNotSetException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates an access to a live or diff --git a/src/javax/media/j3d/Clip.java b/src/main/java/org/jogamp/java3d/Clip.java index 427fb13..41c7eea 100644 --- a/src/javax/media/j3d/Clip.java +++ b/src/main/java/org/jogamp/java3d/Clip.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ClipRetained.java b/src/main/java/org/jogamp/java3d/ClipRetained.java index 78c4ae6..31c285b 100644 --- a/src/javax/media/j3d/ClipRetained.java +++ b/src/main/java/org/jogamp/java3d/ClipRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/ColorInterpolator.java b/src/main/java/org/jogamp/java3d/ColorInterpolator.java index 1377d7c..59ef505 100644 --- a/src/javax/media/j3d/ColorInterpolator.java +++ b/src/main/java/org/jogamp/java3d/ColorInterpolator.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * Color interpolation behavior. This class defines a behavior that @@ -168,11 +168,11 @@ public class ColorInterpolator extends Interpolator { * or specular color (or both the ambient and diffuse color) of * the specified target Material object with this new color value. * - * @param criteria an enumeration of the criteria that caused the + * @param criteria an iterator of the criteria that caused the * stimulus */ @Override - public void processStimulus(Enumeration criteria) { + public void processStimulus(Iterator<WakeupCriterion> criteria) { // Handle stimulus WakeupCriterion criterion = passiveWakeupCriterion; diff --git a/src/javax/media/j3d/ColoringAttributes.java b/src/main/java/org/jogamp/java3d/ColoringAttributes.java index 5596154..422fc5a 100644 --- a/src/javax/media/j3d/ColoringAttributes.java +++ b/src/main/java/org/jogamp/java3d/ColoringAttributes.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The ColoringAttributes object defines attributes used in @@ -348,7 +348,7 @@ public class ColoringAttributes extends NodeComponent { @Override public String toString() { StringBuffer str = new StringBuffer(getNamePrefix()); - str.append("javax.media.j3d.ColoringAttributes: "); + str.append("org.jogamp.java3d.ColoringAttributes: "); String shadingModes[] = { "FASTEST", "NICEST", "SHADE_FLAT", "SHADE_GOURAUD" }; diff --git a/src/javax/media/j3d/ColoringAttributesRetained.java b/src/main/java/org/jogamp/java3d/ColoringAttributesRetained.java index f419b1e..07b28f3 100644 --- a/src/javax/media/j3d/ColoringAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/ColoringAttributesRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The ColoringAttributesRetained object defines attributes that apply to diff --git a/src/javax/media/j3d/CompileState.java b/src/main/java/org/jogamp/java3d/CompileState.java index fdf777e..8e1b2fe 100644 --- a/src/javax/media/j3d/CompileState.java +++ b/src/main/java/org/jogamp/java3d/CompileState.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Collection; import java.util.HashMap; @@ -185,6 +185,10 @@ AppearanceRetained getAppearance(AppearanceRetained app) { Shape3DRetained[] shapes = new Shape3DRetained[numShapes]; curList.copyInto(shapes); Shape3DRetained[] toBeMergedShapes = new Shape3DRetained[numShapes]; +//must be at least 2 to try a merge + if(numShapes>1) + { + for (int i = 0; i < numShapes; i++) { if (shapes[i] == null) { continue; @@ -286,6 +290,7 @@ AppearanceRetained getAppearance(AppearanceRetained app) { } } } + } // Clear the shapelists for the next merge shapeLists.clear(); diff --git a/src/javax/media/j3d/CompressedGeometry.java b/src/main/java/org/jogamp/java3d/CompressedGeometry.java index a595f1c..c92ec9c 100644 --- a/src/javax/media/j3d/CompressedGeometry.java +++ b/src/main/java/org/jogamp/java3d/CompressedGeometry.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The compressed geometry object is used to store geometry in a diff --git a/src/javax/media/j3d/CompressedGeometryHeader.java b/src/main/java/org/jogamp/java3d/CompressedGeometryHeader.java index 33b1742..5b1febe 100644 --- a/src/javax/media/j3d/CompressedGeometryHeader.java +++ b/src/main/java/org/jogamp/java3d/CompressedGeometryHeader.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * The CompressedGeometrHeader object is used in conjunction with diff --git a/src/javax/media/j3d/CompressedGeometryRenderMethod.java b/src/main/java/org/jogamp/java3d/CompressedGeometryRenderMethod.java index 6633b57..491afdb 100644 --- a/src/javax/media/j3d/CompressedGeometryRenderMethod.java +++ b/src/main/java/org/jogamp/java3d/CompressedGeometryRenderMethod.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d ; +package org.jogamp.java3d; /** * The RenderMethod interface is used to create various ways to render * different geometries. */ - +@Deprecated class CompressedGeometryRenderMethod implements RenderMethod { /** diff --git a/src/javax/media/j3d/CompressedGeometryRetained.java b/src/main/java/org/jogamp/java3d/CompressedGeometryRetained.java index aba0277..8c13acd 100644 --- a/src/javax/media/j3d/CompressedGeometryRetained.java +++ b/src/main/java/org/jogamp/java3d/CompressedGeometryRetained.java @@ -24,8 +24,8 @@ * */ -package javax.media.j3d ; -import javax.vecmath.Point3d; +package org.jogamp.java3d; +import org.jogamp.vecmath.Point3d; /** * The compressed geometry object is used to store geometry in a @@ -35,6 +35,7 @@ import javax.vecmath.Point3d; * hardware support becomes available, increased rendering performance * will also result from the use of compressed geometry. */ +@Deprecated class CompressedGeometryRetained extends GeometryRetained { // If not in by-reference mode, a 48-byte header as defined by the @@ -57,7 +58,7 @@ class CompressedGeometryRetained extends GeometryRetained { private static final int HEADER_BUFFER_DATA_OFFSET = 4 ; // The OpenGL compressed geometry extensions use bits instead of - // enumerations to represent the type of compressed geometry. + // iterators to represent the type of compressed geometry. static final byte TYPE_POINT = 1 ; static final byte TYPE_LINE = 2 ; static final byte TYPE_TRIANGLE = 4 ; diff --git a/src/javax/media/j3d/ConeSound.java b/src/main/java/org/jogamp/java3d/ConeSound.java index b2f2629..133e519 100644 --- a/src/javax/media/j3d/ConeSound.java +++ b/src/main/java/org/jogamp/java3d/ConeSound.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** diff --git a/src/javax/media/j3d/ConeSoundRetained.java b/src/main/java/org/jogamp/java3d/ConeSoundRetained.java index 514f172..d1f3523 100644 --- a/src/javax/media/j3d/ConeSoundRetained.java +++ b/src/main/java/org/jogamp/java3d/ConeSoundRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; diff --git a/src/javax/media/j3d/Context.java b/src/main/java/org/jogamp/java3d/Context.java index ee25ed3..13ebf73 100644 --- a/src/javax/media/j3d/Context.java +++ b/src/main/java/org/jogamp/java3d/Context.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Tagging interface for graphics context objects. The rendering pipelines diff --git a/src/javax/media/j3d/DanglingReferenceException.java b/src/main/java/org/jogamp/java3d/DanglingReferenceException.java index 076a9a0..c57994e 100644 --- a/src/javax/media/j3d/DanglingReferenceException.java +++ b/src/main/java/org/jogamp/java3d/DanglingReferenceException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * During a <code>cloneTree</code> call an updated reference was requested diff --git a/src/javax/media/j3d/DecalGroup.java b/src/main/java/org/jogamp/java3d/DecalGroup.java index a153903..5b10dee 100644 --- a/src/javax/media/j3d/DecalGroup.java +++ b/src/main/java/org/jogamp/java3d/DecalGroup.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/DecalGroupRetained.java b/src/main/java/org/jogamp/java3d/DecalGroupRetained.java index 3d0d4fa..029c745 100644 --- a/src/javax/media/j3d/DecalGroupRetained.java +++ b/src/main/java/org/jogamp/java3d/DecalGroupRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class DecalGroupRetained extends OrderedGroupRetained { diff --git a/src/javax/media/j3d/DefaultRenderMethod.java b/src/main/java/org/jogamp/java3d/DefaultRenderMethod.java index 61a4ed0..a608178 100644 --- a/src/javax/media/j3d/DefaultRenderMethod.java +++ b/src/main/java/org/jogamp/java3d/DefaultRenderMethod.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The RenderMethod interface is used to create various ways to render diff --git a/src/javax/media/j3d/DepthComponent.java b/src/main/java/org/jogamp/java3d/DepthComponent.java index 02994fb..dd32f36 100644 --- a/src/javax/media/j3d/DepthComponent.java +++ b/src/main/java/org/jogamp/java3d/DepthComponent.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Abstract base class that defines a 2D array of depth (Z) values. diff --git a/src/javax/media/j3d/DepthComponentFloat.java b/src/main/java/org/jogamp/java3d/DepthComponentFloat.java index 3a304c5..6043142 100644 --- a/src/javax/media/j3d/DepthComponentFloat.java +++ b/src/main/java/org/jogamp/java3d/DepthComponentFloat.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A 2D array of depth (Z) values in floating point format in the range [0,1]. diff --git a/src/javax/media/j3d/DepthComponentFloatRetained.java b/src/main/java/org/jogamp/java3d/DepthComponentFloatRetained.java index 24290bd..97d6b6c 100644 --- a/src/javax/media/j3d/DepthComponentFloatRetained.java +++ b/src/main/java/org/jogamp/java3d/DepthComponentFloatRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/DepthComponentInt.java b/src/main/java/org/jogamp/java3d/DepthComponentInt.java index 34963ea..9010da3 100644 --- a/src/javax/media/j3d/DepthComponentInt.java +++ b/src/main/java/org/jogamp/java3d/DepthComponentInt.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A 2D array of depth (Z) values in integer format. Values are in the diff --git a/src/javax/media/j3d/DepthComponentIntRetained.java b/src/main/java/org/jogamp/java3d/DepthComponentIntRetained.java index a382da7..b89eb92 100644 --- a/src/javax/media/j3d/DepthComponentIntRetained.java +++ b/src/main/java/org/jogamp/java3d/DepthComponentIntRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/DepthComponentNative.java b/src/main/java/org/jogamp/java3d/DepthComponentNative.java index 070d00c..4ff8d5e 100644 --- a/src/javax/media/j3d/DepthComponentNative.java +++ b/src/main/java/org/jogamp/java3d/DepthComponentNative.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A 2D array of depth (Z) values stored in the most efficient format for a diff --git a/src/javax/media/j3d/DepthComponentNativeRetained.java b/src/main/java/org/jogamp/java3d/DepthComponentNativeRetained.java index 220a328..7da5390 100644 --- a/src/javax/media/j3d/DepthComponentNativeRetained.java +++ b/src/main/java/org/jogamp/java3d/DepthComponentNativeRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A 2D array of depth (Z) values stored in the most efficient format for a diff --git a/src/javax/media/j3d/DepthComponentRetained.java b/src/main/java/org/jogamp/java3d/DepthComponentRetained.java index d28ab87..e9997e0 100644 --- a/src/javax/media/j3d/DepthComponentRetained.java +++ b/src/main/java/org/jogamp/java3d/DepthComponentRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Abstract base class that defines a 2D array of depth (Z) values. diff --git a/src/javax/media/j3d/DirectionalLight.java b/src/main/java/org/jogamp/java3d/DirectionalLight.java index 69b4a46..2bd1b97 100644 --- a/src/javax/media/j3d/DirectionalLight.java +++ b/src/main/java/org/jogamp/java3d/DirectionalLight.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Vector3f; /** * A DirectionalLight node defines an oriented light with an origin at diff --git a/src/javax/media/j3d/DirectionalLightRetained.java b/src/main/java/org/jogamp/java3d/DirectionalLightRetained.java index 325762b..e75a663 100644 --- a/src/javax/media/j3d/DirectionalLightRetained.java +++ b/src/main/java/org/jogamp/java3d/DirectionalLightRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Vector3f; /** * An infinite directional light source object. diff --git a/src/javax/media/j3d/DisplayListRenderMethod.java b/src/main/java/org/jogamp/java3d/DisplayListRenderMethod.java index a5c3233..e88d8d9 100644 --- a/src/javax/media/j3d/DisplayListRenderMethod.java +++ b/src/main/java/org/jogamp/java3d/DisplayListRenderMethod.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The RenderMethod interface is used to create various ways to render diff --git a/src/javax/media/j3d/DistanceLOD.java b/src/main/java/org/jogamp/java3d/DistanceLOD.java index 244c06a..1664109 100644 --- a/src/javax/media/j3d/DistanceLOD.java +++ b/src/main/java/org/jogamp/java3d/DistanceLOD.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point3f; /** * This class defines a distance-based LOD behavior node that operates on @@ -171,11 +171,11 @@ public class DistanceLOD extends LOD { /** * Process stimulus method that computes appropriate level of detail. - * @param criteria an enumeration of the criteria that caused the + * @param criteria an iterator of the criteria that caused the * stimulus */ @Override - public void processStimulus(Enumeration criteria) { + public void processStimulus(Iterator<WakeupCriterion> criteria) { // compute distance in virtual world diff --git a/src/javax/media/j3d/Drawable.java b/src/main/java/org/jogamp/java3d/Drawable.java index 833b6cd..b5156a6 100644 --- a/src/javax/media/j3d/Drawable.java +++ b/src/main/java/org/jogamp/java3d/Drawable.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Tagging interface for drawable (window) objects. The rendering pipelines diff --git a/src/javax/media/j3d/DrawingSurfaceObject.java b/src/main/java/org/jogamp/java3d/DrawingSurfaceObject.java index 3d2c591..f9ad0b5 100644 --- a/src/javax/media/j3d/DrawingSurfaceObject.java +++ b/src/main/java/org/jogamp/java3d/DrawingSurfaceObject.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The DrawingSurfaceObject class is used to manage native drawing surface diff --git a/src/javax/media/j3d/EnvironmentSet.java b/src/main/java/org/jogamp/java3d/EnvironmentSet.java index ab22747..42d2f5a 100644 --- a/src/javax/media/j3d/EnvironmentSet.java +++ b/src/main/java/org/jogamp/java3d/EnvironmentSet.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The LightBin manages a collection of EnvironmentSet objects. diff --git a/src/javax/media/j3d/EventCatcher.java b/src/main/java/org/jogamp/java3d/EventCatcher.java index d0e561f..594c9db 100644 --- a/src/javax/media/j3d/EventCatcher.java +++ b/src/main/java/org/jogamp/java3d/EventCatcher.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; diff --git a/src/javax/media/j3d/ExponentialFog.java b/src/main/java/org/jogamp/java3d/ExponentialFog.java index bc24ee3..fe526f0 100644 --- a/src/javax/media/j3d/ExponentialFog.java +++ b/src/main/java/org/jogamp/java3d/ExponentialFog.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The ExponentialFog leaf node extends the Fog leaf node by adding a diff --git a/src/javax/media/j3d/ExponentialFogRetained.java b/src/main/java/org/jogamp/java3d/ExponentialFogRetained.java index e4c0945..1f3928e 100644 --- a/src/javax/media/j3d/ExponentialFogRetained.java +++ b/src/main/java/org/jogamp/java3d/ExponentialFogRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The ExponentialFog leaf node defines distance parameters for diff --git a/src/javax/media/j3d/Fog.java b/src/main/java/org/jogamp/java3d/Fog.java index 58557a9..16c0c48 100644 --- a/src/javax/media/j3d/Fog.java +++ b/src/main/java/org/jogamp/java3d/Fog.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The Fog leaf node defines a set of fog parameters common to all @@ -349,13 +349,13 @@ public abstract class Fog extends Leaf { /** - * Returns an enumeration of this Fog node's list of scopes. - * @return an Enumeration object containing all nodes in this Fog node's + * Returns an iterator of this Fog node's list of scopes. + * @return an Iterator object containing all nodes in this Fog node's * list of scopes. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ -public Enumeration<Group> getAllScopes() { +public Iterator<Group> getAllScopes() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_SCOPE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Fog11")); @@ -511,10 +511,10 @@ public Enumeration<Group> getAllScopes() { rt.initColor(c); rt.initInfluencingBounds(attr.getInfluencingBounds()); - Enumeration<Group> elm = attr.getAllScopes(); - while (elm.hasMoreElements()) { + Iterator<Group> elm = attr.getAllScopes(); + while (elm.hasNext()) { // this reference will set correctly in updateNodeReferences() callback - rt.initAddScope(elm.nextElement()); + rt.initAddScope(elm.next()); } // this reference will set correctly in updateNodeReferences() callback diff --git a/src/javax/media/j3d/FogRetained.java b/src/main/java/org/jogamp/java3d/FogRetained.java index 32cfae5..104caeb 100644 --- a/src/javax/media/j3d/FogRetained.java +++ b/src/main/java/org/jogamp/java3d/FogRetained.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The Fog leaf node defines Fog parameters. @@ -331,16 +331,16 @@ Vector<GroupRetained> scopes = new Vector<GroupRetained>(); } /** - * Returns an enumeration object of the scoperen. - * @return an enumeration object of the scoperen + * Returns an iterator object of the scoperen. + * @return an iterator object of the scoperen */ -Enumeration<Group> getAllScopes() { - Enumeration<GroupRetained> elm = scopes.elements(); +Iterator<Group> getAllScopes() { + Iterator<GroupRetained> elm = scopes.iterator(); Vector<Group> v = new Vector<Group>(scopes.size()); - while (elm.hasMoreElements()) { - v.add((Group)elm.nextElement().source); + while (elm.hasNext()) { + v.add((Group)elm.next().source); } - return v.elements(); + return v.iterator(); } /** diff --git a/src/javax/media/j3d/Font3D.java b/src/main/java/org/jogamp/java3d/Font3D.java index 0d7c631..34326cf 100644 --- a/src/javax/media/j3d/Font3D.java +++ b/src/main/java/org/jogamp/java3d/Font3D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Font; import java.awt.Shape; @@ -40,9 +40,9 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.ServiceLoader; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * The Font3D object is used to store extruded 2D glyphs. These diff --git a/src/javax/media/j3d/FontExtrusion.java b/src/main/java/org/jogamp/java3d/FontExtrusion.java index d326154..84520ce 100644 --- a/src/javax/media/j3d/FontExtrusion.java +++ b/src/main/java/org/jogamp/java3d/FontExtrusion.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Shape; import java.awt.geom.PathIterator; import java.util.ArrayList; -import javax.vecmath.Point2f; +import org.jogamp.vecmath.Point2f; /** * The FontExtrusion object is used to describe the extrusion path diff --git a/src/javax/media/j3d/FreeListManager.java b/src/main/java/org/jogamp/java3d/FreeListManager.java index 83e2c66..7d1f93a 100644 --- a/src/javax/media/j3d/FreeListManager.java +++ b/src/main/java/org/jogamp/java3d/FreeListManager.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class FreeListManager { diff --git a/src/main/java/org/jogamp/java3d/GLSLShaderProgram.java b/src/main/java/org/jogamp/java3d/GLSLShaderProgram.java new file mode 100644 index 0000000..b8b0c43 --- /dev/null +++ b/src/main/java/org/jogamp/java3d/GLSLShaderProgram.java @@ -0,0 +1,282 @@ +/* + * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +package org.jogamp.java3d; + + +/** + * The GLSLShaderProgram object is a concrete implementation of a + * ShaderProgram node component for the OpenGL GLSL shading language. + * + * @see SourceCodeShader + * + * @since Java 3D 1.4 + */ + +public class GLSLShaderProgram extends ShaderProgram +{ + + /** + * Constructs a GLSL shader program node component. + * + * <br> + * TODO: ADD MORE DOCUMENTATION HERE. + */ + public GLSLShaderProgram() + { + } + + // Implement abstract setVertexAttrNames method (inherit javadoc from parent class) + @Override + public void setVertexAttrNames(String[] vertexAttrNames) + { + checkForLiveOrCompiled(); + + if (vertexAttrNames != null) + { + for (int i = 0; i < vertexAttrNames.length; i++) + { + if (vertexAttrNames[i] == null) + { + throw new NullPointerException(); + } + } + } + + ((GLSLShaderProgramRetained) this.retained).setVertexAttrNames(vertexAttrNames); + } + + // Implement abstract getVertexAttrNames method (inherit javadoc from parent class) + @Override + public String[] getVertexAttrNames() + { + + if (isLiveOrCompiled()) + { + if (!this.getCapability(ALLOW_NAMES_READ)) + { + throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram0")); + } + } + + return ((GLSLShaderProgramRetained) this.retained).getVertexAttrNames(); + + } + + // Implement abstract setShaderAttrNames method (inherit javadoc from parent class) + @Override + public void setShaderAttrNames(String[] shaderAttrNames) + { + checkForLiveOrCompiled(); + + if (shaderAttrNames != null) + { + for (int i = 0; i < shaderAttrNames.length; i++) + { + if (shaderAttrNames[i] == null) + { + throw new NullPointerException(); + } + } + } + + ((GLSLShaderProgramRetained) this.retained).setShaderAttrNames(shaderAttrNames); + } + + // Implement abstract getShaderAttrNames method (inherit javadoc from parent class) + @Override + public String[] getShaderAttrNames() + { + + if (isLiveOrCompiled()) + { + if (!this.getCapability(ALLOW_NAMES_READ)) + { + throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram0")); + } + } + + return ((GLSLShaderProgramRetained) this.retained).getShaderAttrNames(); + + } + + /** + * Copies the specified array of shaders into this shader + * program. This method makes a shallow copy of the array. The + * array of shaders may be null or empty (0 length), but the + * elements of the array must be non-null. The shading language of + * each shader in the array must be + * <code>SHADING_LANGUAGE_GLSL</code>. Each shader in the array must + * be a SourceCodeShader. + * + * @param shaders array of Shader objects to be copied into this + * ShaderProgram + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception IllegalArgumentException if the shading language of + * any shader in the shaders array is <em>not</em> + * <code>SHADING_LANGUAGE_GLSL</code>. + * + * @exception ClassCastException if any shader in the shaders + * array is <em>not</em> a SourceCodeShader. + * + * @exception NullPointerException if any element in the + * shaders array is null. + */ + @Override + public void setShaders(Shader[] shaders) + { + checkForLiveOrCompiled(); + + if (shaders != null) + { + // Check shaders for valid shading language and class type + for (int i = 0; i < shaders.length; i++) + { + if (shaders[i].getShadingLanguage() != Shader.SHADING_LANGUAGE_GLSL) + { + throw new IllegalArgumentException(J3dI18N.getString("GLSLShaderProgram2")); + } + + // Try to cast shader to SourceCodeShader; it will throw + // ClassCastException if it isn't. + SourceCodeShader shad = (SourceCodeShader) shaders[i]; + } + + } + + ((GLSLShaderProgramRetained) this.retained).setShaders(shaders); + } + + // Implement abstract getShaders method (inherit javadoc from parent class) + @Override + public Shader[] getShaders() + { + + if (isLiveOrCompiled()) + { + if (!this.getCapability(ALLOW_SHADERS_READ)) + { + throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram1")); + } + } + + return ((GLSLShaderProgramRetained) this.retained).getShaders(); + } + + /** + * Creates a retained mode GLSLShaderProgramRetained object that this + * GLSLShaderProgram component object will point to. + */ + @Override + void createRetained() + { + this.retained = new GLSLShaderProgramRetained(); + this.retained.setSource(this); + } + + /** + * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) + */ + @Override + public NodeComponent cloneNodeComponent() + { + GLSLShaderProgram a = new GLSLShaderProgram(); + a.duplicateNodeComponent(this); + return a; + } + + /** + * NOTE: Applications should <i>not</i> call this method directly. + * It should only be called by the cloneNode method. + * + * @deprecated replaced with duplicateNodeComponent( + * NodeComponent originalNodeComponent, boolean forceDuplicate) + */ + @Override + public void duplicateNodeComponent(NodeComponent originalNodeComponent) + { + checkDuplicateNodeComponent(originalNodeComponent); + } + + /** + * Copies all ShaderAppearance information from + * <code>originalNodeComponent</code> into + * the current node. This method is called from the + * <code>cloneNode</code> method which is, in turn, called by the + * <code>cloneTree</code> method.<P> + * + * @param originalNodeComponent the original node to duplicate. + * @param forceDuplicate when set to <code>true</code>, causes the + * <code>duplicateOnCloneTree</code> flag to be ignored. When + * <code>false</code>, the value of each node's + * <code>duplicateOnCloneTree</code> variable determines whether + * NodeComponent data is duplicated or copied. + * + * @exception RestrictedAccessException if this object is part of a live + * or compiled scenegraph. + * + * @see Node#cloneTree + * @see NodeComponent#setDuplicateOnCloneTree + */ + @Override + void duplicateAttributes(NodeComponent originalNodeComponent, boolean forceDuplicate) + { + super.duplicateAttributes(originalNodeComponent, forceDuplicate); + + //Hashtable hashtable = originalNodeComponent.nodeHashtable; + + GLSLShaderProgramRetained orig = (GLSLShaderProgramRetained) originalNodeComponent.retained; + + GLSLShaderProgramRetained rt = (GLSLShaderProgramRetained) retained; + + rt.setVertexAttrNames(orig.getVertexAttrNames()); + rt.setShaderAttrNames(orig.getShaderAttrNames()); + rt.setShaders(orig.getShaders()); + } + + /** + * This function is called from getNodeComponent() to see if any of + * the sub-NodeComponents duplicateOnCloneTree flag is true. + * If it is the case, current NodeComponent needs to + * duplicate also even though current duplicateOnCloneTree flag is false. + * This should be overwrite by NodeComponent which contains sub-NodeComponent. + */ + @Override + boolean duplicateChild() + { + if (super.duplicateChild()) + return true; + + if (getDuplicateOnCloneTree()) + return true; + + // we have no node components + return false; + } +} diff --git a/src/javax/media/j3d/GLSLShaderProgramRetained.java b/src/main/java/org/jogamp/java3d/GLSLShaderProgramRetained.java index d1c7614..fa1ccf7 100644 --- a/src/javax/media/j3d/GLSLShaderProgramRetained.java +++ b/src/main/java/org/jogamp/java3d/GLSLShaderProgramRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The GLSLShaderProgram object is a concrete implementation of a diff --git a/src/javax/media/j3d/GeneralizedStrip.java b/src/main/java/org/jogamp/java3d/GeneralizedStrip.java index baddedf..f27ed88 100644 --- a/src/javax/media/j3d/GeneralizedStrip.java +++ b/src/main/java/org/jogamp/java3d/GeneralizedStrip.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** @@ -39,6 +39,7 @@ package javax.media.j3d; * @see GeneralizedVertexList * @see GeometryDecompressor */ +@Deprecated class GeneralizedStrip { private static final boolean debug = false ; diff --git a/src/javax/media/j3d/GeneralizedStripFlags.java b/src/main/java/org/jogamp/java3d/GeneralizedStripFlags.java index 330342d..ab0e9f2 100644 --- a/src/javax/media/j3d/GeneralizedStripFlags.java +++ b/src/main/java/org/jogamp/java3d/GeneralizedStripFlags.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A class which implements GeneralizedStripFlags provides the means to access @@ -36,6 +36,7 @@ package javax.media.j3d; * @see GeneralizedStrip * @see GeneralizedVertexList */ +@Deprecated interface GeneralizedStripFlags { /** diff --git a/src/javax/media/j3d/GeneralizedVertexList.java b/src/main/java/org/jogamp/java3d/GeneralizedVertexList.java index 26a225b..d1a3030 100644 --- a/src/javax/media/j3d/GeneralizedVertexList.java +++ b/src/main/java/org/jogamp/java3d/GeneralizedVertexList.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3f; -import javax.vecmath.Color4f; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * The GeneralizedVertexList class is a variable-size list used to @@ -43,6 +43,7 @@ import javax.vecmath.Vector3f; * @see GeneralizedStrip * @see GeometryDecompressor */ +@Deprecated class GeneralizedVertexList implements GeneralizedStripFlags { // The ArrayList containing the vertices. diff --git a/src/javax/media/j3d/Geometry.java b/src/main/java/org/jogamp/java3d/Geometry.java index ac6b3cf..efd968a 100644 --- a/src/javax/media/j3d/Geometry.java +++ b/src/main/java/org/jogamp/java3d/Geometry.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Geometry is an abstract class that specifies the geometry diff --git a/src/javax/media/j3d/GeometryArray.java b/src/main/java/org/jogamp/java3d/GeometryArray.java index f830acc..04ac530 100644 --- a/src/javax/media/j3d/GeometryArray.java +++ b/src/main/java/org/jogamp/java3d/GeometryArray.java @@ -24,20 +24,20 @@ * */ -package javax.media.j3d; - -import javax.vecmath.Color3b; -import javax.vecmath.Color3f; -import javax.vecmath.Color4b; -import javax.vecmath.Color4f; -import javax.vecmath.Point2f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Point4f; -import javax.vecmath.TexCoord2f; -import javax.vecmath.TexCoord3f; -import javax.vecmath.TexCoord4f; -import javax.vecmath.Vector3f; +package org.jogamp.java3d; + +import org.jogamp.vecmath.Color3b; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Color4b; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Point4f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.TexCoord3f; +import org.jogamp.vecmath.TexCoord4f; +import org.jogamp.vecmath.Vector3f; /** diff --git a/src/javax/media/j3d/GeometryArrayRetained.java b/src/main/java/org/jogamp/java3d/GeometryArrayRetained.java index 53a691a..e6731c2 100644 --- a/src/javax/media/j3d/GeometryArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/GeometryArrayRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -35,21 +35,21 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import javax.vecmath.Color3b; -import javax.vecmath.Color3f; -import javax.vecmath.Color4b; -import javax.vecmath.Color4f; -import javax.vecmath.Point2d; -import javax.vecmath.Point2f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Point4d; -import javax.vecmath.Point4f; -import javax.vecmath.TexCoord2f; -import javax.vecmath.TexCoord3f; -import javax.vecmath.TexCoord4f; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Color3b; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Color4b; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point2d; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Point4f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.TexCoord3f; +import org.jogamp.vecmath.TexCoord4f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** @@ -412,7 +412,24 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; if (this.refCount <= 0) { isShared = false; } - } + //PJ: big ugly hack for buffers + // only Jogl2es2Pipeline uses buffers + if(Pipeline.getPipeline() instanceof Jogl2es2Pipeline) + { + for(Context ctx: ctxExecutedOn) + { + ((Jogl2es2Pipeline)Pipeline.getPipeline()).registerClearBuffers(ctx, this); + } + } + + ctxExecutedOn.clear(); + prevContext = null; + } + + //PJ: big ugly hack for buffers + protected HashSet<Context> ctxExecutedOn = new HashSet<Context>(); + protected Context prevContext = null; // as I only expect one check versus prev to see if something new is come along + @Override void computeBoundingBox() { @@ -2196,6 +2213,13 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; int screen, boolean ignoreVertexColors) { + //PJ: big ugly hack for buffers + if(cv.ctx != prevContext) + { + ctxExecutedOn.add(cv.ctx); + prevContext = cv.ctx; + } + int cdirty; boolean useAlpha = false; Object[] retVal; @@ -3439,9 +3463,9 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; } - + J3dMessage[] m; void sendDataChangedMessage(boolean coordinatesChanged) { - J3dMessage[] m; + int i, j, k, numShapeMessages, numMorphMessages; synchronized(liveStateLock) { @@ -3459,6 +3483,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; synchronized (universeList) { numShapeMessages = universeList.size(); + if(m==null||m.length<numShapeMessages) m = new J3dMessage[numShapeMessages]; k = 0; @@ -3490,6 +3515,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; gaList.add(Shape3DRetained.getGeomAtom(s)); } + if(m[k]==null) m[k] = new J3dMessage(); m[k].type = J3dMessage.GEOMETRY_CHANGED; diff --git a/src/javax/media/j3d/GeometryAtom.java b/src/main/java/org/jogamp/java3d/GeometryAtom.java index a4351ef..3eea147 100644 --- a/src/javax/media/j3d/GeometryAtom.java +++ b/src/main/java/org/jogamp/java3d/GeometryAtom.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * A GeometryAtom is the smallest object representing Geometry. diff --git a/src/javax/media/j3d/GeometryDecompressor.java b/src/main/java/org/jogamp/java3d/GeometryDecompressor.java index 7a5bfd8..7d24de7 100644 --- a/src/javax/media/j3d/GeometryDecompressor.java +++ b/src/main/java/org/jogamp/java3d/GeometryDecompressor.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; -import javax.vecmath.Color4f; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +package org.jogamp.java3d; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * This abstract class provides the base methods needed to create a geometry @@ -35,6 +35,7 @@ import javax.vecmath.Vector3f; * consisting of a generalized triangle strip, line strip, or point array, * along with possible global color and normal changes. */ +@Deprecated abstract class GeometryDecompressor { private static final boolean debug = false ; private static final boolean benchmark = false ; diff --git a/src/javax/media/j3d/GeometryDecompressorRetained.java b/src/main/java/org/jogamp/java3d/GeometryDecompressorRetained.java index 41ae770..a3dfc59 100644 --- a/src/javax/media/j3d/GeometryDecompressorRetained.java +++ b/src/main/java/org/jogamp/java3d/GeometryDecompressorRetained.java @@ -24,16 +24,17 @@ * */ -package javax.media.j3d; -import javax.vecmath.Color4f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +package org.jogamp.java3d; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * This class implements a retained geometry backend for the abstract * GeometryDecompressor. */ +@Deprecated class GeometryDecompressorRetained extends GeometryDecompressor { private static final boolean debug = false ; private static final boolean benchmark = false ; diff --git a/src/javax/media/j3d/GeometryDecompressorShape3D.java b/src/main/java/org/jogamp/java3d/GeometryDecompressorShape3D.java index 4854b8c..1cab7d9 100644 --- a/src/javax/media/j3d/GeometryDecompressorShape3D.java +++ b/src/main/java/org/jogamp/java3d/GeometryDecompressorShape3D.java @@ -24,17 +24,18 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color4f; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * This class implements a Shape3D backend for the abstract * GeometryDecompressor. */ +@Deprecated class GeometryDecompressorShape3D extends GeometryDecompressor { private static final boolean debug = false ; private static final boolean benchmark = false ; diff --git a/src/javax/media/j3d/GeometryLock.java b/src/main/java/org/jogamp/java3d/GeometryLock.java index bb1132c..fc98b25 100644 --- a/src/javax/media/j3d/GeometryLock.java +++ b/src/main/java/org/jogamp/java3d/GeometryLock.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class GeometryLock { diff --git a/src/javax/media/j3d/GeometryRetained.java b/src/main/java/org/jogamp/java3d/GeometryRetained.java index 7f9fded..78d1580 100644 --- a/src/javax/media/j3d/GeometryRetained.java +++ b/src/main/java/org/jogamp/java3d/GeometryRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; abstract class GeometryRetained extends NodeComponentRetained { diff --git a/src/javax/media/j3d/GeometryService.java b/src/main/java/org/jogamp/java3d/GeometryService.java index 346087c..4ce5af0 100644 --- a/src/javax/media/j3d/GeometryService.java +++ b/src/main/java/org/jogamp/java3d/GeometryService.java @@ -1,9 +1,9 @@ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point3f; /** * A service interface for certain geometric operations that are not available diff --git a/src/javax/media/j3d/GeometryStripArray.java b/src/main/java/org/jogamp/java3d/GeometryStripArray.java index 02db947..cb32b3d 100644 --- a/src/javax/media/j3d/GeometryStripArray.java +++ b/src/main/java/org/jogamp/java3d/GeometryStripArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The GeometryStripArray object is an abstract class that is extended for diff --git a/src/javax/media/j3d/GeometryStripArrayRetained.java b/src/main/java/org/jogamp/java3d/GeometryStripArrayRetained.java index f08c9e9..2168c04 100644 --- a/src/javax/media/j3d/GeometryStripArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/GeometryStripArrayRetained.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.nio.FloatBuffer; import java.util.ArrayList; -import javax.vecmath.TexCoord2f; -import javax.vecmath.TexCoord3f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.TexCoord3f; /** diff --git a/src/javax/media/j3d/GeometryStructure.java b/src/main/java/org/jogamp/java3d/GeometryStructure.java index 2fd5578..fe16c12 100644 --- a/src/javax/media/j3d/GeometryStructure.java +++ b/src/main/java/org/jogamp/java3d/GeometryStructure.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3d; /** diff --git a/src/javax/media/j3d/GeometryUpdater.java b/src/main/java/org/jogamp/java3d/GeometryUpdater.java index 1d8a445..1813b33 100644 --- a/src/javax/media/j3d/GeometryUpdater.java +++ b/src/main/java/org/jogamp/java3d/GeometryUpdater.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/GraphStructureChangeListener.java b/src/main/java/org/jogamp/java3d/GraphStructureChangeListener.java index ff440cd..0a1b316 100644 --- a/src/javax/media/j3d/GraphStructureChangeListener.java +++ b/src/main/java/org/jogamp/java3d/GraphStructureChangeListener.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Listener interface for monitoring structural changes to live scene diff --git a/src/javax/media/j3d/GraphicsConfigInfo.java b/src/main/java/org/jogamp/java3d/GraphicsConfigInfo.java index 8483b83..65f6e2e 100644 --- a/src/javax/media/j3d/GraphicsConfigInfo.java +++ b/src/main/java/org/jogamp/java3d/GraphicsConfigInfo.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Container for the GraphicsTemplate3D and other private data about a selected diff --git a/src/javax/media/j3d/GraphicsConfigTemplate3D.java b/src/main/java/org/jogamp/java3d/GraphicsConfigTemplate3D.java index 757f5a6..e92f510 100644 --- a/src/javax/media/j3d/GraphicsConfigTemplate3D.java +++ b/src/main/java/org/jogamp/java3d/GraphicsConfigTemplate3D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.GraphicsConfigTemplate; import java.awt.GraphicsConfiguration; diff --git a/src/javax/media/j3d/GraphicsContext3D.java b/src/main/java/org/jogamp/java3d/GraphicsContext3D.java index b6eb1c5..2595d8c 100644 --- a/src/javax/media/j3d/GraphicsContext3D.java +++ b/src/main/java/org/jogamp/java3d/GraphicsContext3D.java @@ -24,15 +24,15 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Dimension; import java.awt.Point; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; -import javax.vecmath.Color3f; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Vector3d; /** * A GraphicsContext3D object is used for immediate mode rendering into @@ -963,11 +963,11 @@ public Light getLight(int index) { } /** - * Retrieves the enumeration object of all the lights. - * @return the enumeration object of all the lights + * Retrieves the iterator object of all the lights. + * @return the iterator object of all the lights */ -public Enumeration<Light> getAllLights() { - return uLights.elements(); +public Iterator<Light> getAllLights() { + return uLights.iterator(); } /** @@ -1329,11 +1329,11 @@ public Sound getSound(int index) { } /** - * Retrieves the enumeration object of all the sounds. - * @return the enumeration object of all the sounds + * Retrieves the iterator object of all the sounds. + * @return the iterator object of all the sounds */ -public Enumeration<Sound> getAllSounds() { - return uSounds.elements(); +public Iterator<Sound> getAllSounds() { + return uSounds.iterator(); } /** @@ -1731,9 +1731,6 @@ public int numSounds() { return; } - // createNewContext finishes with a release, re-make current so the init calls below work - canvas3d.makeCtxCurrent(); - canvas3d.ctxTimeStamp = VirtualUniverse.mc.getContextTimeStamp(); canvas3d.screen.renderer.listOfCtxs.add(canvas3d.ctx); diff --git a/src/javax/media/j3d/Group.java b/src/main/java/org/jogamp/java3d/Group.java index 11dee57..f5fce2a 100644 --- a/src/javax/media/j3d/Group.java +++ b/src/main/java/org/jogamp/java3d/Group.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Hashtable; /** @@ -242,12 +242,12 @@ public class Group extends Node { } /** - * Returns an Enumeration object of this group node's list of children. - * @return an Enumeration object of all the children + * Returns an Iterator object of this group node's list of children. + * @return an Iterator object of all the children * @exception CapabilityNotSetException if the appropriate capability is * not set and this group node is part of live or compiled scene graph */ - public Enumeration<Node> getAllChildren() { + public Iterator<Node> getAllChildren() { if (isLiveOrCompiled() && !this.getCapability(ALLOW_CHILDREN_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Group9")); diff --git a/src/javax/media/j3d/GroupRetained.java b/src/main/java/org/jogamp/java3d/GroupRetained.java index 826a989..8ecf6d8 100644 --- a/src/javax/media/j3d/GroupRetained.java +++ b/src/main/java/org/jogamp/java3d/GroupRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; /** @@ -438,10 +438,10 @@ ArrayList<ArrayList<View>> viewLists = null; } /** - * Returns an enumeration object of the children. - * @return an enumeration object of the children + * Returns an iterator object of the children. + * @return an iterator object of the children */ - Enumeration<Node> getAllChildren() { + Iterator<Node> getAllChildren() { Vector<Node> userChildren = new Vector<Node>(children.size()); for (int i = 0; i < children.size(); i++) { @@ -452,7 +452,7 @@ ArrayList<ArrayList<View>> viewLists = null; userChildren.add(null); } - return userChildren.elements(); + return userChildren.iterator(); } void checkValidChild(Node child, String s) { @@ -2128,6 +2128,17 @@ synchronized void setAltAppScope() { (TargetsInterface)parentSwitchLink; } + + @Override + synchronized void updateLocalToVworld() { + // For each children call ..... + for (int i=children.size()-1; i>=0; i--) { + NodeRetained child = children.get(i); + if(child != null) + child.updateLocalToVworld(); + } + } + @Override void setNodeData(SetLiveState s) { super.setNodeData(s); diff --git a/src/javax/media/j3d/HashKey.java b/src/main/java/org/jogamp/java3d/HashKey.java index cfbf7fe..1ff0c80 100644 --- a/src/javax/media/j3d/HashKey.java +++ b/src/main/java/org/jogamp/java3d/HashKey.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class HashKey extends Object { diff --git a/src/javax/media/j3d/HiResCoord.java b/src/main/java/org/jogamp/java3d/HiResCoord.java index cfefa4a..c26aaf6 100644 --- a/src/javax/media/j3d/HiResCoord.java +++ b/src/main/java/org/jogamp/java3d/HiResCoord.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3d; /** * High resolution coordinate object. diff --git a/src/javax/media/j3d/IllegalRenderingStateException.java b/src/main/java/org/jogamp/java3d/IllegalRenderingStateException.java index 023ad9a..25964dd 100644 --- a/src/javax/media/j3d/IllegalRenderingStateException.java +++ b/src/main/java/org/jogamp/java3d/IllegalRenderingStateException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates an illegal state for rendering. This is typically some sort of diff --git a/src/javax/media/j3d/IllegalSceneGraphException.java b/src/main/java/org/jogamp/java3d/IllegalSceneGraphException.java index 64542aa..28663aa 100644 --- a/src/javax/media/j3d/IllegalSceneGraphException.java +++ b/src/main/java/org/jogamp/java3d/IllegalSceneGraphException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates an illegal Java 3D scene graph. diff --git a/src/javax/media/j3d/IllegalSharingException.java b/src/main/java/org/jogamp/java3d/IllegalSharingException.java index e93d5f8..6b9f431 100644 --- a/src/javax/media/j3d/IllegalSharingException.java +++ b/src/main/java/org/jogamp/java3d/IllegalSharingException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates an illegal attempt to share a scene graph object. For example, diff --git a/src/javax/media/j3d/ImageComponent.java b/src/main/java/org/jogamp/java3d/ImageComponent.java index 85d7aa4..d0ca920 100644 --- a/src/javax/media/j3d/ImageComponent.java +++ b/src/main/java/org/jogamp/java3d/ImageComponent.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Abstract class that is used to define 2D or 3D ImageComponent diff --git a/src/javax/media/j3d/ImageComponent2D.java b/src/main/java/org/jogamp/java3d/ImageComponent2D.java index d8e0d2f..5cb5a18 100644 --- a/src/javax/media/j3d/ImageComponent2D.java +++ b/src/main/java/org/jogamp/java3d/ImageComponent2D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; diff --git a/src/javax/media/j3d/ImageComponent2DRetained.java b/src/main/java/org/jogamp/java3d/ImageComponent2DRetained.java index 395b159..85abcca 100644 --- a/src/javax/media/j3d/ImageComponent2DRetained.java +++ b/src/main/java/org/jogamp/java3d/ImageComponent2DRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; diff --git a/src/javax/media/j3d/ImageComponent3D.java b/src/main/java/org/jogamp/java3d/ImageComponent3D.java index 34be8b9..3774a97 100644 --- a/src/javax/media/j3d/ImageComponent3D.java +++ b/src/main/java/org/jogamp/java3d/ImageComponent3D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; diff --git a/src/javax/media/j3d/ImageComponent3DRetained.java b/src/main/java/org/jogamp/java3d/ImageComponent3DRetained.java index fd65ad1..45fd68c 100644 --- a/src/javax/media/j3d/ImageComponent3DRetained.java +++ b/src/main/java/org/jogamp/java3d/ImageComponent3DRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; diff --git a/src/javax/media/j3d/ImageComponentRetained.java b/src/main/java/org/jogamp/java3d/ImageComponentRetained.java index 8fb9697..211d4cd 100644 --- a/src/javax/media/j3d/ImageComponentRetained.java +++ b/src/main/java/org/jogamp/java3d/ImageComponentRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.color.ColorSpace; import java.awt.geom.AffineTransform; diff --git a/src/javax/media/j3d/ImageComponentUpdateInfo.java b/src/main/java/org/jogamp/java3d/ImageComponentUpdateInfo.java index eeb45ad..1cce28f 100644 --- a/src/javax/media/j3d/ImageComponentUpdateInfo.java +++ b/src/main/java/org/jogamp/java3d/ImageComponentUpdateInfo.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Image Component update information for the users diff --git a/src/javax/media/j3d/IndexedGeometryArray.java b/src/main/java/org/jogamp/java3d/IndexedGeometryArray.java index 113bd4f..2fda0ff 100644 --- a/src/javax/media/j3d/IndexedGeometryArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedGeometryArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/IndexedGeometryArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedGeometryArrayRetained.java index 528c46f..dbcc23d 100644 --- a/src/javax/media/j3d/IndexedGeometryArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedGeometryArrayRetained.java @@ -24,14 +24,14 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.nio.Buffer; import java.nio.FloatBuffer; import java.util.ArrayList; -import javax.vecmath.TexCoord2f; -import javax.vecmath.TexCoord3f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.TexCoord3f; /** * The IndexedGeometryArray object contains arrays of positional coordinates, @@ -1159,6 +1159,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { boolean updateAlpha, float alpha, int screen, boolean ignoreVertexColors) { + //FIXME: PJPJPJ big ugly hack for buffers + if(cv.ctx!= prevContext) + { + ctxExecutedOn.add(cv.ctx); + prevContext = cv.ctx; + } + int cdirty; boolean useAlpha = false; Object[] retVal; diff --git a/src/javax/media/j3d/IndexedGeometryStripArray.java b/src/main/java/org/jogamp/java3d/IndexedGeometryStripArray.java index 7253aac..5331ab1 100644 --- a/src/javax/media/j3d/IndexedGeometryStripArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedGeometryStripArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedGeometryStripArray object is an abstract class that is extended for diff --git a/src/javax/media/j3d/IndexedGeometryStripArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedGeometryStripArrayRetained.java index d3e874f..26df232 100644 --- a/src/javax/media/j3d/IndexedGeometryStripArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedGeometryStripArrayRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; /** diff --git a/src/javax/media/j3d/IndexedLineArray.java b/src/main/java/org/jogamp/java3d/IndexedLineArray.java index f010506..cdcf3de 100644 --- a/src/javax/media/j3d/IndexedLineArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedLineArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedLineArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/IndexedLineArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedLineArrayRetained.java index b28b830..d1a557d 100644 --- a/src/javax/media/j3d/IndexedLineArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedLineArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The IndexedLineArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/IndexedLineStripArray.java b/src/main/java/org/jogamp/java3d/IndexedLineStripArray.java index e956d23..ad2b383 100644 --- a/src/javax/media/j3d/IndexedLineStripArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedLineStripArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedLineStripArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/IndexedLineStripArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedLineStripArrayRetained.java index 21b5205..853946b 100644 --- a/src/javax/media/j3d/IndexedLineStripArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedLineStripArrayRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +package org.jogamp.java3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The IndexedLineStripArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/IndexedObject.java b/src/main/java/org/jogamp/java3d/IndexedObject.java index a739769..3b6c74f 100644 --- a/src/javax/media/j3d/IndexedObject.java +++ b/src/main/java/org/jogamp/java3d/IndexedObject.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class used for IndexedUnorderedList diff --git a/src/javax/media/j3d/IndexedPointArray.java b/src/main/java/org/jogamp/java3d/IndexedPointArray.java index 4373fb3..2287e25 100644 --- a/src/javax/media/j3d/IndexedPointArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedPointArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedPointArray object draws the array of vertices as diff --git a/src/javax/media/j3d/IndexedPointArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedPointArrayRetained.java index 4d7970f..9d91c20 100644 --- a/src/javax/media/j3d/IndexedPointArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedPointArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The IndexedPointArray object draws the array of vertices as individual points. diff --git a/src/javax/media/j3d/IndexedQuadArray.java b/src/main/java/org/jogamp/java3d/IndexedQuadArray.java index 0ed40d1..0519a79 100644 --- a/src/javax/media/j3d/IndexedQuadArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedQuadArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedQuadArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/IndexedQuadArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedQuadArrayRetained.java index b32ac13..fc98f05 100644 --- a/src/javax/media/j3d/IndexedQuadArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedQuadArrayRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * The IndexedQuadArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/IndexedTriangleArray.java b/src/main/java/org/jogamp/java3d/IndexedTriangleArray.java index 35969f0..d38afeb 100644 --- a/src/javax/media/j3d/IndexedTriangleArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedTriangleArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedTriangleArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/IndexedTriangleArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedTriangleArrayRetained.java index 22b4839..d74f631 100644 --- a/src/javax/media/j3d/IndexedTriangleArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedTriangleArrayRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * The IndexedTriangleArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/IndexedTriangleFanArray.java b/src/main/java/org/jogamp/java3d/IndexedTriangleFanArray.java index 38a321b..17e4c73 100644 --- a/src/javax/media/j3d/IndexedTriangleFanArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedTriangleFanArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedTriangleFanArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/IndexedTriangleFanArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedTriangleFanArrayRetained.java index f4f0c98..4423cfd 100644 --- a/src/javax/media/j3d/IndexedTriangleFanArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedTriangleFanArrayRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * The IndexedTriangleFanArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/IndexedTriangleStripArray.java b/src/main/java/org/jogamp/java3d/IndexedTriangleStripArray.java index 71f4659..d63d888 100644 --- a/src/javax/media/j3d/IndexedTriangleStripArray.java +++ b/src/main/java/org/jogamp/java3d/IndexedTriangleStripArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The IndexedTriangleStripArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/IndexedTriangleStripArrayRetained.java b/src/main/java/org/jogamp/java3d/IndexedTriangleStripArrayRetained.java index 3b393d3..b6de110 100644 --- a/src/javax/media/j3d/IndexedTriangleStripArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/IndexedTriangleStripArrayRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * The IndexedTriangleStripArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/IndexedUnorderSet.java b/src/main/java/org/jogamp/java3d/IndexedUnorderSet.java index d498bac..e0f2f1e 100644 --- a/src/javax/media/j3d/IndexedUnorderSet.java +++ b/src/main/java/org/jogamp/java3d/IndexedUnorderSet.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A strongly type indexed unorder set. diff --git a/src/javax/media/j3d/InputDevice.java b/src/main/java/org/jogamp/java3d/InputDevice.java index bab0200..3e2ae05 100644 --- a/src/javax/media/j3d/InputDevice.java +++ b/src/main/java/org/jogamp/java3d/InputDevice.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; diff --git a/src/javax/media/j3d/InputDeviceBlockingThread.java b/src/main/java/org/jogamp/java3d/InputDeviceBlockingThread.java index f65a65b..9eccc71 100644 --- a/src/javax/media/j3d/InputDeviceBlockingThread.java +++ b/src/main/java/org/jogamp/java3d/InputDeviceBlockingThread.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class InputDeviceBlockingThread extends Thread { diff --git a/src/javax/media/j3d/InputDeviceScheduler.java b/src/main/java/org/jogamp/java3d/InputDeviceScheduler.java index 1c24094..21e2935 100644 --- a/src/javax/media/j3d/InputDeviceScheduler.java +++ b/src/main/java/org/jogamp/java3d/InputDeviceScheduler.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/IntegerFreeList.java b/src/main/java/org/jogamp/java3d/IntegerFreeList.java index db96457..8b30482 100644 --- a/src/javax/media/j3d/IntegerFreeList.java +++ b/src/main/java/org/jogamp/java3d/IntegerFreeList.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class IntegerFreeList extends MemoryFreeList { diff --git a/src/javax/media/j3d/Interpolator.java b/src/main/java/org/jogamp/java3d/Interpolator.java index e035927..22f7d62 100644 --- a/src/javax/media/j3d/Interpolator.java +++ b/src/main/java/org/jogamp/java3d/Interpolator.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; diff --git a/src/javax/media/j3d/J3DBuffer.java b/src/main/java/org/jogamp/java3d/J3DBuffer.java index 2cacf8a..938ae16 100644 --- a/src/javax/media/j3d/J3DBuffer.java +++ b/src/main/java/org/jogamp/java3d/J3DBuffer.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.nio.Buffer; import java.nio.ByteBuffer; diff --git a/src/javax/media/j3d/J3DGraphics2D.java b/src/main/java/org/jogamp/java3d/J3DGraphics2D.java index 1fc48cf..f34fb32 100644 --- a/src/javax/media/j3d/J3DGraphics2D.java +++ b/src/main/java/org/jogamp/java3d/J3DGraphics2D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Color; import java.awt.Graphics; diff --git a/src/javax/media/j3d/J3DGraphics2DImpl.java b/src/main/java/org/jogamp/java3d/J3DGraphics2DImpl.java index 0d55383..d774ede 100644 --- a/src/javax/media/j3d/J3DGraphics2DImpl.java +++ b/src/main/java/org/jogamp/java3d/J3DGraphics2DImpl.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.AlphaComposite; import java.awt.Color; diff --git a/src/javax/media/j3d/J3dClock.java b/src/main/java/org/jogamp/java3d/J3dClock.java index b634f79..ee6a91f 100644 --- a/src/javax/media/j3d/J3dClock.java +++ b/src/main/java/org/jogamp/java3d/J3dClock.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Utility class to provide a more accurate replacement for diff --git a/src/javax/media/j3d/J3dDebug.java b/src/main/java/org/jogamp/java3d/J3dDebug.java index 1b18544..feffeea 100644 --- a/src/javax/media/j3d/J3dDebug.java +++ b/src/main/java/org/jogamp/java3d/J3dDebug.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class J3dDebug { diff --git a/src/javax/media/j3d/J3dHash.java b/src/main/java/org/jogamp/java3d/J3dHash.java index 5db0437..39c829b 100644 --- a/src/javax/media/j3d/J3dHash.java +++ b/src/main/java/org/jogamp/java3d/J3dHash.java @@ -13,7 +13,7 @@ * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A Utility class wrapping the approach used to hash double values in Java3D diff --git a/src/javax/media/j3d/J3dI18N.java b/src/main/java/org/jogamp/java3d/J3dI18N.java index c6ddf21..a8d9734 100644 --- a/src/javax/media/j3d/J3dI18N.java +++ b/src/main/java/org/jogamp/java3d/J3dI18N.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -34,7 +34,7 @@ class J3dI18N { static String getString(String key) { String s; try { - s = ResourceBundle.getBundle("javax.media.j3d.ExceptionStrings").getString(key); + s = ResourceBundle.getBundle("org.jogamp.java3d.ExceptionStrings").getString(key); } catch (MissingResourceException e) { System.err.println("J3dI18N: Error looking up: " + key); diff --git a/src/javax/media/j3d/J3dMessage.java b/src/main/java/org/jogamp/java3d/J3dMessage.java index 4c695f3..cd0b987 100644 --- a/src/javax/media/j3d/J3dMessage.java +++ b/src/main/java/org/jogamp/java3d/J3dMessage.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The J3dMessage is the super class of all messages in Java 3D. It implements diff --git a/src/javax/media/j3d/J3dNotification.java b/src/main/java/org/jogamp/java3d/J3dNotification.java index c1b0e70..5211b54 100644 --- a/src/javax/media/j3d/J3dNotification.java +++ b/src/main/java/org/jogamp/java3d/J3dNotification.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * J3dNotification is used to hold data for asynchronous error notification. diff --git a/src/javax/media/j3d/J3dQueryProps.java b/src/main/java/org/jogamp/java3d/J3dQueryProps.java index ef639f1..5a3daf3 100644 --- a/src/javax/media/j3d/J3dQueryProps.java +++ b/src/main/java/org/jogamp/java3d/J3dQueryProps.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.AbstractMap; import java.util.AbstractSet; diff --git a/src/javax/media/j3d/J3dStructure.java b/src/main/java/org/jogamp/java3d/J3dStructure.java index 4dcf45f..8af0f9e 100644 --- a/src/javax/media/j3d/J3dStructure.java +++ b/src/main/java/org/jogamp/java3d/J3dStructure.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/J3dThread.java b/src/main/java/org/jogamp/java3d/J3dThread.java index 1d5b3a8..043cae2 100644 --- a/src/javax/media/j3d/J3dThread.java +++ b/src/main/java/org/jogamp/java3d/J3dThread.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The J3dThread is the super class of all slave threads in Java 3D. It implements diff --git a/src/javax/media/j3d/J3dThreadData.java b/src/main/java/org/jogamp/java3d/J3dThreadData.java index 8161bbf..d1998e9 100644 --- a/src/javax/media/j3d/J3dThreadData.java +++ b/src/main/java/org/jogamp/java3d/J3dThreadData.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The J3dThreadData is the data wrapper for threads in Java 3D. diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Context.java b/src/main/java/org/jogamp/java3d/Jogl2es2Context.java new file mode 100644 index 0000000..c6a0c48 --- /dev/null +++ b/src/main/java/org/jogamp/java3d/Jogl2es2Context.java @@ -0,0 +1,597 @@ +/* Copyright (c) 2016 JogAmp Community. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +package org.jogamp.java3d; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; + +import org.jogamp.vecmath.Matrix3d; +import org.jogamp.vecmath.Matrix4d; +import org.jogamp.vecmath.Vector3f; +import org.jogamp.vecmath.Vector4f; + +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL2ES3; +import com.jogamp.opengl.GLContext; + + +public class Jogl2es2Context extends JoglContext +{ + + public Jogl2es2Context(GLContext context) + { + super(context); + } + + public GL2ES2 gl2es2() + { + return context.getGL().getGL2ES2(); + } + + public GL2ES3 gl2es3() + { + if(context.getGL().isGL2ES3()) + return context.getGL().getGL2ES3(); + else + return null; + } + + public JoglShaderObject shaderProgram; + public int shaderProgramId = -1; + public ProgramData programData; + + @Override + void setShaderProgram(JoglShaderObject object) + { + super.setShaderProgram(object); + shaderProgram = object; + shaderProgramId = object == null ? -1 : object.getValue(); + programData = allProgramData.get(shaderProgramId); + if (programData == null) + { + programData = new ProgramData(); + allProgramData.put(shaderProgramId, programData); + } + + } + + // all buffers created are recorded for each render pass, and for cleanup + public ArrayList<GeometryArrayRetained> geoToClearBuffers = new ArrayList<GeometryArrayRetained>(); + + public SparseArray<GeometryData> allGeometryData = new SparseArray<GeometryData>(); + + public static class GeometryData + { + public int nativeId = -1; + + public int geoToIndBuf = -1; + public int geoToIndBufSize = -1; + public int[] geoToIndStripBuf = null; + //public int geoToIndStripSwappedSize = -1;// removed into j3dnotristrips + public int geoToCoordBuf = -1; + public int geoToCoordBuf1 = -2;// double buffered for updates + public int geoToCoordBuf2 = -3; + public int geoToCoordBuf3 = -3; + public int geoToCoordBufSize = -1; + public int geoToColorBuf = -1; + public int geoToNormalBuf = -1; + public SparseArray<Integer> geoToTexCoordsBuf = new SparseArray<Integer>(); + public SparseArray<Integer> geoToVertAttribBuf = new SparseArray<Integer>(); + + //Every thing below relates to interleaved data + public int coordBufId = -1; // if separate + public int interleavedBufId = -1; + public int interleavedStride = 0; + public int geoToCoordOffset = -1; + public int geoToColorsOffset = -1; + public int geoToNormalsOffset = -1; + public int[] geoToVattrOffset = new int[10]; + public int[] geoToTexCoordOffset = new int[10]; + + // vertex array object id for this geom + public int vaoId = -1; + + //used to identify each geometry as we see it + private static int nextNativeId = 0; + + public GeometryData() + { + nativeId = nextNativeId++; + nextNativeId = nextNativeId > Integer.MAX_VALUE - 10 ? 0 : nextNativeId;// desperate loop + } + + } + + public SparseArray<ProgramData> allProgramData = new SparseArray<ProgramData>(); + + public static class ProgramData + { + public HashMap<String, Integer> progToGenVertAttNameToGenVertAttIndex = new HashMap<String, Integer>(); + public LocationData programToLocationData = null;// null to indicate need to load + public ByteBuffer programToUBOBB = null; + public int programToUBOBuf = -1; + } + + public fogData fogData = new fogData(); + + public glFrontMaterial materialData = new glFrontMaterial(); + // should use getMaximumLights() in pipeline? though it's up to the shader + public static int MAX_LIGHTS = 32; + public int maxLights; + public int numberOfLights; + public glLightSource[] glLightSource = new glLightSource[MAX_LIGHTS]; + + //See here http://download.java.net/media/java3d/javadoc/1.3.2/javax/media/j3d/RenderingAttributes.html + // For coloring implementation details + + //only for no lighting, materialDiffuse or vertex colors otherwise + public Vector4f objectColor = new Vector4f(); + + public float pointSize = 0; + + public int polygonMode = PolygonAttributes.POLYGON_FILL; + + public static class RenderingData + { + public boolean alphaTestEnabled = false; + public int alphaTestFunction = RenderingAttributes.ALWAYS; + public float alphaTestValue = 0; + public int ignoreVertexColors; //-1 is not set 1,0 bool + } + + public RenderingData renderingData = new RenderingData(); + + public float transparencyAlpha = 0; + + public Vector4f currentAmbientColor = new Vector4f(); + + public Matrix4d textureTransform = new Matrix4d(); + + //various ffp matrixes + public Matrix4d currentModelMat = new Matrix4d(); + public Matrix4d currentViewMat = new Matrix4d(); + public Matrix4d currentModelViewMat = new Matrix4d(); + public Matrix4d currentModelViewMatInverse = new Matrix4d(); + public Matrix4d currentModelViewProjMat = new Matrix4d(); + public Matrix3d currentNormalMat = new Matrix3d(); + public Matrix4d currentProjMat = new Matrix4d(); + public Matrix4d currentProjMatInverse = new Matrix4d(); + + /** + * On shader creation the various FFP locations are discovered and recorded for use later + * @author phil + * + */ + public static class LocationData + { + //normal uniform data + public int glProjectionMatrix = -1; + public int glProjectionMatrixInverse = -1; + public int glModelMatrix = -1; + public int glViewMatrix = -1; + public int glModelViewMatrix = -1; + public int glModelViewMatrixInverse = -1; + public int glModelViewProjectionMatrix = -1; + public int glNormalMatrix = -1; + public int ignoreVertexColors = -1; + public int glLightModelambient = -1; + public int objectColor = -1; + public int transparencyAlpha = -1; + public int alphaTestEnabled = -1; + public int alphaTestFunction = -1; + public int alphaTestValue = -1; + public int textureTransform = -1; + + public fogDataLocs fogData = new fogDataLocs(); + + public glFrontMaterialLocs glFrontMaterial = new glFrontMaterialLocs(); + public int numberOfLights = -1; + public glLightSourceLocs[] glLightSource = new glLightSourceLocs[MAX_LIGHTS]; + + public int glVertex = -1; + public int glColor = -1; + public int glNormal = -1; + + public int[] glMultiTexCoord = new int[16]; + public SparseArray<Integer> genAttIndexToLoc = new SparseArray<Integer>(); + + } + + /** + * below here are openGL state tracking to reduce unnecessary native calls + * Note this is NOT like the "new" or so called current staet above taht needs to be st in the FFP + * call, this is the old or previously set data, that might not need to be updated + * @author phil + * + */ + public static class GL_State + { + public boolean depthBufferEnableOverride; + public boolean depthBufferEnable; + public int depthTestFunction; + public boolean depthBufferWriteEnableOverride; + public boolean depthBufferWriteEnable; + public boolean userStencilAvailable; + public boolean stencilEnable; + public boolean glDepthMask; + public boolean glEnableGL_STENCIL_TEST; + public int stencilFailOp; + public int stencilZFailOp; + public int stencilZPassOp; + public int stencilFunction; + public int stencilReferenceValue; + public int stencilCompareMask; + public int stencilWriteMask; + public int[] setGLSLUniform1i = new int[500]; + public int[] clearer1 = new int[500]; + public float[] setGLSLUniform1f = new float[500]; + public float[] clearer2 = new float[500]; + public boolean glEnableGL_BLEND; + public int srcBlendFunction; + public int dstBlendFunction; + public int glActiveTexture; + public int currentProgramId; + public int[] glBindTextureGL_TEXTURE_2D = new int[35000];// indexed based on current glActiveTexture + public int[] clearer3 = new int[35000]; + public int cullFace; + public float polygonOffsetFactor; + public float polygonOffset; + + public int ignoreVertexColors; //-1 indicates not set yet, always set + public Vector4f glLightModelambient = new Vector4f(); + public Vector4f objectColor = new Vector4f(); + public float transparencyAlpha; + public Matrix4d textureTransform = new Matrix4d(); + public Matrix4d modelMatrix = new Matrix4d(); + public Matrix4d glModelViewMatrix = new Matrix4d(); + public Matrix4d glModelViewMatrixInverse = new Matrix4d(); + public Matrix4d glModelViewProjectionMatrix = new Matrix4d(); + public Matrix3d glNormalMatrix = new Matrix3d(); + public boolean alphaTestEnabled = false; + public int alphaTestFunction; + public float alphaTestValue; + + public fogData fogData = new fogData(); + public glFrontMaterial glFrontMaterial = new glFrontMaterial(); + public int numberOfLights = -1; + public glLightSource[] glLightSource = new glLightSource[MAX_LIGHTS]; + + public void clear() + { + depthBufferEnableOverride = false; + depthBufferEnable = false; + depthTestFunction = -1; + depthBufferWriteEnableOverride = false; + depthBufferWriteEnable = false; + userStencilAvailable = false; + stencilEnable = false; + glDepthMask = false; + glEnableGL_STENCIL_TEST = false; + stencilFailOp = -1; + stencilZFailOp = -1; + stencilZPassOp = -1; + stencilFunction = -1; + stencilReferenceValue = -1; + stencilCompareMask = -1; + stencilWriteMask = -1; + System.arraycopy(clearer1, 0, setGLSLUniform1i, 0, setGLSLUniform1i.length); + System.arraycopy(clearer2, 0, setGLSLUniform1f, 0, setGLSLUniform1f.length); + glEnableGL_BLEND = false; + srcBlendFunction = -1; + dstBlendFunction = -1; + glActiveTexture = -1; + currentProgramId = -1; + System.arraycopy(clearer3, 0, glBindTextureGL_TEXTURE_2D, 0, glBindTextureGL_TEXTURE_2D.length); + cullFace = -1; + polygonOffsetFactor = -1; + polygonOffset = -1; + ignoreVertexColors = -1; + glLightModelambient.set(Float.NEGATIVE_INFINITY, -999f, -999f, -999f); + objectColor.set(Float.NEGATIVE_INFINITY, -999f, -999f, -999f); + transparencyAlpha = -1; + textureTransform.m00 = Double.NEGATIVE_INFINITY; + modelMatrix.m00 = Double.NEGATIVE_INFINITY; + glModelViewMatrix.m00 = Double.NEGATIVE_INFINITY; + glModelViewMatrixInverse.m00 = Double.NEGATIVE_INFINITY; + glModelViewProjectionMatrix.m00 = Double.NEGATIVE_INFINITY; + glNormalMatrix.m00 = Double.NEGATIVE_INFINITY; + alphaTestEnabled = false; + alphaTestFunction = -1; + alphaTestValue = -99f; + + fogData.clear(); + glFrontMaterial.clear(); + for (int i = 0; i < MAX_LIGHTS; i++) + { + glLightSource[i] = null; + } + } + } + + public GL_State gl_state = new GL_State(); + + /** + * program used on last run through of FFP, so nearly like gl_state above, just a desperate attempt + * to see if the uniform locations have changed even if a new shader is being used + */ + public int prevShaderProgram; + + // The per frame stats + public Jogl2es2PerFrameStats perFrameStats = new Jogl2es2PerFrameStats(); + + private int statsFrame = 0; + private int STATS_OUTPUT_FRAME_FREQ = 50; + + public void outputPerFrameData() + { + statsFrame++; + if (statsFrame % STATS_OUTPUT_FRAME_FREQ == 0) + { + statsFrame = 0; + System.out.println("======================================================"); + perFrameStats.outputPerFrameData(); + } + // clear for next frame + perFrameStats = new Jogl2es2PerFrameStats(); + perFrameStats.endOfPrevFrameTime = System.nanoTime(); + } + + // texture and raster fill variables + + // raster vao and buf are not in the by geom bucket because I don't get given geom + // background has to be created and destroyed + + public int simpleTextureShaderProgramId = -1; + public int simpleTextureShaderProgramVertLoc = -1; + public int simpleTextureShaderProgramTexCoordLoc = -1; + public int simpleTextureShaderProgramBaseMapLoc = -1; + + // just a singleton of the handy matrix/array operations + public Jogl2es2MatrixUtil matrixUtil = new Jogl2es2MatrixUtil(); + + /////////////////////////////////////S H A D E R S T R U C T S ///////////////////////////////////////////////////// + + // in the shader as follows + // struct material + // { + // int lightEnabled; + // vec4 ambient; + // vec4 diffuse; + // vec4 emission; + // vec3 specular; + // float shininess; + // }; + // uniform material glFrontMaterial; + public static class glFrontMaterial + { + public int lightEnabled = -1; + public Vector4f ambient = new Vector4f(); + public Vector4f diffuse = new Vector4f(); + public Vector3f emission = new Vector3f(); + public Vector3f specular = new Vector3f(); + public float shininess; + + public void clear() + { + lightEnabled = -1; + ambient.set(Float.NEGATIVE_INFINITY, -999f, -999f, -999f); + diffuse.set(Float.NEGATIVE_INFINITY, -999f, -999f, -999f); + emission.set(Float.NEGATIVE_INFINITY, -999f, -999f); + specular.set(Float.NEGATIVE_INFINITY, -999f, -999f); + shininess = -99; + } + + @Override + public boolean equals(Object o) + { + if (o instanceof glFrontMaterial) + { + glFrontMaterial ogfm = (glFrontMaterial) o; + return ogfm.lightEnabled == lightEnabled && ogfm.ambient.equals(ambient) && ogfm.diffuse.equals(diffuse) + && ogfm.emission.equals(emission) && ogfm.specular.equals(specular) && ogfm.shininess == shininess; + } + else + { + return false; + } + } + } + + public static class glFrontMaterialLocs + { + public boolean present = false; + public int lightEnabled = -1; + public int ambient = -1; + public int diffuse = -1; + public int emission = -1; + public int specular = -1; + public int shininess = -1; + + public void setPresent() + { + present = lightEnabled != -1 || ambient != -1 || diffuse != -1 || emission != -1 || specular != -1 || shininess != -1; + } + } + // struct lightSource + // { + // vec4 position; + // vec4 diffuse; + // vec4 specular; + // float constantAttenuation, linearAttenuation, quadraticAttenuation; + // float spotCutoff, spotExponent; + // vec3 spotDirection; + // }; + // + // uniform int numberOfLights; + // const int maxLights = 2; + // uniform lightSource glLightSource[maxLights]; + + //see https://en.wikibooks.org/wiki/GLSL_Programming/GLUT/Multiple_Lights + public static class glLightSource + { + public int enabled = -1; + public int prevLightSlot = -1; + public Vector4f position = new Vector4f(); + //public Vector4f ambient = new Vector4f();//removed as an oddity + public Vector4f diffuse = new Vector4f(); + public Vector4f specular = new Vector4f(); + public float constantAttenuation; + public float linearAttenuation; + public float quadraticAttenuation; + public float spotCutoff; + public float spotExponent; + public Vector3f spotDirection = new Vector3f(); + + public void clear() + { + enabled = -1; + prevLightSlot = -1; + position.set(-999f, -999f, -999f, -999f); + diffuse.set(-999f, -999f, -999f, -999f); + specular.set(-999f, -999f, -999f, -999f); + constantAttenuation = -99; + linearAttenuation = -99; + quadraticAttenuation = -99; + spotCutoff = -99; + spotExponent = -99; + spotDirection.set(-999f, -999f, -999f); + } + + public void set(glLightSource ogfm) + { + enabled = ogfm.enabled; + prevLightSlot = ogfm.prevLightSlot; + position.set(ogfm.position); + diffuse.set(ogfm.diffuse); + specular.set(ogfm.specular); + constantAttenuation = ogfm.constantAttenuation; + linearAttenuation = ogfm.linearAttenuation; + quadraticAttenuation = ogfm.quadraticAttenuation; + spotCutoff = ogfm.spotCutoff; + spotExponent = ogfm.spotExponent; + spotDirection.set(ogfm.spotDirection); + } + + @Override + public boolean equals(Object o) + { + if (o instanceof glLightSource) + { + glLightSource ogfm = (glLightSource) o; + return enabled == ogfm.enabled && prevLightSlot == ogfm.prevLightSlot && ogfm.position.equals(position) + && ogfm.diffuse.equals(diffuse) && ogfm.specular.equals(specular) && ogfm.constantAttenuation == constantAttenuation + && ogfm.linearAttenuation == linearAttenuation && ogfm.quadraticAttenuation == quadraticAttenuation + && ogfm.spotCutoff == spotCutoff && ogfm.spotExponent == spotExponent && ogfm.spotDirection.equals(spotDirection); + } + else + { + return false; + } + } + } + + public static class glLightSourceLocs + { + public int position = -1; + public int diffuse = -1; + public int specular = -1; + public int constantAttenuation = -1; + public int linearAttenuation = -1; + public int quadraticAttenuation = -1; + public int spotCutoff = -1; + public int spotExponent = -1; + public int spotDirection = -1; + } + + // in the shader as follows + // struct fogDataStruct + // { + // int fogEnabled; + // vec4 expColor; + // float expDensity; + // vec4 linearColor; + // float linearStart; + // float linearEnd; + // }; + // uniform fogDataStruct fogData; + public static class fogData + { + public int fogEnabled = -1; + public Vector3f expColor = new Vector3f(); + public float expDensity; + public Vector3f linearColor = new Vector3f(); + public float linearStart; + public float linearEnd; + + public void clear() + { + fogEnabled = -1; + expColor.set(Float.NEGATIVE_INFINITY, -999f, -999f); + expDensity = -99; + linearColor.set(-999f, -999f, -999f); + linearStart = -99; + linearEnd = -99; + } + + public void set(fogData ogfm) + { + fogEnabled = ogfm.fogEnabled; + expColor.set(ogfm.expColor); + expDensity = ogfm.expDensity; + linearColor.set(ogfm.linearColor); + linearStart = ogfm.linearStart; + linearEnd = ogfm.linearEnd; + } + + @Override + public boolean equals(Object o) + { + if (o instanceof fogData) + { + fogData ogfm = (fogData) o; + return ogfm.fogEnabled == fogEnabled && ogfm.expColor.equals(expColor) && ogfm.expDensity == expDensity + && ogfm.linearColor.equals(linearColor) && ogfm.linearStart == linearStart && ogfm.linearEnd == linearEnd; + } + else + { + return false; + } + } + } + + public static class fogDataLocs + { + public boolean present = false; + public int fogEnabled = -1; + public int expColor = -1; + public int expDensity = -1; + public int linearColor = -1; + public int linearStart = -1; + public int linearEnd = -1; + + public void setPresent() + { + present = fogEnabled != -1 || expColor != -1 || expDensity != -1 || linearColor != -1 || linearStart != -1 || linearEnd != -1; + } + } +} diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java new file mode 100644 index 0000000..7e4cccf --- /dev/null +++ b/src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java @@ -0,0 +1,375 @@ +/* + * Copyright (c) 2016 JogAmp Community. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +package org.jogamp.java3d; + +/** + * Separated from the actual pipeline for clarity of features that are not supported from the + * Pipeline class for the JOGL2ES2 rendering pipeline. + */ +abstract class Jogl2es2DEPPipeline extends Pipeline +{ + public static final String VALID_FORMAT_MESSAGE = "The Gl2ES2 pipeline only supports a subset of the Geometry data types and formats. \n"// + + "Coordinates must be defined and float type, colors must be float type, if defined. \n"// + + "Decaling is not supported. \n"// + + "Model Clip is not supported and must be reimplemented in shaders \n"// + + "QuadArray or IndexedQuadArray cannot be supported. \n"// + + "Texture Coordinate generation cannot be supported. \n" // + + "Texture Lod, Filter, Sharpen and Combine cannot be supported. \n"// + + "Texture3D cannot be supported. \n"// + + "Accum style anti-aliasing cannot be supported. \n"// + + "RasterOps from RenderingAttributes cannot be used. \n"// + + "ReadRaster for depth requires a custom shader and color read instead. \n"// + + "It is strongly recomended that you use the format GeometryArray.USE_NIO_BUFFER = true. \n"// + + "Note LineArray and LineStripArray will not render as nicely as the fixed function pipeline.";// + + /** + * Constructor for singleton JoglPipeline instance + */ + protected Jogl2es2DEPPipeline() + { + + } + + // used for GeometryArrays (this means DisplayList usage) + @Override + @Deprecated + void buildGA(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean updateAlpha, float alpha, + boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount, int[] texCoordSetMap, + int texCoordSetMapLen, int[] texCoordSetMapOffset, int vertexAttrCount, int[] vertexAttrSizes, double[] xform, double[] nxform, + float[] varray) + { + throw new UnsupportedOperationException("DisplayLists in use!. When using the gl2es2pipeline you can use \n" + + "System.setProperty(\"j3d.displaylist\", \"false\"); to avoid this issue. \n" + + "Please note the recommended solution is to use NIO buffers. \n" + VALID_FORMAT_MESSAGE); + } + + // used to Build DisplayList GeometryArray by Reference with java arrays + @Override + @Deprecated + void buildGAForByRef(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean updateAlpha, float alpha, + boolean ignoreVertexColors, int vcount, int vformat, int vdefined, int initialCoordIndex, float[] vfcoords, double[] vdcoords, + int initialColorIndex, float[] cfdata, byte[] cbdata, int initialNormalIndex, float[] ndata, int vertexAttrCount, + int[] vertexAttrSizes, int[] vertexAttrIndices, float[][] vertexAttrData, int texCoordMapLength, int[] tcoordsetmap, + int[] texIndices, int texStride, Object[] texCoords, double[] xform, double[] nxform) + { + throw new UnsupportedOperationException("DisplayLists in use!. When using the gl2es2pipeline you can use \n" + + "System.setProperty(\"j3d.displaylist\", \"false\"); to avoid this issue. \n" + + "Please note the recommended solution is to use NIO buffers. \n" + VALID_FORMAT_MESSAGE); + } + + //DisplayList usage + // by-copy geometry + @Override + @Deprecated + void buildIndexedGeometry(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean updateAlpha, + float alpha, boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount, int vertexCount, int vformat, + int vertexAttrCount, int[] vertexAttrSizes, int texCoordSetCount, int[] texCoordSetMap, int texCoordSetMapLen, + int[] texCoordSetMapOffset, double[] xform, double[] nxform, float[] varray, int[] indexCoord) + { + throw new UnsupportedOperationException("DisplayLists in use!. When using the gl2es2pipeline you can use \n" + + "System.setProperty(\"j3d.displaylist\", \"false\"); to avoid this issue. \n" + + "Please note the recommended solution is to use NIO buffers. \n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + boolean decal1stChildSetup(Context ctx) + { + throw new UnsupportedOperationException("decal not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void decalNthChildSetup(Context ctx) + { + throw new UnsupportedOperationException("decal not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void decalReset(Context ctx, boolean depthBufferEnable) + { + throw new UnsupportedOperationException("decal not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + // --------------------------------------------------------------------- + + // + // ModelClipRetained methods + // + @Override + @Deprecated + void updateModelClip(Context ctx, int planeNum, boolean enableFlag, double A, double B, double C, double D) + { + throw new UnsupportedOperationException("Model Clip call not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + // --------------------------------------------------------------------- + + // + // TexCoordGenerationRetained methods + // + + /** + * This method updates the native context: + * trans contains eyeTovworld transform in d3d + * trans contains vworldToEye transform in ogl + */ + @Override + @Deprecated + void updateTexCoordGeneration(Context ctx, boolean enable, int genMode, int format, float planeSx, float planeSy, float planeSz, + float planeSw, float planeTx, float planeTy, float planeTz, float planeTw, float planeRx, float planeRy, float planeRz, + float planeRw, float planeQx, float planeQy, float planeQz, float planeQw, double[] vworldToEc) + { + throw new UnsupportedOperationException( + "Texture Coordinate generation is not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + // --------------------------------------------------------------------- + + // + // TextureAttributesRetained methods + // + @Override + @Deprecated + void updateRegisterCombiners(Context absCtx, double[] transform, boolean isIdentity, int textureMode, int perspCorrectionMode, + float textureBlendColorRed, float textureBlendColorGreen, float textureBlendColorBlue, float textureBlendColorAlpha, + int textureFormat, int combineRgbMode, int combineAlphaMode, int[] combineRgbSrc, int[] combineAlphaSrc, int[] combineRgbFcn, + int[] combineAlphaFcn, int combineRgbScale, int combineAlphaScale) + { + throw new UnsupportedOperationException("RegisterCombiners is not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTextureColorTable(Context ctx, int numComponents, int colorTableSize, int[] textureColorTable) + { + throw new UnsupportedOperationException("TextureColorTable is not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateCombiner(Context ctx, int combineRgbMode, int combineAlphaMode, int[] combineRgbSrc, int[] combineAlphaSrc, + int[] combineRgbFcn, int[] combineAlphaFcn, int combineRgbScale, int combineAlphaScale) + { + throw new UnsupportedOperationException("GL combine not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + // --------------------------------------------------------------------- + + // + // TextureRetained methods + // Texture2DRetained methods + + @Override + @Deprecated + void updateTexture2DLodOffset(Context ctx, float lodOffsetS, float lodOffsetT, float lodOffsetR) + { + throw new UnsupportedOperationException("Texture2DLodOffset not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture2DSharpenFunc(Context ctx, int numSharpenTextureFuncPts, float[] sharpenTextureFuncPts) + { + throw new UnsupportedOperationException("Texture2DSharpenFunc not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture2DFilter4Func(Context ctx, int numFilter4FuncPts, float[] filter4FuncPts) + { + throw new UnsupportedOperationException("Texture2DFilter4Func not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + // --------------------------------------------------------------------- + + // + // Texture3DRetained methods + // + @Override + @Deprecated + void bindTexture3D(Context ctx, int objectId, boolean enable) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DImage(Context ctx, int numLevels, int level, int textureFormat, int imageFormat, int width, int height, int depth, + int boundaryWidth, int dataType, Object data, boolean useAutoMipMap) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DSubImage(Context ctx, int level, int xoffset, int yoffset, int zoffset, int textureFormat, int imageFormat, + int imgXOffset, int imgYOffset, int imgZOffset, int tilew, int tileh, int width, int height, int depth, int dataType, + Object data, boolean useAutoMipMap) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DLodRange(Context ctx, int baseLevel, int maximumLevel, float minimumLod, float maximumLod) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DLodOffset(Context ctx, float lodOffsetS, float lodOffsetT, float lodOffsetR) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DBoundary(Context ctx, int boundaryModeS, int boundaryModeT, int boundaryModeR, float boundaryRed, + float boundaryGreen, float boundaryBlue, float boundaryAlpha) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DFilterModes(Context ctx, int minFilter, int magFilter) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DSharpenFunc(Context ctx, int numSharpenTextureFuncPts, float[] sharpenTextureFuncPts) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DFilter4Func(Context ctx, int numFilter4FuncPts, float[] filter4FuncPts) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTexture3DAnisotropicFilter(Context ctx, float degree) + { + throw new UnsupportedOperationException("Texture3D not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + // --------------------------------------------------------------------- + + // + // TextureCubeMapRetained methods + + @Override + @Deprecated + void updateTextureCubeMapLodOffset(Context ctx, float lodOffsetS, float lodOffsetT, float lodOffsetR) + { + throw new UnsupportedOperationException("TextureCubeMapLodOffset not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTextureCubeMapSharpenFunc(Context ctx, int numSharpenTextureFuncPts, float[] sharpenTextureFuncPts) + { + throw new UnsupportedOperationException("TextureCubeMapSharpenFunc not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void updateTextureCubeMapFilter4Func(Context ctx, int numFilter4FuncPts, float[] filter4FuncPts) + { + throw new UnsupportedOperationException("TextureCubeMapFilter4Func not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + // --------------------------------------------------------------------- + + // + // Canvas3D methods - native wrappers + // + + // This is the native method for doing accumulation. + @Override + @Deprecated + void accum(Context ctx, float value) + { + throw new UnsupportedOperationException("accum not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void accumReturn(Context ctx) + { + throw new UnsupportedOperationException("accum not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void clearAccum(Context ctx) + { + throw new UnsupportedOperationException("accum not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE); + } + + + // used for display Lists + @Override + @Deprecated + void newDisplayList(Context ctx, int displayListId) + { + throw new UnsupportedOperationException("DisplayLists in use!. When using the gl2es2pipeline you can use \n" + + "System.setProperty(\"j3d.displaylist\", \"false\"); to avoid this issue. \n" + + "Please note the recommended solution is to use NIO buffers. \n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void endDisplayList(Context ctx) + { + throw new UnsupportedOperationException("DisplayLists in use!. When using the gl2es2pipeline you can use \n" + + "System.setProperty(\"j3d.displaylist\", \"false\"); to avoid this issue. \n" + + "Please note the recommended solution is to use NIO buffers. \n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void callDisplayList(Context ctx, int id, boolean isNonUniformScale) + { + throw new UnsupportedOperationException("DisplayLists in use!. When using the gl2es2pipeline you can use \n" + + "System.setProperty(\"j3d.displaylist\", \"false\"); to avoid this issue. \n" + + "Please note the recommended solution is to use NIO buffers. \n" + VALID_FORMAT_MESSAGE); + } + + @Override + @Deprecated + void freeDisplayList(Context ctx, int id) + { + throw new UnsupportedOperationException("DisplayLists in use!. When using the gl2es2pipeline you can use \n" + + "System.setProperty(\"j3d.displaylist\", \"false\"); to avoid this issue. \n" + + "Please note the recommended solution is to use NIO buffers. \n" + VALID_FORMAT_MESSAGE); + } +} diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2MatrixUtil.java b/src/main/java/org/jogamp/java3d/Jogl2es2MatrixUtil.java new file mode 100644 index 0000000..6f13653 --- /dev/null +++ b/src/main/java/org/jogamp/java3d/Jogl2es2MatrixUtil.java @@ -0,0 +1,987 @@ +/* + * Copyright (c) 2016 JogAmp Community. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +package org.jogamp.java3d; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import org.jogamp.vecmath.Matrix3d; +import org.jogamp.vecmath.Matrix4d; +import org.jogamp.vecmath.SingularMatrixException; +import org.jogamp.vecmath.Tuple4f; +import org.jogamp.vecmath.Vector4f; + +/** class that demands single threading and uses deburners, don't touch if you don't understand, it will be bad... + * + * @author phil + * + */ +class Jogl2es2MatrixUtil +{ + + /** + * Possibly faster + * http://stackoverflow.com/questions/983999/simple-3x3-matrix-inverse-code-c + */ + + public static void transposeInvert(Matrix3d m, Matrix3d out) + { + double determinant = m.determinant(); + if (determinant > 0) + { + double invdet = 1 / determinant; + out.m00 = (m.m11 * m.m22 - m.m21 * m.m12) * invdet; + out.m10 = -(m.m01 * m.m22 - m.m02 * m.m21) * invdet; + out.m20 = (m.m01 * m.m12 - m.m02 * m.m11) * invdet; + out.m01 = -(m.m10 * m.m22 - m.m12 * m.m20) * invdet; + out.m11 = (m.m00 * m.m22 - m.m02 * m.m20) * invdet; + out.m21 = -(m.m00 * m.m12 - m.m10 * m.m02) * invdet; + out.m02 = (m.m10 * m.m21 - m.m20 * m.m11) * invdet; + out.m12 = -(m.m00 * m.m21 - m.m20 * m.m01) * invdet; + out.m22 = (m.m00 * m.m11 - m.m10 * m.m01) * invdet; + } + else + { + out.setIdentity(); + } + } + + /** + * Only upper left 3x3 copied and transformed + * @param m + * @param out + */ + + public static void transposeInvert(Matrix4d m, Matrix3d out) + { + double determinant = m.determinant(); + if (determinant > 0) + { + double invdet = 1 / determinant; + out.m00 = (m.m11 * m.m22 - m.m21 * m.m12) * invdet; + out.m10 = -(m.m01 * m.m22 - m.m02 * m.m21) * invdet; + out.m20 = (m.m01 * m.m12 - m.m02 * m.m11) * invdet; + out.m01 = -(m.m10 * m.m22 - m.m12 * m.m20) * invdet; + out.m11 = (m.m00 * m.m22 - m.m02 * m.m20) * invdet; + out.m21 = -(m.m00 * m.m12 - m.m10 * m.m02) * invdet; + out.m02 = (m.m10 * m.m21 - m.m20 * m.m11) * invdet; + out.m12 = -(m.m00 * m.m21 - m.m20 * m.m01) * invdet; + out.m22 = (m.m00 * m.m11 - m.m10 * m.m01) * invdet; + } + else + { + out.setIdentity(); + } + } + + double result3[] = new double[9]; + int row_perm3[] = new int[3]; + double[] tmp3 = new double[9]; // scratch matrix + //@See Matrix3d + + final void invertGeneral3(Matrix3d thisM, Matrix3d m1) + { + for (int i = 0; i < 3; i++) + row_perm3[i] = 0; + + for (int i = 0; i < 9; i++) + result3[i] = 0.0; + + // Use LU decomposition and backsubstitution code specifically + // for floating-point 3x3 matrices. + + // Copy source matrix to t1tmp + tmp3[0] = m1.m00; + tmp3[1] = m1.m01; + tmp3[2] = m1.m02; + + tmp3[3] = m1.m10; + tmp3[4] = m1.m11; + tmp3[5] = m1.m12; + + tmp3[6] = m1.m20; + tmp3[7] = m1.m21; + tmp3[8] = m1.m22; + + // Calculate LU decomposition: Is the matrix singular? + if (!luDecomposition3(tmp3, row_perm3)) + { + // Matrix has no inverse + throw new SingularMatrixException("!luDecomposition(tmp, row_perm)"); + } + + // Perform back substitution on the identity matrix + + result3[0] = 1.0; + result3[4] = 1.0; + result3[8] = 1.0; + luBacksubstitution3(tmp3, row_perm3, result3); + + thisM.m00 = result3[0]; + thisM.m01 = result3[1]; + thisM.m02 = result3[2]; + + thisM.m10 = result3[3]; + thisM.m11 = result3[4]; + thisM.m12 = result3[5]; + + thisM.m20 = result3[6]; + thisM.m21 = result3[7]; + thisM.m22 = result3[8]; + + } + + double row_scale3[] = new double[3]; + + //@See Matrix3d + boolean luDecomposition3(double[] matrix0, int[] row_perm) + { + for (int i = 0; i < 3; i++) + row_scale3[i] = 0.0; + // Determine implicit scaling information by looping over rows + { + int i, j; + int ptr, rs; + double big, temp; + + ptr = 0; + rs = 0; + + // For each row ... + i = 3; + while (i-- != 0) + { + big = 0.0; + + // For each column, find the largest element in the row + j = 3; + while (j-- != 0) + { + temp = matrix0[ptr++]; + temp = Math.abs(temp); + if (temp > big) + { + big = temp; + } + } + + // Is the matrix singular? + if (big == 0.0) + { + return false; + } + row_scale4[rs++] = 1.0 / big; + } + } + + { + int j; + int mtx; + + mtx = 0; + + // For all columns, execute Crout's method + for (j = 0; j < 3; j++) + { + int i, imax, k; + int target, p1, p2; + double sum, big, temp; + + // Determine elements of upper diagonal matrix U + for (i = 0; i < j; i++) + { + target = mtx + (3 * i) + j; + sum = matrix0[target]; + k = i; + p1 = mtx + (3 * i); + p2 = mtx + j; + while (k-- != 0) + { + sum -= matrix0[p1] * matrix0[p2]; + p1++; + p2 += 3; + } + matrix0[target] = sum; + } + + // Search for largest pivot element and calculate + // intermediate elements of lower diagonal matrix L. + big = 0.0; + imax = -1; + for (i = j; i < 3; i++) + { + target = mtx + (3 * i) + j; + sum = matrix0[target]; + k = j; + p1 = mtx + (3 * i); + p2 = mtx + j; + while (k-- != 0) + { + sum -= matrix0[p1] * matrix0[p2]; + p1++; + p2 += 3; + } + matrix0[target] = sum; + + // Is this the best pivot so far? + if ((temp = row_scale3[i] * Math.abs(sum)) >= big) + { + big = temp; + imax = i; + } + } + + if (imax < 0) + { + throw new RuntimeException("imax < 0"); + } + + // Is a row exchange necessary? + if (j != imax) + { + // Yes: exchange rows + k = 3; + p1 = mtx + (3 * imax); + p2 = mtx + (3 * j); + while (k-- != 0) + { + temp = matrix0[p1]; + matrix0[p1++] = matrix0[p2]; + matrix0[p2++] = temp; + } + + // Record change in scale factor + row_scale3[imax] = row_scale3[j]; + } + + // Record row permutation + row_perm[j] = imax; + + // Is the matrix singular + if (matrix0[(mtx + (3 * j) + j)] == 0.0) + { + return false; + } + + // Divide elements of lower diagonal matrix L by pivot + if (j != (3 - 1)) + { + temp = 1.0 / (matrix0[(mtx + (3 * j) + j)]); + target = mtx + (3 * (j + 1)) + j; + i = 2 - j; + while (i-- != 0) + { + matrix0[target] *= temp; + target += 3; + } + } + } + } + + return true; + } + + //@See Matrix3d + void luBacksubstitution3(double[] matrix1, int[] row_perm, double[] matrix2) + { + int i, ii, ip, j, k; + int rp; + int cv, rv; + + // rp = row_perm; + rp = 0; + + // For each column vector of matrix2 ... + for (k = 0; k < 3; k++) + { + // cv = &(matrix2[0][k]); + cv = k; + ii = -1; + + // Forward substitution + for (i = 0; i < 3; i++) + { + double sum; + + ip = row_perm[rp + i]; + sum = matrix2[cv + 3 * ip]; + matrix2[cv + 3 * ip] = matrix2[cv + 3 * i]; + if (ii >= 0) + { + // rv = &(matrix1[i][0]); + rv = i * 3; + for (j = ii; j <= i - 1; j++) + { + sum -= matrix1[rv + j] * matrix2[cv + 3 * j]; + } + } + else if (sum != 0.0) + { + ii = i; + } + matrix2[cv + 3 * i] = sum; + } + + // Backsubstitution + // rv = &(matrix1[3][0]); + rv = 2 * 3; + matrix2[cv + 3 * 2] /= matrix1[rv + 2]; + + rv -= 3; + matrix2[cv + 3 * 1] = (matrix2[cv + 3 * 1] - matrix1[rv + 2] * matrix2[cv + 3 * 2]) / matrix1[rv + 1]; + + rv -= 3; + matrix2[cv + 4 * 0] = (matrix2[cv + 3 * 0] - matrix1[rv + 1] * matrix2[cv + 3 * 1] - matrix1[rv + 2] * matrix2[cv + 3 * 2]) + / matrix1[rv + 0]; + + } + } + + double result4[] = new double[16]; + int row_perm4[] = new int[4]; + double[] tmp4 = new double[16]; // scratch matrix + + final void invertGeneral4(Matrix4d thisM, Matrix4d m1) + { + for (int i = 0; i < 4; i++) + row_perm4[i] = 0; + + for (int i = 0; i < 16; i++) + result4[i] = 0.0; + + // Use LU decomposition and backsubstitution code specifically + // for floating-point 4x4 matrices. + + // Copy source matrix to t1tmp + tmp4[0] = m1.m00; + tmp4[1] = m1.m01; + tmp4[2] = m1.m02; + tmp4[3] = m1.m03; + + tmp4[4] = m1.m10; + tmp4[5] = m1.m11; + tmp4[6] = m1.m12; + tmp4[7] = m1.m13; + + tmp4[8] = m1.m20; + tmp4[9] = m1.m21; + tmp4[10] = m1.m22; + tmp4[11] = m1.m23; + + tmp4[12] = m1.m30; + tmp4[13] = m1.m31; + tmp4[14] = m1.m32; + tmp4[15] = m1.m33; + + // Calculate LU decomposition: Is the matrix singular? + if (!luDecomposition4(tmp4, row_perm4)) + { + // Matrix has no inverse + throw new SingularMatrixException("luDecomposition4(tmp4, row_perm4)"); + } + + // Perform back substitution on the identity matrix + result4[0] = 1.0; + result4[5] = 1.0; + result4[10] = 1.0; + result4[15] = 1.0; + luBacksubstitution4(tmp4, row_perm4, result4); + + thisM.m00 = result4[0]; + thisM.m01 = result4[1]; + thisM.m02 = result4[2]; + thisM.m03 = result4[3]; + + thisM.m10 = result4[4]; + thisM.m11 = result4[5]; + thisM.m12 = result4[6]; + thisM.m13 = result4[7]; + + thisM.m20 = result4[8]; + thisM.m21 = result4[9]; + thisM.m22 = result4[10]; + thisM.m23 = result4[11]; + + thisM.m30 = result4[12]; + thisM.m31 = result4[13]; + thisM.m32 = result4[14]; + thisM.m33 = result4[15]; + + } + + double row_scale4[] = new double[4]; + + boolean luDecomposition4(double[] matrix0, int[] row_perm) + { + for (int i = 0; i < 4; i++) + row_scale4[i] = 0.0; + // Determine implicit scaling information by looping over rows + { + int i, j; + int ptr, rs; + double big, temp; + + ptr = 0; + rs = 0; + + // For each row ... + i = 4; + while (i-- != 0) + { + big = 0.0; + + // For each column, find the largest element in the row + j = 4; + while (j-- != 0) + { + temp = matrix0[ptr++]; + temp = Math.abs(temp); + if (temp > big) + { + big = temp; + } + } + + // Is the matrix singular? + if (big == 0.0) + { + return false; + } + row_scale4[rs++] = 1.0 / big; + } + } + + { + int j; + int mtx; + + mtx = 0; + + // For all columns, execute Crout's method + for (j = 0; j < 4; j++) + { + int i, imax, k; + int target, p1, p2; + double sum, big, temp; + + // Determine elements of upper diagonal matrix U + for (i = 0; i < j; i++) + { + target = mtx + (4 * i) + j; + sum = matrix0[target]; + k = i; + p1 = mtx + (4 * i); + p2 = mtx + j; + while (k-- != 0) + { + sum -= matrix0[p1] * matrix0[p2]; + p1++; + p2 += 4; + } + matrix0[target] = sum; + } + + // Search for largest pivot element and calculate + // intermediate elements of lower diagonal matrix L. + big = 0.0; + imax = -1; + for (i = j; i < 4; i++) + { + target = mtx + (4 * i) + j; + sum = matrix0[target]; + k = j; + p1 = mtx + (4 * i); + p2 = mtx + j; + while (k-- != 0) + { + sum -= matrix0[p1] * matrix0[p2]; + p1++; + p2 += 4; + } + matrix0[target] = sum; + + // Is this the best pivot so far? + if ((temp = row_scale4[i] * Math.abs(sum)) >= big) + { + big = temp; + imax = i; + } + } + + if (imax < 0) + { + throw new RuntimeException("(imax < 0)"); + } + + // Is a row exchange necessary? + if (j != imax) + { + // Yes: exchange rows + k = 4; + p1 = mtx + (4 * imax); + p2 = mtx + (4 * j); + while (k-- != 0) + { + temp = matrix0[p1]; + matrix0[p1++] = matrix0[p2]; + matrix0[p2++] = temp; + } + + // Record change in scale factor + row_scale4[imax] = row_scale4[j]; + } + + // Record row permutation + row_perm[j] = imax; + + // Is the matrix singular + if (matrix0[(mtx + (4 * j) + j)] == 0.0) + { + return false; + } + + // Divide elements of lower diagonal matrix L by pivot + if (j != (4 - 1)) + { + temp = 1.0 / (matrix0[(mtx + (4 * j) + j)]); + target = mtx + (4 * (j + 1)) + j; + i = 3 - j; + while (i-- != 0) + { + matrix0[target] *= temp; + target += 4; + } + } + } + } + + return true; + } + + void luBacksubstitution4(double[] matrix1, int[] row_perm, double[] matrix2) + { + + int i, ii, ip, j, k; + int rp; + int cv, rv; + + // rp = row_perm; + rp = 0; + + // For each column vector of matrix2 ... + for (k = 0; k < 4; k++) + { + // cv = &(matrix2[0][k]); + cv = k; + ii = -1; + + // Forward substitution + for (i = 0; i < 4; i++) + { + double sum; + + ip = row_perm[rp + i]; + sum = matrix2[cv + 4 * ip]; + matrix2[cv + 4 * ip] = matrix2[cv + 4 * i]; + if (ii >= 0) + { + // rv = &(matrix1[i][0]); + rv = i * 4; + for (j = ii; j <= i - 1; j++) + { + sum -= matrix1[rv + j] * matrix2[cv + 4 * j]; + } + } + else if (sum != 0.0) + { + ii = i; + } + matrix2[cv + 4 * i] = sum; + } + + // Backsubstitution + // rv = &(matrix1[3][0]); + rv = 3 * 4; + matrix2[cv + 4 * 3] /= matrix1[rv + 3]; + + rv -= 4; + matrix2[cv + 4 * 2] = (matrix2[cv + 4 * 2] - matrix1[rv + 3] * matrix2[cv + 4 * 3]) / matrix1[rv + 2]; + + rv -= 4; + matrix2[cv + 4 * 1] = (matrix2[cv + 4 * 1] - matrix1[rv + 2] * matrix2[cv + 4 * 2] - matrix1[rv + 3] * matrix2[cv + 4 * 3]) + / matrix1[rv + 1]; + + rv -= 4; + matrix2[cv + 4 * 0] = (matrix2[cv + 4 * 0] - matrix1[rv + 1] * matrix2[cv + 4 * 1] - matrix1[rv + 2] * matrix2[cv + 4 * 2] + - matrix1[rv + 3] * matrix2[cv + 4 * 3]) / matrix1[rv + 0]; + } + } + + public final void transform(Matrix4d m, Tuple4f vecOut) + { + float x, y, z; + + x = (float) (m.m00 * vecOut.x + m.m01 * vecOut.y + m.m02 * vecOut.z + m.m03 * vecOut.w); + y = (float) (m.m10 * vecOut.x + m.m11 * vecOut.y + m.m12 * vecOut.z + m.m13 * vecOut.w); + z = (float) (m.m20 * vecOut.x + m.m21 * vecOut.y + m.m22 * vecOut.z + m.m23 * vecOut.w); + vecOut.w = (float) (m.m30 * vecOut.x + m.m31 * vecOut.y + m.m32 * vecOut.z + m.m33 * vecOut.w); + vecOut.x = x; + vecOut.y = y; + vecOut.z = z; + } + + //Oh lordy lordy yo' betta swear yo' single freadin' !!! + + public double[] deburnV2 = null;//deburners + + public Matrix4d deburnV = new Matrix4d();//deburners + public Matrix4d deburnM = new Matrix4d(); + public float[] tempMat9 = new float[9]; + public float[] tempMat12 = new float[12]; + public float[] tempMat16 = new float[16]; + public double[] tempMatD9 = new double[9]; + + public float[] toArray(Matrix4d m) + { + tempMat16[0] = (float) m.m00; + tempMat16[1] = (float) m.m01; + tempMat16[2] = (float) m.m02; + tempMat16[3] = (float) m.m03; + tempMat16[4] = (float) m.m10; + tempMat16[5] = (float) m.m11; + tempMat16[6] = (float) m.m12; + tempMat16[7] = (float) m.m13; + tempMat16[8] = (float) m.m20; + tempMat16[9] = (float) m.m21; + tempMat16[10] = (float) m.m22; + tempMat16[11] = (float) m.m23; + tempMat16[12] = (float) m.m30; + tempMat16[13] = (float) m.m31; + tempMat16[14] = (float) m.m32; + tempMat16[15] = (float) m.m33; + return tempMat16; + } + + public static float[] toArray(Matrix4d m, float[] a) + { + a[0] = (float) m.m00; + a[1] = (float) m.m01; + a[2] = (float) m.m02; + a[3] = (float) m.m03; + a[4] = (float) m.m10; + a[5] = (float) m.m11; + a[6] = (float) m.m12; + a[7] = (float) m.m13; + a[8] = (float) m.m20; + a[9] = (float) m.m21; + a[10] = (float) m.m22; + a[11] = (float) m.m23; + a[12] = (float) m.m30; + a[13] = (float) m.m31; + a[14] = (float) m.m32; + a[15] = (float) m.m33; + + return a; + } + + public float[] toArray(Matrix3d m) + { + tempMat9[0] = (float) m.m00; + tempMat9[1] = (float) m.m01; + tempMat9[2] = (float) m.m02; + tempMat9[3] = (float) m.m10; + tempMat9[4] = (float) m.m11; + tempMat9[5] = (float) m.m12; + tempMat9[6] = (float) m.m20; + tempMat9[7] = (float) m.m21; + tempMat9[8] = (float) m.m22; + return tempMat9; + + } + + public static float[] toArray(Matrix3d m, float[] a) + { + a[0] = (float) m.m00; + a[1] = (float) m.m01; + a[2] = (float) m.m02; + a[3] = (float) m.m10; + a[4] = (float) m.m11; + a[5] = (float) m.m12; + a[6] = (float) m.m20; + a[7] = (float) m.m21; + a[8] = (float) m.m22; + + return a; + } + + public float[] toArray3x4(Matrix3d m) + { + return toArray3x4(m, tempMat12); + } + + public static float[] toArray3x4(Matrix3d m, float[] a) + { + a[0] = (float) m.m00; + a[1] = (float) m.m01; + a[2] = (float) m.m02; + a[3] = 0f; + a[4] = (float) m.m10; + a[5] = (float) m.m11; + a[6] = (float) m.m12; + a[7] = 0f; + a[8] = (float) m.m20; + a[9] = (float) m.m21; + a[10] = (float) m.m22; + a[11] = 0f; + + return a; + } + + public double[] toArray3x3(Matrix4d m) + { + return toArray3x3(m, tempMatD9); + } + + public static double[] toArray3x3(Matrix4d m, double[] a) + { + a[0] = m.m00; + a[1] = m.m01; + a[2] = m.m02; + a[3] = m.m10; + a[4] = m.m11; + a[5] = m.m12; + a[6] = m.m20; + a[7] = m.m21; + a[8] = m.m22; + + return a; + } + + public void invert(Matrix3d m1) + { + try + { + invertGeneral3(m1, m1); + } + catch (Exception e) + { + //fine, move along + m1.setIdentity(); + } + } + + public void invert(Matrix4d m1) + { + try + { + invertGeneral4(m1, m1); + } + catch (Exception e) + { + //fine, move along + m1.setIdentity(); + } + } + + //More single threaded death-defying gear + private Vector4f tmpV4f = new Vector4f();; + + public Vector4f transform(Matrix4d m1, Matrix4d m2, float tx, float ty, float tz, float tw) + { + tmpV4f.set(tx, ty, tz, tw); + transform(m1, tmpV4f); + transform(m2, tmpV4f); + return tmpV4f; + } + + private FloatBuffer matFB4x4; + + public FloatBuffer toFB4(float[] f) + { + if (matFB4x4 == null) + { + ByteBuffer bb = ByteBuffer.allocateDirect(16 * 4); + bb.order(ByteOrder.nativeOrder()); + matFB4x4 = bb.asFloatBuffer(); + } + matFB4x4.position(0); + matFB4x4.put(f); + matFB4x4.position(0); + return matFB4x4; + } + + public FloatBuffer toFB3(float[] f) + { + if (matFB3x3 == null) + { + ByteBuffer bb = ByteBuffer.allocateDirect(16 * 4); + bb.order(ByteOrder.nativeOrder()); + matFB3x3 = bb.asFloatBuffer(); + } + matFB3x3.position(0); + matFB3x3.put(f); + matFB3x3.position(0); + return matFB3x3; + } + + public FloatBuffer toFB(Matrix4d m) + { + if (matFB4x4 == null) + { + ByteBuffer bb = ByteBuffer.allocateDirect(16 * 4); + bb.order(ByteOrder.nativeOrder()); + matFB4x4 = bb.asFloatBuffer(); + } + matFB4x4.position(0); + matFB4x4.put(toArray(m)); + matFB4x4.position(0); + return matFB4x4; + } + + private FloatBuffer matFB3x3; + + public FloatBuffer toFB(Matrix3d m) + { + if (matFB3x3 == null) + { + ByteBuffer bb = ByteBuffer.allocateDirect(9 * 4); + bb.order(ByteOrder.nativeOrder()); + matFB3x3 = bb.asFloatBuffer(); + } + matFB3x3.position(0); + matFB3x3.put(toArray(m)); + matFB3x3.position(0); + return matFB3x3; + } + + public static float[] transposeInPlace(float[] src) + { + if (src.length == 9) + { + float temp; + + temp = src[3]; + src[3] = src[1]; + src[1] = temp; + + temp = src[6]; + src[6] = src[2]; + src[2] = temp; + + temp = src[7]; + src[7] = src[5]; + src[5] = temp; + + } + else if (src.length == 16) + { + float v1 = src[1]; + float v2 = src[2]; + float v3 = src[3]; + float v6 = src[6]; + float v7 = src[7]; + float v11 = src[11]; + + //src[0] = src[0]; + src[1] = src[4]; + src[2] = src[8]; + src[3] = src[12]; + src[4] = v1; + //src[5] = src[5]; + src[6] = src[9]; + src[7] = src[13]; + src[8] = v2; + src[9] = v6; + //src[10] = src[10]; + src[11] = src[14]; + src[12] = v3; + src[13] = v7; + src[14] = v11; + //src[15] = src[15]; + } + else + { + throw new UnsupportedOperationException("Only 9 or 16 length float arrays can be transposed!"); + } + return src; + + } + + // ignores the higher 16 bits + public static float halfToFloat(int hbits) + { + int mant = hbits & 0x03ff; // 10 bits mantissa + int exp = hbits & 0x7c00; // 5 bits exponent + if (exp == 0x7c00) // NaN/Inf + exp = 0x3fc00; // -> NaN/Inf + else if (exp != 0) // normalized value + { + exp += 0x1c000; // exp - 15 + 127 + if (mant == 0 && exp > 0x1c400) // smooth transition + return Float.intBitsToFloat((hbits & 0x8000) << 16 | exp << 13 | 0x3ff); + } + else if (mant != 0) // && exp==0 -> subnormal + { + exp = 0x1c400; // make it normal + do + { + mant <<= 1; // mantissa * 2 + exp -= 0x400; // decrease exp by 1 + } + while ((mant & 0x400) == 0); // while not normal + mant &= 0x3ff; // discard subnormal bit + } // else +/-0 -> +/-0 + return Float.intBitsToFloat( // combine all parts + (hbits & 0x8000) << 16 // sign << ( 31 - 15 ) + | (exp | mant) << 13); // value << ( 23 - 10 ) + } + + // returns all higher 16 bits as 0 for all results + public static int halfFromFloat(float fval) + { + int fbits = Float.floatToIntBits(fval); + int sign = fbits >>> 16 & 0x8000; // sign only + int val = (fbits & 0x7fffffff) + 0x1000; // rounded value + + if (val >= 0x47800000) // might be or become NaN/Inf + { // avoid Inf due to rounding + if ((fbits & 0x7fffffff) >= 0x47800000) + { // is or must become NaN/Inf + if (val < 0x7f800000) // was value but too large + return sign | 0x7c00; // make it +/-Inf + return sign | 0x7c00 | // remains +/-Inf or NaN + (fbits & 0x007fffff) >>> 13; // keep NaN (and Inf) bits + } + return sign | 0x7bff; // unrounded not quite Inf + } + if (val >= 0x38800000) // remains normalized value + return sign | val - 0x38000000 >>> 13; // exp - 127 + 15 + if (val < 0x33000000) // too small for subnormal + return sign; // becomes +/-0 + val = (fbits & 0x7fffffff) >>> 23; // tmp exp for subnormal calc + return sign | ((fbits & 0x7fffff | 0x800000) // add subnormal bit + + (0x800000 >>> val - 102) // round depending on cut off + >>> 126 - val); // div by 2^(1-(exp-127+15)) and >> 13 | exp=0 + } +}
\ No newline at end of file diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java b/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java new file mode 100644 index 0000000..210b7a3 --- /dev/null +++ b/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2016 JogAmp Community. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +package org.jogamp.java3d; + +import java.util.HashSet; + +public class Jogl2es2PerFrameStats +{ + public long endOfPrevFrameTime; + + public HashSet<ShaderProgramId> usedPrograms = new HashSet<ShaderProgramId>(); + //public ArrayList<ShaderProgramId> usedPrograms = new ArrayList<ShaderProgramId>(); + //public HashSet<String> usedProgramNames = new HashSet<String>(); + //TODO: how do I get these? + //public HashMap<ShaderProgramId, String> usedProgramNames = new HashMap<ShaderProgramId, String>(); + + public int geoToClearBuffers; + public int glDrawStripArrays; + public int glDrawStripArraysStrips; + public int glDrawArrays; + public int glDrawStripElements; + public int glDrawStripElementsStrips; + public int glDrawElements; + public int executeSkippedNoShaderProgram; + public int setFFPAttributes; + public int programToLocationData; + public int enableTexCoordPointer; + public int createGLSLShader; + public int createGLSLShaderProgram; + public int compileGLSLShader; + public int destroyGLSLShader; + public int destroyGLSLShaderProgram; + public int linkGLSLShaderProgram; + public int useGLSLShaderProgram; + public int bindGLSLVertexAttrName; + public int lookupGLSLShaderAttrNames; + public int updateDirectionalLight; + public int updatePointLight; + public int updateSpotLight; + public int updateExponentialFog; + public int updateLinearFog; + public int disableFog; + public int setFogEnableFlag; + public int updateLineAttributes; + public int resetLineAttributes; + public int updateMaterial; + public int updateMaterialColor; + public int updateColoringAttributes; + public int resetColoringAttributes; + public int updatePointAttributes; + public int resetPointAttributes; + public int updatePolygonAttributes; + public int resetPolygonAttributes; + public int updateRenderingAttributes; + public int resetRenderingAttributes; + public int updateTransparencyAttributes; + public int resetTransparency; + public int updateTextureAttributes; + public int resetTextureAttributes; + public int resetTexCoordGeneration; + public int updateTextureUnitState; + public int bindTexture2D; + public int bindTextureCubeMap; + public int setBlendColor; + public int setBlendFunc; + public int setFullSceneAntialiasing; + public int setLightEnables; + public int setSceneAmbient; + public int activeTextureUnit; + public int resetTextureNative; + public int useCtx; + public int releaseCtx; + public int clear; + public int setModelViewMatrix; + public int setProjectionMatrix; + public int setViewport; + public int freeTexture; + public int generateTexID; + public int setDepthBufferWriteEnable; + public int redundantUseProgram; + + public int coordCount; + public int indexCount; + public int glVertexAttribPointerNormals; + public int glVertexAttribPointerUserAttribs; + public int glVertexAttribPointerColor; + public int glVertexAttribPointerCoord; + public int glBufferData; + public int glBufferSubData; + public int glDisableVertexAttribArray; + + public int modelMatrixUpdated; + public int glModelViewMatrixUpdated; + public int glModelViewProjectionMatrixUpdated; + public int glNormalMatrixUpdated; + public int glModelViewMatrixInverseUpdated; + + public int modelMatrixSkipped; + public int glModelViewMatrixSkipped; + public int glModelViewProjectionMatrixSkipped; + public int glNormalMatrixSkipped; + public int glModelViewMatrixInverseSkipped; + + public int interleavedBufferCreated; + + public int glVertexAttribPointerInterleaved; + + public long setViewportTime; + + public long syncRenderTime; + + public void outputPerFrameData() + { + boolean highInterestOnly = true; + + System.out.println("coordCount " + coordCount + " indexCount " + indexCount); + System.out.println("glDrawStripArrays " + glDrawStripArrays + "\t made up of glDrawStripArraysStrips " + glDrawStripArraysStrips); + System.out.println("glDrawArrays " + glDrawArrays); + System.out.println( + "glDrawStripElements " + glDrawStripElements + "\t made up of glDrawStripElementsStrips " + glDrawStripElementsStrips); + System.out.println("glDrawElements " + glDrawElements); + System.out.println("glVertexAttribPointerCoord " + glVertexAttribPointerCoord); + System.out.println("glVertexAttribPointerNormals " + glVertexAttribPointerNormals); + System.out.println("glVertexAttribPointerColor " + glVertexAttribPointerColor); + System.out.println("glVertexAttribPointerUserAttribs " + glVertexAttribPointerUserAttribs); + System.out.println("enableTexCoordPointer " + enableTexCoordPointer); + System.out.println("glBufferData " + glBufferData + " glBufferSubData " + glBufferSubData); + System.out.println("glVertexAttribPointerInterleaved " + glVertexAttribPointerInterleaved); + System.out.println("interleavedBufferCreated " + interleavedBufferCreated); + System.out.println("---"); + System.out.println("setModelViewMatrix " + setModelViewMatrix); + System.out.println("setFFPAttributes " + setFFPAttributes); + System.out.println("executeSkippedNoShaderProgram " + executeSkippedNoShaderProgram); + + System.out.println("modelMatrixUpdated " + modelMatrixUpdated + " modelMatrixSkipped " + modelMatrixSkipped); + System.out + .println("glModelViewMatrixUpdated " + glModelViewMatrixUpdated + " glModelViewMatrixSkipped " + glModelViewMatrixSkipped); + System.out.println("glModelViewProjectionMatrixUpdated " + glModelViewProjectionMatrixUpdated + + " glModelViewProjectionMatrixSkipped " + glModelViewProjectionMatrixSkipped); + System.out.println("glNormalMatrixUpdated " + glNormalMatrixUpdated + " glNormalMatrixSkipped " + glNormalMatrixSkipped); + System.out.println("---"); + if (!highInterestOnly) + { + System.out.println("glDisableVertexAttribArray " + glDisableVertexAttribArray + " note native called commented out, trouble?"); + System.out.println("geoToClearBuffers " + geoToClearBuffers); + System.out.println("programToLocationData " + programToLocationData); + System.out.print("createGLSLShader " + createGLSLShader); + System.out.print("\tcreateGLSLShaderProgram " + createGLSLShaderProgram); + System.out.print("\tcompileGLSLShader " + compileGLSLShader); + System.out.print("\tdestroyGLSLShader " + destroyGLSLShader); + System.out.print("\tdestroyGLSLShaderProgram " + destroyGLSLShaderProgram); + System.out.print("\tlinkGLSLShaderProgram " + linkGLSLShaderProgram); + System.out.print("\tbindGLSLVertexAttrName " + bindGLSLVertexAttrName); + System.out.println("\tlookupGLSLShaderAttrNames " + lookupGLSLShaderAttrNames); + System.out.print("updateDirectionalLight " + updateDirectionalLight); + System.out.print("\tupdatePointLight " + updatePointLight); + System.out.println("\tupdateSpotLight " + updateSpotLight); + System.out.print("updateExponentialFog " + updateExponentialFog); + System.out.print("\tupdateLinearFog " + updateLinearFog); + System.out.print("\tdisableFog " + disableFog); + System.out.println("\tsetFogEnableFlag " + setFogEnableFlag); + System.out.print("updateLineAttributes " + updateLineAttributes); + System.out.println("\tresetLineAttributes " + resetLineAttributes); + System.out.print("updateMaterial " + updateMaterial); + System.out.println("\tupdateMaterialColor " + updateMaterialColor); + System.out.print("updateColoringAttributes " + updateColoringAttributes); + System.out.println("\tresetColoringAttributes " + resetColoringAttributes); + System.out.print("updatePointAttributes " + updatePointAttributes); + System.out.println("\tresetPointAttributes " + resetPointAttributes); + System.out.print("updatePolygonAttributes " + updatePolygonAttributes); + System.out.println("\tresetPolygonAttributes " + resetPolygonAttributes); + System.out.print("updateRenderingAttributes " + updateRenderingAttributes); + System.out.println("\tresetRenderingAttributes " + resetRenderingAttributes); + System.out.println("setBlendColor " + setBlendColor); + System.out.println("setFullSceneAntialiasing " + setFullSceneAntialiasing); + System.out.println("setLightEnables " + setLightEnables); + System.out.println("setSceneAmbient " + setSceneAmbient); + System.out.println("resetTexCoordGeneration " + resetTexCoordGeneration); + System.out.println("freeTexture " + freeTexture); + System.out.println("generateTexID " + generateTexID); + System.out.println("useCtx " + useCtx); + System.out.println("releaseCtx " + releaseCtx); + System.out.println("clear " + clear); + System.out.println("setViewport " + setViewport); + System.out.println("setProjectionMatrix " + setProjectionMatrix); + } + + System.out.print("updateTransparencyAttributes " + updateTransparencyAttributes); + System.out.println("\tresetTransparency " + resetTransparency); + System.out.print("updateTextureAttributes " + updateTextureAttributes); + System.out.println("\tresetTextureAttributes " + resetTextureAttributes); + System.out.println("updateTextureUnitState " + updateTextureUnitState); + System.out.println("bindTexture2D " + bindTexture2D + "\tbindTextureCubeMap " + bindTextureCubeMap); + System.out.println("setBlendFunc " + setBlendFunc); + System.out.println("activeTextureUnit " + activeTextureUnit + "\tresetTextureNative " + resetTextureNative); + System.out.println("setDepthBufferWriteEnable " + setDepthBufferWriteEnable); + System.out.println("useGLSLShaderProgram " + useGLSLShaderProgram + " redundantUseProgram " + redundantUseProgram); + + //for (ShaderProgramId id : usedPrograms) + // System.out.println("ShaderProgramId " + ((JoglShaderObject) id).getValue()); + if ((syncRenderTime - setViewportTime) != 0) + { + System.out.println("time in frame (not in glFinish) " + (syncRenderTime - setViewportTime) + // + " = (ms) " + ((syncRenderTime - setViewportTime) / 1000000L));// + // + // " = fps: " + (1000 / ((syncRenderTime - setViewportTime) / 1000000L))); + } + + long now = System.nanoTime(); + System.out.println("time since end of previous frame (ns) " + (now - endOfPrevFrameTime) + // + " = (ms) " + ((now - endOfPrevFrameTime) / 1000000L) + // + " = fps: " + (1000 / ((now - endOfPrevFrameTime) / 1000000L))); + } +}
\ No newline at end of file diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java new file mode 100644 index 0000000..934e9b8 --- /dev/null +++ b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java @@ -0,0 +1,9854 @@ +/* + * Copyright (c) 2016 JogAmp Community. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +package org.jogamp.java3d; + +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Dialog; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GraphicsConfigTemplate; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.Window; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.jogamp.java3d.Jogl2es2Context.GeometryData; +import org.jogamp.java3d.Jogl2es2Context.LocationData; +import org.jogamp.java3d.Jogl2es2Context.ProgramData; +import org.jogamp.java3d.Jogl2es2Context.glLightSource; +import org.jogamp.java3d.Jogl2es2Context.glLightSourceLocs; +import org.jogamp.vecmath.SingularMatrixException; +import org.jogamp.vecmath.Vector4f; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.Platform; +import com.jogamp.nativewindow.AbstractGraphicsDevice; +import com.jogamp.nativewindow.AbstractGraphicsScreen; +import com.jogamp.nativewindow.CapabilitiesChooser; +import com.jogamp.nativewindow.GraphicsConfigurationFactory; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.OffscreenLayerOption; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.UpstreamSurfaceHook; +import com.jogamp.nativewindow.VisualIDHolder; +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.awt.JAWTWindow; +import com.jogamp.opengl.DefaultGLCapabilitiesChooser; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL2ES3; +import com.jogamp.opengl.GL3; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLCapabilitiesChooser; +import com.jogamp.opengl.GLCapabilitiesImmutable; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.GLDrawable; +import com.jogamp.opengl.GLDrawableFactory; +import com.jogamp.opengl.GLException; +import com.jogamp.opengl.GLFBODrawable; +import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.Threading; + +/** + * Concrete implementation of Pipeline class for the GL2ES2 rendering pipeline. + */ +class Jogl2es2Pipeline extends Jogl2es2DEPPipeline +{ + //Note this is VERY expensive and should be false unless debugging + private static final boolean DO_OUTPUT_ERRORS = false; + // Currently prints for entry points already implemented + static final boolean VERBOSE = false; + // Debugging output for graphics configuration selection + private static final boolean DEBUG_CONFIG = false; + // Prints extra debugging information + private static final boolean EXTRA_DEBUGGING = false; + + private static final boolean OUTPUT_PER_FRAME_STATS = false; + + private static final boolean MINIMISE_NATIVE_CALLS_FFP = true; + + private static final boolean MINIMISE_NATIVE_CALLS_TRANSPARENCY = true; + private static final boolean MINIMISE_NATIVE_CALLS_TEXTURE = true; + + private static final boolean MINIMISE_NATIVE_SHADER = true; + private static final boolean MINIMISE_NATIVE_CALLS_OTHER = true; + + // This MUST be true on android fullscreen + // setPosition on a GLWindow can lock-up if true + // also with on and offscreen must be false too + private static final boolean NEVER_RELEASE_CONTEXT = false; + + /** + * Constructor for singleton JoglPipeline instance + */ + protected Jogl2es2Pipeline() + { + + } + + /** + * Initialize the pipeline + */ + @Override + void initialize(Pipeline.Type pipelineType) + { + super.initialize(pipelineType); + + // Java3D maintains strict control over which threads perform OpenGL work + Threading.disableSingleThreading(); + + profile = GLProfile.get(GLProfile.GL2ES2); + // profile = GLProfile.getMaxProgrammable(true); + + } + + // FIXME: ugly hack for buffer clearing on removal of a geometry + public void registerClearBuffers(Context ctx, GeometryArrayRetained geo) + { + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + synchronized (joglesctx.geoToClearBuffers) + { + joglesctx.geoToClearBuffers.add(geo); + } + } + + private static void doClearBuffers(Context ctx) + { + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + + if (joglesctx.geoToClearBuffers.size() > 0) + { + synchronized (joglesctx.geoToClearBuffers) + { + GL2ES2 gl = joglesctx.gl2es2(); + for (GeometryArrayRetained geo : joglesctx.geoToClearBuffers) + { + GeometryData gd = joglesctx.allGeometryData.get(geo.nativeId); + joglesctx.allGeometryData.remove(geo.nativeId); + geo.nativeId = -1; + + // TODO: why exactly is the same geo being removed twice? + if (gd != null) + { + if (gd.geoToIndBuf != -1) + + gl.glDeleteBuffers(1, new int[] { gd.geoToIndBuf }, 0); + if (gd.geoToCoordBuf != -1) + gl.glDeleteBuffers(1, new int[] { gd.geoToCoordBuf }, 0); + if (gd.geoToColorBuf != -1) + gl.glDeleteBuffers(1, new int[] { gd.geoToColorBuf }, 0); + if (gd.geoToNormalBuf != -1) + gl.glDeleteBuffers(1, new int[] { gd.geoToNormalBuf }, 0); + + int[] bufIds = gd.geoToIndStripBuf; + if (bufIds != null && bufIds.length > 0) + { + gl.glDeleteBuffers(bufIds.length, bufIds, 0); + } + + SparseArray<Integer> tcBufIds = gd.geoToTexCoordsBuf; + if (tcBufIds != null) + { + for (int i = 0; i < tcBufIds.size(); i++) + { + Integer tcBufId = tcBufIds.get(tcBufIds.keyAt(i)); + + if (tcBufId != null) + gl.glDeleteBuffers(1, new int[] { tcBufId.intValue() }, 0); + } + tcBufIds.clear(); + } + + SparseArray<Integer> vaBufIds = gd.geoToVertAttribBuf; + if (vaBufIds != null) + { + for (int i = 0; i < vaBufIds.size(); i++) + { + Integer vaBufId = vaBufIds.get(vaBufIds.keyAt(i)); + if (vaBufId != null) + gl.glDeleteBuffers(1, new int[] { vaBufId.intValue() }, 0); + } + vaBufIds.clear(); + } + + if (gd.interleavedBufId != -1) + gl.glDeleteBuffers(1, new int[] { gd.interleavedBufId }, 0); + + if (gd.vaoId != -1) + ((GL2ES3) gl).glDeleteVertexArrays(1, new int[] { gd.vaoId }, 0); + + } + + } + + if (OUTPUT_PER_FRAME_STATS) + joglesctx.perFrameStats.geoToClearBuffers = joglesctx.geoToClearBuffers.size(); + + joglesctx.geoToClearBuffers.clear(); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + } + } + + // --------------------------------------------------------------------- + + // + // GeometryArrayRetained methods + // + + // used for GeometryArrays by Copy or interleaved + @Override + void execute(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha, + boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount, int[] texCoordSetMap, + int texCoordSetMapLen, int[] texUnitOffset, int numActiveTexUnitState, int vertexAttrCount, int[] vertexAttrSizes, + float[] varray, float[] carray, int cDirty) + { + if (VERBOSE) + System.err.println("JoglPipeline.execute()"); + + executeGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, startVIndex, vcount, vformat, + texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnitState, vertexAttrCount, vertexAttrSizes, + varray, null, carray, cDirty); + } + + // used by GeometryArray by Reference in interleaved format with NIO buffer + @Override + void executeInterleavedBuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha, + boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount, int[] texCoordSetMap, + int texCoordSetMapLen, int[] texUnitOffset, int numActiveTexUnit, FloatBuffer varray, float[] cdata, int cdirty) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeInterleavedBuffer()"); + + executeGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, startVIndex, vcount, vformat, + texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnit, 0, null, null, varray, cdata, cdirty); + } + + private void executeGeometryArray(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha, + boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount, int[] texCoordSetMap, + int texCoordSetMapLen, int[] texCoordSetMapOffset, int numActiveTexUnitState, int vertexAttrCount, int[] vertexAttrSizes, + float[] varray, FloatBuffer varrayBuffer, float[] carray, int cDirty) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeGeometryArray()"); + + Jogl2es2Context ctx = (Jogl2es2Context) absCtx; + int shaderProgramId = ctx.shaderProgramId; + + if (shaderProgramId != -1) + { + GL2ES2 gl = ctx.gl2es2(); + ProgramData pd = ctx.programData; + LocationData locs = pd.programToLocationData; + + setFFPAttributes(ctx, gl, shaderProgramId, pd, vformat, ignoreVertexColors); + + int stride = 0, coordoff = 0, normoff = 0, coloroff = 0, texCoordoff = 0; + int texSize = 0, texStride = 0; + int vAttrOff = 0; + int vAttrStride = 0; + int bstride = 0, cbstride = 0; + + int[] sarray = null; + int[] start_array = null; + + if (EXTRA_DEBUGGING) + { + System.err.println("Vertex format: " + getVertexDescription(vformat)); + System.err.println("Geometry type: " + getGeometryDescription(geo_type)); + if (carray != null) + { + System.err.println(" Separate color array"); + } + else + { + System.err.println(" Colors (if any) interleaved"); + } + } + + if ((vformat & GeometryArray.COORDINATES) != 0) + { + stride += 3; + } + if ((vformat & GeometryArray.NORMALS) != 0) + { + stride += 3; + coordoff += 3; + } + if ((vformat & GeometryArray.COLOR) != 0) + { + if ((vformat & GeometryArray.WITH_ALPHA) != 0) + { + stride += 4; + normoff += 4; + coordoff += 4; + } + else + { + // Handle the case of executeInterleaved 3f + stride += 3; + normoff += 3; + coordoff += 3; + } + } + if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) + { + if (EXTRA_DEBUGGING) + { + System.err.println("Number of tex coord sets: " + texCoordSetCount); + } + if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) + { + texSize = 2; + texStride = 2 * texCoordSetCount; + } + else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) + { + texSize = 3; + texStride = 3 * texCoordSetCount; + } + else if ((vformat & GeometryArray.TEXTURE_COORDINATE_4) != 0) + { + texSize = 4; + texStride = 4 * texCoordSetCount; + } + stride += texStride; + normoff += texStride; + coloroff += texStride; + coordoff += texStride; + } + if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) + { + for (int i = 0; i < vertexAttrCount; i++) + { + vAttrStride += vertexAttrSizes[i]; + } + stride += vAttrStride; + normoff += vAttrStride; + coloroff += vAttrStride; + coordoff += vAttrStride; + texCoordoff += vAttrStride; + } + + bstride = stride * Buffers.SIZEOF_FLOAT; + + if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) + { + sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts; + start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices; + } + + // using byRef interleaved array and has a separate pointer, then .. + int cstride = stride; + if (carray != null) + { + cstride = 4; + } + + cbstride = cstride * Buffers.SIZEOF_FLOAT; + + int startVertex = stride * startVIndex; + int startClrs = cstride * startVIndex; + if (carray == null) + { + startClrs += coloroff; + } + + if (EXTRA_DEBUGGING) + { + System.err.println(" startVertex: " + startVertex); + System.err.println(" stride: " + stride); + System.err.println(" bstride: " + bstride); + System.err.println(" normoff: " + normoff); + System.err.println(" coloroff: " + coloroff); + System.err.println(" coordoff: " + coordoff); + System.err.println(" texCoordoff: " + texCoordoff); + } + + GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vcount, vformat, vformat, varrayBuffer, varray, startVertex, + varrayBuffer, carray, startClrs); + + // GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability + boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE) + || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE); + + // not required second time around for VAO (except morphable coords) + boolean bindingRequired = true; + // Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders + if (gl.isGL2ES3()) + { + GL2ES3 gl2es3 = (GL2ES3)gl; + if (gd.vaoId == -1) + { + int[] tmp = new int[1]; + gl2es3.glGenVertexArrays(1, tmp, 0); + gd.vaoId = tmp[0]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + bindingRequired = false; + } + gl2es3.glBindVertexArray(gd.vaoId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // refill the buffers in case of writeable data (morphable) + if (locs.glVertex != -1) + { + if (gd.geoToCoordBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + // rather than the morphable system above we should be able to use cDirty, but it appears to be wrong + // if ((cDirty & GeometryArrayRetained.COORDINATE_CHANGED) != 0) + if (morphable) + { + FloatBuffer verts = null; + // do we need to covert a float[] + if (varray != null) + { + verts = getVertexArrayBuffer(varray); + } + else + { + verts = varrayBuffer; + } + + verts.position(startVertex); + // Sometime the FloatBuffer is swapped out for bigger or smaller + if (gd.geoToCoordBufSize != verts.remaining()) + { + System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + verts.remaining() + + " un indexed ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " " + + geo.source + ", this is not nessasarily a problem"); + + int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete after re-bind + int prevBufId2 = gd.geoToCoordBuf2; + + int[] tmp = new int[2]; + gl.glGenBuffers(2, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + gd.geoToCoordBuf1 = tmp[0]; + gd.geoToCoordBuf2 = tmp[1]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW); + + gd.geoToCoordBufSize = verts.remaining(); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + //Notice no check for bindingRequired as we are altering the binding + //and previously used buffer is deleted AFTER re-bind + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glVertex); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + + gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + // work out the buffer to update and buffer to swap to + if (gd.geoToCoordBuf == gd.geoToCoordBuf1) + { + // update 1 but set to draw 2 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts); + gd.geoToCoordBuf = gd.geoToCoordBuf2; + } + else + { + // update 2 but set to draw 1 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts); + gd.geoToCoordBuf = gd.geoToCoordBuf1; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferSubData++; + } + } + } + } + else + { + throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE); + } + + // update other attributes if required + if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) + { + // if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE); + if (changable) + { + FloatBuffer verts = null; + FloatBuffer clrs = null; + // do we need to covert a float[] + if (varray != null) + { + verts = getVertexArrayBuffer(varray); + } + else + { + verts = varrayBuffer; + } + if (carray != null) + { + verts = getColorArrayBuffer(carray); + } + else + { + clrs = verts; + } + + clrs.position(0); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, clrs.remaining() * Float.SIZE / 8, clrs); + } + } + + // notice morphables must always rebind each frame as coord buffers are swapped, so the vao + // (if it is bound points to the previous buffer) + if (bindingRequired || morphable) + { + // always do coords + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, bstride, + (startVertex + coordoff) * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glVertex); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + } + + if (bindingRequired) + { + if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) + { + if (gd.geoToColorBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glVertexAttribPointer(locs.glColor, sz, GL2ES2.GL_FLOAT, false, cbstride, + (startVertex + coloroff) * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glColor); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerColor++; + } + } + else if (locs.glColor != -1) + { + // ignoreVertexcolors will have been set in FFP, now as the glColors is unbound + gl.glDisableVertexAttribArray(locs.glColor); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + + if (((vformat & GeometryArray.NORMALS) != 0) && locs.glNormal != -1) + { + if (gd.geoToCoordBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, false, bstride, + (startVertex + normoff) * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glNormal); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerNormals++; + } + } + else + { + if (locs.glNormal != -1) + { + gl.glDisableVertexAttribArray(locs.glNormal); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + } + + if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) + { + int vAttrOffset = startVertex + vAttrOff; + for (int index = 0; index < vertexAttrCount; index++) + { + Integer attribLoc = locs.genAttIndexToLoc.get(index); + if (attribLoc != null && attribLoc.intValue() != -1) + { + int sz = vertexAttrSizes[index]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, bstride, + vAttrOffset * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(attribLoc.intValue()); + vAttrOffset += vertexAttrSizes[index]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerUserAttribs++; + + } + } + } + + if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) + { + boolean[] texSetsBound = new boolean[texCoordSetMapLen]; + for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordSetMapLen; texUnit++) + { + int texSet = texCoordSetMap[texUnit]; + if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet]) + { + texSetsBound[texSet] = true; + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texSize, GL2ES2.GL_FLOAT, true, bstride, + (startVertex + texCoordoff + texCoordSetMapOffset[texUnit]) * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.enableTexCoordPointer++; + + } + } + + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + ////////////////////////////////////////////// + + if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) + { + int primType = 0; + + // FIXME: GL_LINE and GL_LINE_STRIP simply go from one vertex to the next drawing a line between + // each pair, what I want is a line between each set of 3 (that are not degenerate) + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_LINE_STRIP_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_TRI_STRIP_SET: + primType = GL2ES2.GL_TRIANGLE_STRIP; + break; + case GeometryRetained.GEO_TYPE_TRI_FAN_SET: + primType = GL2ES2.GL_TRIANGLE_FAN; + break; + case GeometryRetained.GEO_TYPE_LINE_STRIP_SET: + primType = GL2ES2.GL_LINE_LOOP; + break; + } + + for (int i = 0; i < sarray.length; i++) + { + if (sarray[i] > 0) + { + gl.glDrawArrays(primType, start_array[i], sarray[i]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripArraysStrips++; + } + } + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripArrays++; + } + else + { + //need to override if polygonAttributes says so + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_LINE_SET; + else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT) + geo_type = GeometryRetained.GEO_TYPE_POINT_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_QUAD_SET: + System.err.println("QuadArray.\n" + VALID_FORMAT_MESSAGE); + case GeometryRetained.GEO_TYPE_TRI_SET: + gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, vcount); + break; + case GeometryRetained.GEO_TYPE_POINT_SET: + gl.glDrawArrays(GL2ES2.GL_POINTS, 0, vcount); + break; + case GeometryRetained.GEO_TYPE_LINE_SET: + gl.glDrawArrays(GL2ES2.GL_LINES, 0, vcount); + break; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawArrays++; + } + } + else + { + if (!NO_PROGRAM_WARNING_GIVEN) + System.err.println("Execute called with no shader Program in use!"); + NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + + //---------------------------------------------------------------------- + // Private helper methods for GeometryArrayRetained + // + + private static String getVertexDescription(int vformat) + { + String res = ""; + if ((vformat & GeometryArray.COORDINATES) != 0) + res += "COORDINATES "; + if ((vformat & GeometryArray.NORMALS) != 0) + res += "NORMALS "; + if ((vformat & GeometryArray.COLOR) != 0) + res += "COLOR "; + if ((vformat & GeometryArray.WITH_ALPHA) != 0) + res += "(WITH_ALPHA) "; + if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) + res += "TEXTURE_COORDINATE "; + if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) + res += "(2) "; + if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) + res += "(3) "; + if ((vformat & GeometryArray.TEXTURE_COORDINATE_4) != 0) + res += "(4) "; + if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) + res += "VERTEX_ATTRIBUTES "; + return res; + } + + private static String getGeometryDescription(int geo_type) + { + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_TRI_STRIP_SET: + return "GEO_TYPE_TRI_STRIP_SET"; + case GeometryRetained.GEO_TYPE_TRI_FAN_SET: + return "GEO_TYPE_TRI_FAN_SET"; + case GeometryRetained.GEO_TYPE_LINE_STRIP_SET: + return "GEO_TYPE_LINE_STRIP_SET"; + case GeometryRetained.GEO_TYPE_QUAD_SET: + return "GEO_TYPE_QUAD_SET"; + case GeometryRetained.GEO_TYPE_TRI_SET: + return "GEO_TYPE_TRI_SET"; + case GeometryRetained.GEO_TYPE_POINT_SET: + return "GEO_TYPE_POINT_SET"; + case GeometryRetained.GEO_TYPE_LINE_SET: + return "GEO_TYPE_LINE_SET"; + default: + return "(unknown " + geo_type + ")"; + } + } + + // used by GeometryArray by Reference with NIO buffer non indexed + //texCoords will be an array of FloatBuffer + @Override + void executeVABuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean ignoreVertexColors, + int vcount, int vformat, int vdefined, int initialCoordIndex, Buffer vcoords, int initialColorIndex, Buffer cdataBuffer, + float[] cfdata, byte[] cbdata, int initialNormalIndex, FloatBuffer ndata, int vertexAttrCount, int[] vertexAttrSizes, + int[] vertexAttrIndices, FloatBuffer[] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, + int[] texIndex, int texstride, Object[] texCoords, int cdirty) + { + + if (VERBOSE) + System.err.println("JoglPipeline.executeVABuffer() "); + + boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + FloatBuffer fverts = null; + DoubleBuffer dverts = null; + FloatBuffer fclrs = null; + ByteBuffer bclrs = null; + + FloatBuffer norms = null; + FloatBuffer[] vertexAttrBufs = null; + + // Get vertex attribute arrays + if (vattrDefined) + vertexAttrBufs = vertexAttrData; + + // get coordinate array + if (floatCoordDefined) + { + fverts = (FloatBuffer) vcoords; + } + else if (doubleCoordDefined) + { + // FIXME: doubles not supported for now + throw new UnsupportedOperationException("Double coordinates in use.\n" + VALID_FORMAT_MESSAGE); + // dverts = (DoubleBuffer) vcoords; + } + + if (fverts == null && dverts == null) + { + return; + } + + + if (floatColorsDefined) + { + fclrs = (FloatBuffer) cdataBuffer; + } + + if (byteColorsDefined) + { + // FIXME: bytes not supported for now + throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE); + // if (cbdata != null) + // bclrs = getColorArrayBuffer(cbdata); + // else + // bclrs = (ByteBuffer) cdataBuffer; + } + + // get normal array + if (normalsDefined) + { + norms = ndata; + } + + int[] sarray = null; + int[] start_array = null; + int strip_len = 0; + if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) + { + sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts; + strip_len = sarray.length; + start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices; + } + + executeGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, + fverts, null, dverts, null, initialColorIndex, fclrs, cfdata, bclrs, null, initialNormalIndex, norms, null, vertexAttrCount, + vertexAttrSizes, vertexAttrIndices, vertexAttrBufs, null, texCoordMapLength, texcoordoffset, numActiveTexUnitState, + texIndex, texstride, texCoords, cdirty, sarray, strip_len, start_array); + } + + // used by GeometryArray by Reference with java arrays non indexed + //Object[] texCoords is an array of float arrays + @Override + void executeVA(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean ignoreVertexColors, int vcount, + int vformat, int vdefined, int initialCoordIndex, float[] vfcoords, double[] vdcoords, int initialColorIndex, float[] cfdata, + byte[] cbdata, int initialNormalIndex, float[] ndata, int vertexAttrCount, int[] vertexAttrSizes, int[] vertexAttrIndices, + float[][] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, int[] texIndex, int texstride, + Object[] texCoords, int cdirty) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeVA()"); + + boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + int[] sarray = null; + int[] start_array = null; + int strip_len = 0; + if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) + { + sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts; + strip_len = sarray.length; + start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices; + } + + if (doubleCoordDefined) + { + // FIXME: doubles not supported for now + throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE); + // dverts = getVertexArrayBuffer(vdcoords); + } + + if (byteColorsDefined) + { + // FIXME: byte colors not supported for now + throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE); + // bclrs = getColorArrayBuffer(cbdata); + } + + executeGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, + null, vfcoords, null, vdcoords, initialColorIndex, null, cfdata, null, cbdata, initialNormalIndex, null, ndata, + vertexAttrCount, vertexAttrSizes, vertexAttrIndices, null, vertexAttrData, texCoordMapLength, texcoordoffset, + numActiveTexUnitState, texIndex, texstride, texCoords, cdirty, sarray, strip_len, start_array); + } + + private void executeGeometryArrayVA(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, + boolean ignoreVertexColors, int vertexCount, int vformat, int vdefined, int initialCoordIndex, FloatBuffer fverts, + float[] vfcoords, DoubleBuffer dverts, double[] vdcoords, int initialColorIndex, FloatBuffer fclrs, float[] cfdata, + ByteBuffer bclrs, byte[] cbdata, int initialNormalIndex, FloatBuffer norms, float[] ndata, int vertexAttrCount, + int[] vertexAttrSizes, int[] vertexAttrIndices, FloatBuffer[] vertexAttrBufs, float[][] vertexAttrData, int texCoordMapLength, + int[] texCoordSetMap, int numActiveTexUnitState, int[] texindices, int texStride, Object[] texCoords, int cDirty, int[] sarray, + int strip_len, int[] start_array) + { + Jogl2es2Context ctx = (Jogl2es2Context) absCtx; + int shaderProgramId = ctx.shaderProgramId; + + if (shaderProgramId != -1) + { + GL2ES2 gl = ctx.gl2es2(); + ProgramData pd = ctx.programData; + LocationData locs = pd.programToLocationData; + + setFFPAttributes(ctx, gl, shaderProgramId, pd, vdefined, ignoreVertexColors); + + // If any buffers need loading do that now + GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vertexCount, vformat, vdefined, fverts, vfcoords, dverts, + vdcoords, fclrs, cfdata, bclrs, cbdata, norms, ndata, vertexAttrCount, vertexAttrSizes, vertexAttrBufs, vertexAttrData, + texCoordMapLength, texCoordSetMap, texStride, texCoords); + + boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + // GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability + boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE) + || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE); + + // not required second time around for VAO (except morphable coords) + boolean bindingRequired = true; + // Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders + if (gl.isGL2ES3()) + { + GL2ES3 gl2es3 = (GL2ES3)gl; + if (gd.vaoId == -1) + { + int[] tmp = new int[1]; + gl2es3.glGenVertexArrays(1, tmp, 0); + gd.vaoId = tmp[0]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + bindingRequired = false; + } + gl2es3.glBindVertexArray(gd.vaoId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // Define the data pointers + if (locs.glVertex != -1) + { + if (floatCoordDefined) + { + if (gd.geoToCoordBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + // rather than the morphable system above we should be able to use cDirty, but it appears to be wrong + // if ((cDirty & GeometryArrayRetained.COORDINATE_CHANGED) != 0) + if (morphable) + { + //if I have vfcoords instead of fverts need to get a fverts buff now + if (vfcoords != null) + { + fverts = getVertexArrayBuffer(vfcoords); + } + + int coordoff = 3 * initialCoordIndex; + fverts.position(coordoff); + // Sometime the FloatBuffer is swapped out for bigger or smaller + if (gd.geoToCoordBufSize != fverts.remaining()) + { + System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + fverts.remaining() + + " un indexed ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " " + + geo.source + ", this is not nessasarily a problem"); + + int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete after re-bind + int prevBufId2 = gd.geoToCoordBuf2; + + int[] tmp = new int[2]; + gl.glGenBuffers(2, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + gd.geoToCoordBuf1 = tmp[0]; + gd.geoToCoordBuf2 = tmp[1]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, + GL2ES2.GL_DYNAMIC_DRAW); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, + GL2ES2.GL_DYNAMIC_DRAW); + + gd.geoToCoordBufSize = fverts.remaining(); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + //Notice no check for bindingRequired as we are altering the binding + //and previously used buffer is deleted AFTER re-bind + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glVertex); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + + gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + // work out the buffer to update and buffer to swap to + if (gd.geoToCoordBuf == gd.geoToCoordBuf1) + { + // update 1 but set to draw 2 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts); + gd.geoToCoordBuf = gd.geoToCoordBuf2; + } + else + { + // update 2 but set to draw 1 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts); + gd.geoToCoordBuf = gd.geoToCoordBuf1; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferSubData++; + } + } + + } + + } + else if (doubleCoordDefined) + { + throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE); + } + else + { + throw new UnsupportedOperationException("No coords defined.\n" + VALID_FORMAT_MESSAGE); + } + } + else + { + throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE); + } + + // update other attributes if required + if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) + { + // if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE); + if (changable) + { + //if I have cfdata instead of fclrs need to get a fclrs buff now + if (cfdata != null) + { + fclrs = getColorArrayBuffer(cfdata); + } + + fclrs.position(0); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, fclrs.remaining() * Float.SIZE / 8, fclrs); + } + } + if (normalsDefined && locs.glNormal != -1) + { + // if ((cDirty & GeometryArrayRetained.NORMAL_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_NORMAL_WRITE); + if (changable) + { + //if I have ndata instead of norms need to get a norms buff now + if (ndata != null) + { + norms = getNormalArrayBuffer(ndata); + } + norms.position(0); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, norms.remaining() * Float.SIZE / 8, norms); + } + } + + if (vattrDefined) + { + if (vertexAttrData != null) + { + vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData); + } + for (int index = 0; index < vertexAttrCount; index++) + { + Integer attribLoc = locs.genAttIndexToLoc.get(index); + if (attribLoc != null && attribLoc.intValue() != -1) + { + // if ((cDirty & GeometryArrayRetained.VATTR_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_VERTEX_ATTR_WRITE); + if (changable) + { + FloatBuffer vertexAttrs = vertexAttrBufs[index]; + vertexAttrs.position(0); + SparseArray<Integer> bufIds = gd.geoToVertAttribBuf; + Integer bufId = bufIds.get(index); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, vertexAttrs.remaining() * Float.SIZE / 8, vertexAttrs); + } + } + } + } + + if (textureDefined) + { + // convert from float[][] to FloatBuffer[] + if (!(texCoords[0] instanceof FloatBuffer)) + { + texCoords = getTexCoordSetBuffer(texCoords); + } + boolean[] texSetsBound = new boolean[texCoords.length]; + for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) + { + int texSet = texCoordSetMap[texUnit]; + if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet]) + { + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_TEXCOORD_WRITE); + if (changable) + { + FloatBuffer buf = (FloatBuffer) texCoords[texSet]; + buf.position(0); + SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf; + Integer bufId = bufIds.get(texUnit); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, buf.remaining() * Float.SIZE / 8, buf); + } + } + } + } + + // notice morphables must always rebind each frame as coord buffers are swapped + if (bindingRequired || morphable) + { + // always do coords + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glVertex); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + } + + if (bindingRequired) + { + if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) + { + if (gd.geoToColorBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + int coloroff; + int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3; + + coloroff = sz * initialColorIndex; + fclrs.position(coloroff); + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glVertexAttribPointer(locs.glColor, sz, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glColor);//must be called after Pointer above + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerColor++; + } + } + else if (byteColorsDefined && locs.glColor != -1 && !ignoreVertexColors) + { + //FIXME: byteColors not supported for now, but I want them a lot + throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE); + /*int coloroff; + int sz; + if ((vformat & GeometryArray.WITH_ALPHA) != 0) + { + coloroff = 4 * initialColorIndex; + sz = 4; + } + else + { + coloroff = 3 * initialColorIndex; + sz = 3; + } + bclrs.position(coloroff); + gl.glColorPointer(sz, GL2ES2.GL_UNSIGNED_BYTE, 0, bclrs);*/ + } + else if (locs.glColor != -1) + { + // ignoreVertexcolors will have been set in FFP now as the glColors is unbound + gl.glDisableVertexAttribArray(locs.glColor); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + + if (normalsDefined && locs.glNormal != -1) + { + if (gd.geoToNormalBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf); + gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glNormal);//must be called after Pointer above + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerNormals++; + } + } + else + { + if (locs.glNormal != -1) + { + gl.glDisableVertexAttribArray(locs.glNormal); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + } + + if (vattrDefined) + { + for (int index = 0; index < vertexAttrCount; index++) + { + Integer attribLoc = locs.genAttIndexToLoc.get(index); + if (attribLoc != null && attribLoc.intValue() != -1) + { + SparseArray<Integer> bufIds = gd.geoToVertAttribBuf; + if (bufIds == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + + Integer bufId = bufIds.get(index); + if (bufId == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + int sz = vertexAttrSizes[index]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(attribLoc.intValue());//must be called after Pointer above + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerUserAttribs++; + } + } + } + } + + if (textureDefined) + { + boolean[] texSetsBound = new boolean[texCoords.length]; + for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) + { + int texSet = texCoordSetMap[texUnit]; + if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet]) + { + texSetsBound[texSet] = true; + + SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf; + if (bufIds == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + Integer bufId = bufIds.get(texUnit); + if (bufId == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texStride, GL2ES2.GL_FLOAT, true, 0, 0); + gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.enableTexCoordPointer++; + } + } + } + + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) + { + int primType = 0; + + // FIXME: GL_LINE and GL_LINE_STRIP simply go from one vertex to the next drawing a line between + // each pair, what I want is a line between each set of 3 (that are not degenerate) + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_LINE_STRIP_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_TRI_STRIP_SET: + primType = GL2ES2.GL_TRIANGLE_STRIP; + break; + case GeometryRetained.GEO_TYPE_TRI_FAN_SET: + primType = GL2ES2.GL_TRIANGLE_FAN; + break; + case GeometryRetained.GEO_TYPE_LINE_STRIP_SET: + primType = GL2ES2.GL_LINE_LOOP; + break; + } + + for (int i = 0; i < strip_len; i++) + { + if (sarray[i] > 0) + { + gl.glDrawArrays(primType, start_array[i], sarray[i]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripArraysStrips++; + } + } + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripArrays++; + } + else + { + // need to override if polygonAttributes says so + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_LINE_SET; + else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT) + geo_type = GeometryRetained.GEO_TYPE_POINT_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_QUAD_SET: + System.err.println("QuadArray.\n" + VALID_FORMAT_MESSAGE); + case GeometryRetained.GEO_TYPE_TRI_SET: + gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, vertexCount); + break; + case GeometryRetained.GEO_TYPE_POINT_SET: + gl.glDrawArrays(GL2ES2.GL_POINTS, 0, vertexCount); + break; + case GeometryRetained.GEO_TYPE_LINE_SET: + gl.glDrawArrays(GL2ES2.GL_LINES, 0, vertexCount); + break; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawArrays++; + } + } + else + { + if (!NO_PROGRAM_WARNING_GIVEN) + System.err.println("Execute called with no shader Program in use!"); + NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + + // --------------------------------------------------------------------- + + // + // IndexedGeometryArrayRetained methods + // + + // by-copy or interleaved, by reference, Java arrays + @Override + void executeIndexedGeometry(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha, + boolean ignoreVertexColors, int initialIndexIndex, int indexCount, int vertexCount, int vformat, int vertexAttrCount, + int[] vertexAttrSizes, int texCoordSetCount, int[] texCoordSetMap, int texCoordSetMapLen, int[] texCoordSetOffset, + int numActiveTexUnitState, float[] varray, float[] carray, int cdirty, int[] indexCoord) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeIndexedGeometry()"); + + executeIndexedGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, initialIndexIndex, indexCount, + vertexCount, vformat, vertexAttrCount, vertexAttrSizes, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, + texCoordSetOffset, numActiveTexUnitState, varray, null, carray, cdirty, indexCoord); + } + + // interleaved, by reference, nio buffer + @Override + void executeIndexedGeometryBuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha, + boolean ignoreVertexColors, int initialIndexIndex, int indexCount, int vertexCount, int vformat, int texCoordSetCount, + int[] texCoordSetMap, int texCoordSetMapLen, int[] texCoordSetOffset, int numActiveTexUnitState, FloatBuffer vdata, + float[] carray, int cDirty, int[] indexCoord) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeIndexedGeometryBuffer()"); + + executeIndexedGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, initialIndexIndex, indexCount, + vertexCount, vformat, 0, null, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texCoordSetOffset, + numActiveTexUnitState, null, vdata, carray, cDirty, indexCoord); + } + + //---------------------------------------------------------------------- + // + // Helper routines for IndexedGeometryArrayRetained + // + + private void executeIndexedGeometryArray(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, + boolean useAlpha, boolean ignoreVertexColors, int initialIndexIndex, int indexCount, int vcount, int vformat, + int vertexAttrCount, int[] vertexAttrSizes, int texCoordSetCount, int[] texCoordSetMap, int texCoordSetMapLen, + int[] texCoordSetOffset, int numActiveTexUnitState, float[] varray, FloatBuffer vdata, float[] carray, int cDirty, + int[] indexCoord) + { + + if (VERBOSE) + System.err.println("JoglPipeline.executeIndexedGeometryArray()"); + + Jogl2es2Context ctx = (Jogl2es2Context) absCtx; + int shaderProgramId = ctx.shaderProgramId; + + if (shaderProgramId != -1) + { + GL2ES2 gl = ctx.gl2es2(); + ProgramData pd = ctx.programData; + LocationData locs = pd.programToLocationData; + + setFFPAttributes(ctx, gl, shaderProgramId, pd, vformat, ignoreVertexColors); + + int stride = 0, coordoff = 0, normoff = 0, coloroff = 0, texCoordoff = 0; + int texSize = 0, texStride = 0; + int vAttrOff = 0; + int vAttrStride = 0; + int bstride = 0, cbstride = 0; + + int[] sarray = null; + int strip_len = 0; + + if (EXTRA_DEBUGGING) + { + System.err.println("Vertex format: " + getVertexDescription(vformat)); + System.err.println("Geometry type: " + getGeometryDescription(geo_type)); + if (carray != null) + { + System.err.println(" Separate color array"); + } + else + { + System.err.println(" Colors (if any) interleaved"); + } + } + + if ((vformat & GeometryArray.COORDINATES) != 0) + { + stride += 3; + } + if ((vformat & GeometryArray.NORMALS) != 0) + { + stride += 3; + coordoff += 3; + } + + if ((vformat & GeometryArray.COLOR) != 0) + { + if ((vformat & GeometryArray.WITH_ALPHA) != 0) + { + stride += 4; + normoff += 4; + coordoff += 4; + } + else + { + // Handle the case of executeInterleaved 3f + stride += 3; + normoff += 3; + coordoff += 3; + } + } + + if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) + { + if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) + { + texSize = 2; + texStride = 2 * texCoordSetCount; + } + else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) + { + texSize = 3; + texStride = 3 * texCoordSetCount; + } + else if ((vformat & GeometryArray.TEXTURE_COORDINATE_4) != 0) + { + texSize = 4; + texStride = 4 * texCoordSetCount; + } + stride += texStride; + normoff += texStride; + coloroff += texStride; + coordoff += texStride; + } + + if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) + { + for (int i = 0; i < vertexAttrCount; i++) + { + vAttrStride += vertexAttrSizes[i]; + } + stride += vAttrStride; + normoff += vAttrStride; + coloroff += vAttrStride; + coordoff += vAttrStride; + texCoordoff += vAttrStride; + } + + bstride = stride * Buffers.SIZEOF_FLOAT; + + if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) + { + sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts; + strip_len = sarray.length; + } + + // using byRef interleaved array and has a separate pointer, then .. + int cstride = stride; + if (carray != null) + { + cstride = 4; + } + + cbstride = cstride * Buffers.SIZEOF_FLOAT; + + if (EXTRA_DEBUGGING) + { + System.err.println(" initialIndexIndex: " + initialIndexIndex); + System.err.println(" stride: " + stride); + System.err.println(" bstride: " + bstride); + System.err.println(" normoff: " + normoff); + System.err.println(" coloroff: " + coloroff); + System.err.println(" coordoff: " + coordoff); + System.err.println(" texCoordoff: " + texCoordoff); + } + + GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vcount, vformat, vformat, vdata, varray, 0, vdata, carray, + 0); + + // GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability + boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE) + || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE); + + // not required second time around for VAO (except morphable coords) + boolean bindingRequired = true; + // Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders + if (gl.isGL2ES3()) + { + GL2ES3 gl2es3 = (GL2ES3)gl; + if (gd.vaoId == -1) + { + int[] tmp = new int[1]; + gl2es3.glGenVertexArrays(1, tmp, 0); + gd.vaoId = tmp[0]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + bindingRequired = false; + } + gl2es3.glBindVertexArray(gd.vaoId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + // refill the buffers in case of writeable data + if (locs.glVertex != -1) + { + + if (gd.geoToCoordBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + // if ((cDirty & GeometryArrayRetained.COORDINATE_CHANGED) != 0) + if (morphable) + { + FloatBuffer verts = null; + + // do we need to covert a float[] + if (varray != null) + { + verts = getVertexArrayBuffer(varray); + } + else + { + verts = vdata; + } + + verts.position(0); + // Sometime the FloatBuffer is swapped out for bigger or smaller + if (gd.geoToCoordBufSize != verts.remaining()) + { + System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + verts.remaining() + + " un indexed ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " " + + geo.source + ", this is not nessasarily a problem"); + + int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete after re-bind + int prevBufId2 = gd.geoToCoordBuf2; + + int[] tmp = new int[2]; + gl.glGenBuffers(2, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + gd.geoToCoordBuf1 = tmp[0]; + gd.geoToCoordBuf2 = tmp[1]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW); + + gd.geoToCoordBufSize = verts.remaining(); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + //Notice no check for bindingRequired as we are altering the binding + //and previously used buffer is deleted AFTER re-bind + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glVertex); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + + gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + // work out the buffer to update and buffer to swap to + if (gd.geoToCoordBuf == gd.geoToCoordBuf1) + { + // update 1 but set to draw 2 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts); + gd.geoToCoordBuf = gd.geoToCoordBuf2; + } + else + { + // update 2 but set to draw 1 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts); + gd.geoToCoordBuf = gd.geoToCoordBuf1; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferSubData++; + } + } + + } + + } + else + { + throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE); + } + + // update other attributes if required + if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) + { + // if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE); + if (changable) + { + // clrs in the vdata, unless seperate + FloatBuffer clrs = null; + FloatBuffer verts = null; + + // do we need to covert a float[] + if (varray != null) + { + verts = getVertexArrayBuffer(varray); + } + else + { + verts = vdata; + } + if (carray != null) + { + clrs = getColorArrayBuffer(carray); + } + else + { + clrs = verts; + } + clrs.position(0); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, clrs.remaining() * Float.SIZE / 8, clrs); + } + } + + // notice morphables must always rebind each frame as coord buffers are swapped + if (bindingRequired || morphable) + { + // always do coords + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, bstride, coordoff * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glVertex); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + } + + if (bindingRequired) + { + if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) + { + if (gd.geoToColorBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glVertexAttribPointer(locs.glColor, sz, GL2ES2.GL_FLOAT, false, cbstride, coloroff * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glColor); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerColor++; + } + } + else if (locs.glColor != -1) + { + // ignoreVertexcolors will have been set in FFP now as the glColors is unbound + gl.glDisableVertexAttribArray(locs.glColor); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + + if (((vformat & GeometryArray.NORMALS) != 0) && locs.glNormal != -1) + { + if (gd.geoToCoordBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, false, bstride, normoff * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glNormal); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerNormals++; + } + } + else + { + if (locs.glNormal != -1) + { + gl.glDisableVertexAttribArray(locs.glNormal); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + } + + if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) + { + + int vAttrOffset = vAttrOff; + for (int index = 0; index < vertexAttrCount; index++) + { + Integer attribLoc = locs.genAttIndexToLoc.get(index); + if (attribLoc != null && attribLoc.intValue() != -1) + { + int sz = vertexAttrSizes[index]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, bstride, + vAttrOffset * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(attribLoc.intValue()); + vAttrOffset += vertexAttrSizes[index]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerUserAttribs++; + + } + } + } + + if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) + { + boolean[] texSetsBound = new boolean[texCoordSetMapLen]; + for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordSetMapLen; texUnit++) + { + int texSet = texCoordSetMap[texUnit]; + if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet]) + { + texSetsBound[texSet] = true; + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texSize, GL2ES2.GL_FLOAT, true, bstride, + texCoordoff * Buffers.SIZEOF_FLOAT); + gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.enableTexCoordPointer++; + + } + } + + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + ////////////////////////////////////////////// + if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) + { + int primType = 0; + + //FIXME: GL_LINE and GL_LINE_STRIP simply go from one vertex to the next drawing a line between + // each pair, what I want is a line between each set of 3 (that are not jumpers) + + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET: + primType = GL2ES2.GL_TRIANGLE_STRIP; + break; + case GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET: + primType = GL2ES2.GL_TRIANGLE_FAN; + break; + case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET: + primType = GL2ES2.GL_LINE_LOOP; + break; + } + + int[] stripInd = gd.geoToIndStripBuf; + // if no index buffers build build them now + if (stripInd == null) + { + stripInd = new int[strip_len]; + gl.glGenBuffers(strip_len, stripInd, 0); + + int offset = initialIndexIndex; + /*ShortBuffer indicesBuffer = ByteBuffer.allocateDirect(indexCoord.length * 2).order(ByteOrder.nativeOrder()) + .asShortBuffer(); + for (int s = 0; s < indexCoord.length; s++) + indicesBuffer.put(s, (short) indexCoord[s]);*/ + + ShortBuffer indicesBuffer = getIndexArrayBuffer(indexCoord); + for (int i = 0; i < strip_len; i++) + { + indicesBuffer.position(offset); + int count = sarray[i]; + int indBufId = stripInd[i]; + + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBufId); + gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, count * Short.SIZE / 8, indicesBuffer, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + offset += count; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + } + + gd.geoToIndStripBuf = stripInd; + } + + for (int i = 0; i < strip_len; i++) + { + int count = sarray[i]; + int indBufId = stripInd[i]; + + //type Specifies the type of the values in indices. Must be + // GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT. + // Apparently ES3 has included this guy now, so I'm a bit commited to it + //https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml + //This restriction is relaxed when GL_OES_element_index_uint is supported. + //GL_UNSIGNED_INT + + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBufId); + gl.glDrawElements(primType, count, GL2ES2.GL_UNSIGNED_SHORT, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripElementsStrips++; + + } + // gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, 0); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripElements++; + + // note only the first count so multi strips is worng here, + // but... + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.indexCount += gd.geoToIndBufSize; + + } + else + { + + // bind my indexes ready for the draw call + if (gd.geoToIndBuf == -1) + { + // create and fill index buffer + //ShortBuffer indBuf = ByteBuffer.allocateDirect(indexCoord.length * 2).order(ByteOrder.nativeOrder()).asShortBuffer(); + //for (int s = 0; s < indexCoord.length; s++) + // indBuf.put(s, (short) indexCoord[s]); + //indBuf.position(initialIndexIndex); + ShortBuffer indBuf = getIndexArrayBuffer(indexCoord); + + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + gd.geoToIndBuf = tmp[0];// about to add to map below + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, gd.geoToIndBuf); + gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBuf.remaining() * Short.SIZE / 8, indBuf, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + gd.geoToIndBufSize = indBuf.remaining(); + + } + + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, gd.geoToIndBuf); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.indexCount += gd.geoToIndBufSize; + + // Need to override if polygonAttributes says we should be drawing lines + // Note these are not poly line just contiguous lines between each pair of points + // So it looks really rubbish + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_INDEXED_LINE_SET; + else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT) + geo_type = GeometryRetained.GEO_TYPE_INDEXED_POINT_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET: + throw new UnsupportedOperationException("QuadArray.\n" + VALID_FORMAT_MESSAGE); + case GeometryRetained.GEO_TYPE_INDEXED_TRI_SET: + gl.glDrawElements(GL2ES2.GL_TRIANGLES, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0); + break; + case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET: + gl.glDrawElements(GL2ES2.GL_POINTS, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0); + break; + case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET: + gl.glDrawElements(GL2ES2.GL_LINES, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0); + break; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawElements++; + } + } + else + { + if (!NO_PROGRAM_WARNING_GIVEN) + System.err.println("Execute called with no shader Program in use!"); + NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + + // non interleaved, by reference, Java arrays + + @Override + void executeIndexedGeometryVA(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, + boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount, int vertexCount, int vformat, int vdefined, + float[] vfcoords, double[] vdcoords, float[] cfdata, byte[] cbdata, float[] ndata, int vertexAttrCount, int[] vertexAttrSizes, + float[][] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, int texStride, + Object[] texCoords, int cdirty, int[] indexCoord) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeIndexedGeometryVA()"); + + boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + int[] sarray = null; + int strip_len = 0; + if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) + { + sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts; + strip_len = sarray.length; + } + + if (doubleCoordDefined) + { + // FIXME: doubles not supported for now + throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE); + // dverts = getVertexArrayBuffer(vdcoords); + } + + if (byteColorsDefined) + { + // FIXME: byte colors not supported for now + throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE); + // bclrs = getColorArrayBuffer(cbdata); + } + + executeIndexedGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, initialIndexIndex, validIndexCount, + vertexCount, vformat, vdefined, null, vfcoords, null, vdcoords, null, cfdata, null, cbdata, null, ndata, vertexAttrCount, + vertexAttrSizes, null, vertexAttrData, texCoordMapLength, texcoordoffset, numActiveTexUnitState, texStride, texCoords, + cdirty, indexCoord, sarray, strip_len); + } + + // non interleaved, by reference, nio buffer + + @Override + void executeIndexedGeometryVABuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, + boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount, int vertexCount, int vformat, int vdefined, + Buffer vcoords, Buffer cdataBuffer, float[] cfdata, byte[] cbdata, FloatBuffer ndata, int vertexAttrCount, + int[] vertexAttrSizes, FloatBuffer[] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, + int texStride, Object[] texCoords, int cdirty, int[] indexCoord) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeIndexedGeometryVABuffer() "); + + boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + FloatBuffer fverts = null; + DoubleBuffer dverts = null; + FloatBuffer fclrs = null; + ByteBuffer bclrs = null; + + FloatBuffer norms = null; + FloatBuffer[] vertexAttrBufs = null; + + // Get vertex attribute arrays + if (vattrDefined) + { + vertexAttrBufs = vertexAttrData; + } + + // get coordinate array + if (floatCoordDefined) + { + fverts = (FloatBuffer) vcoords; + } + else if (doubleCoordDefined) + { + // FIXME: doubles not supported for now + throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE); + // dverts = (DoubleBuffer) vcoords; + } + + if (fverts == null && dverts == null) + { + return; + } + + int[] sarray = null; + int strip_len = 0; + if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) + { + sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts; + strip_len = sarray.length; + } + + // get color array + if (floatColorsDefined) + { + fclrs = (FloatBuffer) cdataBuffer; + } + else if (byteColorsDefined) + { + // FIXME: not supported for now + throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE); + + // if (cbdata != null) + // bclrs = getColorArrayBuffer(cbdata); + // else + // bclrs = (ByteBuffer) cdataBuffer; + } + + // get normal array + if (normalsDefined) + { + norms = ndata; + } + + executeIndexedGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, initialIndexIndex, validIndexCount, + vertexCount, vformat, vdefined, fverts, null, dverts, null, fclrs, cfdata, bclrs, null, norms, null, vertexAttrCount, + vertexAttrSizes, vertexAttrBufs, null, texCoordMapLength, texcoordoffset, numActiveTexUnitState, texStride, texCoords, + cdirty, indexCoord, sarray, strip_len); + } + + // ---------------------------------------------------------------------- + // + // Helper routines for IndexedGeometryArrayRetained + // + // careful - isNonUniformScale is always false regardless + private void executeIndexedGeometryArrayVA(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, + boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount, int vertexCount, int vformat, int vdefined, + FloatBuffer fverts, float[] vfarray, DoubleBuffer dverts, double[] vdarray, FloatBuffer fclrs, float[] cfarray, + ByteBuffer bclrs, byte[] cbarray, FloatBuffer norms, float[] fnorms, int vertexAttrCount, int[] vertexAttrSizes, + FloatBuffer[] vertexAttrBufs, float[][] vertexAttrArrays, int texCoordMapLength, int[] texCoordSetMap, + int numActiveTexUnitState, int texStride, Object[] texCoords, int cDirty, int[] indexCoord, int[] sarray, int strip_len) + { + + // removed if (ATTEMPT_OPTIMIZED_VERTICES && + // executeIndexedGeometryOptimized(... + + Jogl2es2Context ctx = (Jogl2es2Context) absCtx; + int shaderProgramId = ctx.shaderProgramId; + + if (shaderProgramId != -1) + { + GL2ES2 gl = ctx.gl2es2(); + ProgramData pd = ctx.programData; + LocationData locs = pd.programToLocationData; + + setFFPAttributes(ctx, gl, shaderProgramId, pd, vdefined, ignoreVertexColors); + + // If any buffers need loading do that now + GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vertexCount, vformat, vdefined, fverts, vfarray, dverts, + vdarray, fclrs, cfarray, bclrs, cbarray, norms, fnorms, vertexAttrCount, vertexAttrSizes, vertexAttrBufs, + vertexAttrArrays, texCoordMapLength, texCoordSetMap, texStride, texCoords); + + boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + // GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability + boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE) + || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE); + + // not required second time around for VAO (except morphable coords) + boolean bindingRequired = true; + // Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders + if (gl.isGL2ES3()) + { + GL2ES3 gl2es3 = (GL2ES3)gl; + if (gd.vaoId == -1) + { + int[] tmp = new int[1]; + gl2es3.glGenVertexArrays(1, tmp, 0); + gd.vaoId = tmp[0]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + bindingRequired = false; + } + gl2es3.glBindVertexArray(gd.vaoId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // Define the data pointers + if (locs.glVertex != -1) + { + if (floatCoordDefined) + { + // TODO: Building of buffers etc and index buffers should really take place not on the j3d thread if possible + if (gd.geoToCoordBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + if (morphable) + { + + //if I have vfcoords instead of fverts need to get a fverts buff now + if (vfarray != null) + { + fverts = getVertexArrayBuffer(vfarray); + } + + fverts.position(0); + + // Sometime the FloatBuffer is swapped out for bigger or smaller + if (gd.geoToCoordBufSize != fverts.remaining()) + { + System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + fverts.remaining() + + " ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " " + geo.source); + + int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete below + int prevBufId2 = gd.geoToCoordBuf2; + + int[] tmp = new int[2]; + gl.glGenBuffers(2, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + gd.geoToCoordBuf1 = tmp[0]; + gd.geoToCoordBuf2 = tmp[1]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, + GL2ES2.GL_STATIC_DRAW); + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, + GL2ES2.GL_STATIC_DRAW); + + gd.geoToCoordBufSize = fverts.remaining(); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + // Notice no check for bindingRequired as we are altering the binding + // and previously used buffer is deleted AFTER re-bind + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glVertex); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + + gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + // work out the buffer to update and buffer to swap to + if (gd.geoToCoordBuf == gd.geoToCoordBuf1) + { + // update 1 but set to draw 2 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts); + gd.geoToCoordBuf = gd.geoToCoordBuf2; + + } + else + { + // update 2 but set to draw 1 + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts); + gd.geoToCoordBuf = gd.geoToCoordBuf1; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferSubData++; + } + } + + } + } + else if (doubleCoordDefined) + { + throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE); + } + else + { + throw new UnsupportedOperationException("No coords defined.\n" + VALID_FORMAT_MESSAGE); + } + } + else + { + throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE); + } + + // update other attributes if required + if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) + { + // if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE); + if (changable) + { + //if I have cfdata instead of fclrs need to get a fclrs buff now + if (cfarray != null) + { + fclrs = getColorArrayBuffer(cfarray); + } + + fclrs.position(0); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, fclrs.remaining() * Float.SIZE / 8, fclrs); + } + } + if (normalsDefined && locs.glNormal != -1) + { + // if ((cDirty & GeometryArrayRetained.NORMAL_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_NORMAL_WRITE); + if (changable) + { + //if I have ndata instead of norms need to get a norms buff now + if (fnorms != null) + { + norms = getNormalArrayBuffer(fnorms); + } + + norms.position(0); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, norms.remaining() * Float.SIZE / 8, norms); + } + } + + if (vattrDefined) + { + if (vertexAttrArrays != null) + { + vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrArrays); + } + + for (int index = 0; index < vertexAttrCount; index++) + { + Integer attribLoc = locs.genAttIndexToLoc.get(index); + if (attribLoc != null && attribLoc.intValue() != -1) + { + // if ((cDirty & GeometryArrayRetained.VATTR_CHANGED) != 0) + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_VERTEX_ATTR_WRITE); + if (changable) + { + FloatBuffer vertexAttrs = vertexAttrBufs[index]; + vertexAttrs.position(0); + SparseArray<Integer> bufIds = gd.geoToVertAttribBuf; + Integer bufId = bufIds.get(index); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, vertexAttrs.remaining() * Float.SIZE / 8, vertexAttrs); + } + } + } + } + + if (textureDefined) + { + // convert from float[][] to FloatBuffer[] + if (texCoords instanceof float[][]) + { + texCoords = getTexCoordSetBuffer(texCoords); + } + boolean[] texSetsBound = new boolean[texCoords.length]; + for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) + { + int texSet = texCoordSetMap[texUnit]; + if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet]) + { + boolean changable = geo.source.getCapability(GeometryArray.ALLOW_TEXCOORD_WRITE); + if (changable) + { + FloatBuffer buf = (FloatBuffer) texCoords[texSet]; + buf.position(0); + SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf; + Integer bufId = bufIds.get(texUnit); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, buf.remaining() * Float.SIZE / 8, buf); + } + } + } + } + + // binding is required for morphables coords as always swappping buffers each second frame + if (bindingRequired || morphable) + { + // always coords + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(locs.glVertex); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerCoord++; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.coordCount += gd.geoToCoordBufSize; + + } + + if (bindingRequired) + { + if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) + { + if (gd.geoToColorBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3; + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + + gl.glVertexAttribPointer(locs.glColor, sz, GL2ES2.GL_FLOAT, true, 0, 0); + gl.glEnableVertexAttribArray(locs.glColor); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerColor++; + } + + } + else if (byteColorsDefined && locs.glColor != -1 && !ignoreVertexColors) + { + //FIXME: byteColors not supported for now + throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE); + + /*bclrs.position(0); + if ((vformat & GeometryArray.WITH_ALPHA) != 0) + { + gl.glColorPointer(4, GL2ES2.GL_UNSIGNED_BYTE, 0, bclrs); + } + else + { + gl.glColorPointer(3, GL2ES2.GL_UNSIGNED_BYTE, 0, bclrs); + }*/ + } + else if (locs.glColor != -1) + { + // ignoreVertexcolors will be set in FFP now as the glColors is unbound + gl.glDisableVertexAttribArray(locs.glColor); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + + if (normalsDefined) + { + if (locs.glNormal != -1) + { + if (gd.geoToNormalBuf == -1) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf); + + gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, true, 0, 0); + gl.glEnableVertexAttribArray(locs.glNormal);//must be called after Pointer above + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerNormals++; + } + } + } + else + { + if (locs.glNormal != -1) + { + gl.glDisableVertexAttribArray(locs.glNormal); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDisableVertexAttribArray++; + } + } + + if (vattrDefined) + { + for (int index = 0; index < vertexAttrCount; index++) + { + Integer attribLoc = locs.genAttIndexToLoc.get(index); + if (attribLoc != null && attribLoc.intValue() != -1) + { + SparseArray<Integer> bufIds = gd.geoToVertAttribBuf; + if (bufIds == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + + Integer bufId = bufIds.get(index); + if (bufId == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + + int sz = vertexAttrSizes[index]; + + gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(attribLoc.intValue());//must be called after Pointer above + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glVertexAttribPointerUserAttribs++; + } + } + } + } + + if (textureDefined) + { + boolean[] texSetsBound = new boolean[texCoords.length]; + for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) + { + int texSet = texCoordSetMap[texUnit]; + if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet]) + { + texSetsBound[texSet] = true; + // stupid interface... + FloatBuffer buf = (FloatBuffer) texCoords[texSet]; + buf.position(0); + + SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf; + if (bufIds == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + Integer bufId = bufIds.get(texUnit); + if (bufId == null) + { + new Throwable("Buffer load issue!").printStackTrace(); + } + else + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texStride, GL2ES2.GL_FLOAT, true, 0, 0); + gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]);// must be called after Pointer above + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.enableTexCoordPointer++; + } + } + } + } + + // general catch all + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET + || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) + { + int primType = 0; + + // need to override if polygonAttributes says so + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET: + primType = GL2ES2.GL_TRIANGLE_STRIP; + break; + case GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET: + primType = GL2ES2.GL_TRIANGLE_FAN; + break; + case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET: + primType = GL2ES2.GL_LINES; + break; + } + + int[] stripInd = gd.geoToIndStripBuf; + // if no index buffers build build them now + if (stripInd == null) + { + stripInd = new int[strip_len]; + gl.glGenBuffers(strip_len, stripInd, 0); + + int offset = initialIndexIndex; + /*ShortBuffer indicesBuffer = ByteBuffer.allocateDirect(indexCoord.length * 2).order(ByteOrder.nativeOrder()) + .asShortBuffer(); + for (int s = 0; s < indexCoord.length; s++) + indicesBuffer.put(s, (short) indexCoord[s]);*/ + + ShortBuffer indicesBuffer = getIndexArrayBuffer(indexCoord); + + for (int i = 0; i < strip_len; i++) + { + indicesBuffer.position(offset); + int count = sarray[i]; + int indBufId = stripInd[i]; + + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBufId); + gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, count * Short.SIZE / 8, indicesBuffer, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + offset += count; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + } + + gd.geoToIndStripBuf = stripInd; + } + else + { + //a good cDirty and a DYNAMIC_DRAW call needed + /*if ((cDirty & GeometryArrayRetained.INDEX_CHANGED) != 0) + { + int offset = initialIndexIndex; + IntBuffer indicesBuffer = IntBuffer.wrap(indexCoord); + for (int i = 0; i < strip_len; i++) + { + indicesBuffer.position(offset); + int count = sarray[i]; + int indBufId = stripInd[i]; + + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBufId); + gl.glBufferSubData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, 0, count * Integer.SIZE / 8, indicesBuffer); + //gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, 0); + offset += count; + }*/ + } + + for (int i = 0; i < strip_len; i++) + { + int count = sarray[i]; + int indBufId = stripInd[i]; + + // type Specifies the type of the values in indices. Must be + // GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT. + // Apparently ES3 has included this GL_UNSIGNED_INT + // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml + // This restriction is relaxed when GL_OES_element_index_uint is supported. + // GL_UNSIGNED_INT + + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBufId); + gl.glDrawElements(primType, count, GL2ES2.GL_UNSIGNED_SHORT, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripElementsStrips++; + + } + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawStripElements++; + + // note only the first count so multi-strips is wrong here, but... + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.indexCount += gd.geoToIndBufSize; + + } + else + { + // bind my indexes ready for the draw call + if (gd.geoToIndBuf == -1) + { + // create and fill index buffer + /*ShortBuffer indBuf = ByteBuffer.allocateDirect(indexCoord.length * 2).order(ByteOrder.nativeOrder()).asShortBuffer(); + for (int s = 0; s < indexCoord.length; s++) + indBuf.put(s, (short) indexCoord[s]); + indBuf.position(initialIndexIndex);*/ + + ShortBuffer indBuf = getIndexArrayBuffer(indexCoord); + + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + gd.geoToIndBuf = tmp[0];// about to add to map below + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, gd.geoToIndBuf); + gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBuf.remaining() * Short.SIZE / 8, indBuf, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + gd.geoToIndBufSize = indBuf.remaining(); + + } + else + { + //a good cDirty and a DYNAMIC_DRAW call needed + /*if ((cDirty & GeometryArrayRetained.INDEX_CHANGED) != 0) + { + IntBuffer indBuf = IntBuffer.wrap(indexCoord); + indBuf.position(initialIndexIndex); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, indexBufId.intValue()); + gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, indBuf.remaining() * Integer.SIZE / 8, indBuf); + }*/ + } + + gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, gd.geoToIndBuf); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.indexCount += gd.geoToIndBufSize; + + // Need to override if polygonAttributes says we should be drawing lines + // Note these are not poly line just contiguous lines between each pair of points + // So it looks really rubbish + if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE) + geo_type = GeometryRetained.GEO_TYPE_INDEXED_LINE_SET; + else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT) + geo_type = GeometryRetained.GEO_TYPE_INDEXED_POINT_SET; + + switch (geo_type) + { + case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET: + throw new UnsupportedOperationException("QuadArray.\n" + VALID_FORMAT_MESSAGE); + case GeometryRetained.GEO_TYPE_INDEXED_TRI_SET: + gl.glDrawElements(GL2ES2.GL_TRIANGLES, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0); + break; + case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET: + gl.glDrawElements(GL2ES2.GL_POINTS, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0); + break; + case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET: + gl.glDrawElements(GL2ES2.GL_LINES, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0); + break; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glDrawElements++; + + } + } + else + { + if (!NO_PROGRAM_WARNING_GIVEN) + System.err.println("Execute called with no shader Program in use!"); + NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + /** + * Over time we have had things recorded and in FFP they are considered current state + * in programmable we have to push them across manually each time recorded in JoglesContext + * @param gl + * @param vdefined + */ + + private static void setFFPAttributes(Jogl2es2Context ctx, GL2ES2 gl, int shaderProgramId, ProgramData pd, int vdefined, boolean ignoreVertexColors) + { + + LocationData locs = pd.programToLocationData; + + //boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + //boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + //boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + //boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + //boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.setFFPAttributes++; + + boolean isGL2ES3 = gl.isGL2ES3(); + // if shader hasn't changed location of uniform I don't need to reset these (they are cleared to -1 at the start of each swap) + if (locs.glProjectionMatrix != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram)) + { + if (isGL2ES3) + gl.glUniformMatrix4fv(locs.glProjectionMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentProjMat), 0); + else + gl.glUniformMatrix4fv(locs.glProjectionMatrix, 1, false, + Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentProjMat)), 0); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + } + if (locs.glProjectionMatrixInverse != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram)) + { + // EXPENSIVE!!!!! only calc if asked for, and even then... + try + { + ctx.currentProjMatInverse.set(ctx.currentProjMat); + ctx.matrixUtil.invert(ctx.currentProjMatInverse); + } + catch (SingularMatrixException e) + { + System.err.println("" + e); + } + + if (isGL2ES3) + gl.glUniformMatrix4fv(locs.glProjectionMatrixInverse, 1, true, ctx.matrixUtil.toArray(ctx.currentProjMatInverse), 0); + else + gl.glUniformMatrix4fv(locs.glProjectionMatrixInverse, 1, false, + Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentProjMatInverse)), 0); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + } + if (locs.glViewMatrix != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram)) + { + gl.glUniformMatrix4fv(locs.glViewMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentViewMat), 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + } + + if (locs.glModelMatrix != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.modelMatrix.m00 == Double.NEGATIVE_INFINITY)) + { + + if (isGL2ES3) + gl.glUniformMatrix4fv(locs.glModelMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelMat), 0); + else + gl.glUniformMatrix4fv(locs.glModelMatrix, 1, false, + Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelMat)), 0); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.modelMatrix.m00 = 0; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.modelMatrixUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.modelMatrixSkipped++; + } + } + + if (locs.glModelViewMatrix != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glModelViewMatrix.m00 == Double.NEGATIVE_INFINITY)) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + if (ctx.currentModelViewMat.m00 == Double.NEGATIVE_INFINITY) + ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); + + if (isGL2ES3) + gl.glUniformMatrix4fv(locs.glModelViewMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMat), 0); + else + gl.glUniformMatrix4fv(locs.glModelViewMatrix, 1, false, + Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewMat)), 0); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glModelViewMatrix.m00 = 0; + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glModelViewMatrixUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glModelViewMatrixSkipped++; + } + } + if (locs.glModelViewMatrixInverse != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glModelViewMatrixInverse.m00 == Double.NEGATIVE_INFINITY)) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + if (ctx.currentModelViewMatInverse.m00 == Double.NEGATIVE_INFINITY) + { + ctx.currentModelViewMatInverse.mul(ctx.currentViewMat, ctx.currentModelMat); + ctx.matrixUtil.invert(ctx.currentModelViewMatInverse); + } + + + if (isGL2ES3) + gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse), 0); + else + gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, false, + Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse)), 0); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glModelViewMatrixInverse.m00 = 0; + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glModelViewMatrixInverseUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glModelViewMatrixInverseSkipped++; + } + } + + if (locs.glModelViewProjectionMatrix != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram + || ctx.gl_state.glModelViewProjectionMatrix.m00 == Double.NEGATIVE_INFINITY)) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + if (ctx.currentModelViewMat.m00 == Double.NEGATIVE_INFINITY) + ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); + if (ctx.currentModelViewProjMat.m00 == Double.NEGATIVE_INFINITY) + ctx.currentModelViewProjMat.mul(ctx.currentProjMat, ctx.currentModelViewMat); + + if (isGL2ES3) + gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewProjMat), 0); + else + gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, false, + Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewProjMat)), 0); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glModelViewProjectionMatrix.m00 = 0; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glModelViewProjectionMatrixUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glModelViewProjectionMatrixSkipped++; + } + } + + if (locs.glNormalMatrix != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glNormalMatrix.m00 == Double.NEGATIVE_INFINITY)) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + if (ctx.currentModelViewMat.m00 == Double.NEGATIVE_INFINITY) + ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); + if (ctx.currentNormalMat.m00 == Double.NEGATIVE_INFINITY) + Jogl2es2MatrixUtil.transposeInvert(ctx.currentModelViewMat, ctx.currentNormalMat); + + if (isGL2ES3) + gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentNormalMat), 0); + else + gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, false, + Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentNormalMat)), 0); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glNormalMatrix.m00 = 0; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glNormalMatrixUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glNormalMatrixSkipped++; + } + } + + // if set one of the 2 colors below should be used by the shader (material for lighting) + + if (locs.ignoreVertexColors != -1) + { + // vertex colors MUST be ignored if no glColors set + boolean finalIgnoreVertexColors = (!floatColorsDefined && !byteColorsDefined) || ctx.renderingData.ignoreVertexColors == 1; + + //TODO: the execute calls all have a separate ignore vertex colors bool, but it appears to add no value? + // is it just a legacy artifact of some sort? + /*if(finalIgnoreVertexColors != ignoreVertexColors ) + { + System.out.println("odd mismatch I wonder about why "); + System.out.println("finalIgnoreVertexColors " +finalIgnoreVertexColors+ " ignoreVertexColors " +ignoreVertexColors); + System.out.println("ctx.renderingData.ignoreVertexColors " +ctx.renderingData.ignoreVertexColors); + System.out.println("floatColorsDefined " +floatColorsDefined); + }*/ + + int finalIgnoreVertexColorsInt = finalIgnoreVertexColors ? 1 : 0; + + //note ctx.gl_state.ignoreVertexColors can be -1 for not set + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram + || ctx.gl_state.ignoreVertexColors != finalIgnoreVertexColorsInt)) + { + gl.glUniform1i(locs.ignoreVertexColors, finalIgnoreVertexColorsInt);// note local variable used + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.ignoreVertexColors = finalIgnoreVertexColorsInt; + } + } + + // the front material structure + if (locs.glFrontMaterial.present) + { + //note != not equals + if (locs.glFrontMaterial.lightEnabled != -1 && (shaderProgramId != ctx.prevShaderProgram + || ctx.gl_state.glFrontMaterial.lightEnabled != ctx.materialData.lightEnabled)) + { + gl.glUniform1i(locs.glFrontMaterial.lightEnabled, ctx.materialData.lightEnabled); + ctx.gl_state.glFrontMaterial.lightEnabled = ctx.materialData.lightEnabled; + } + + if (locs.glFrontMaterial.ambient != -1 + && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.ambient.x == Float.NEGATIVE_INFINITY)) + { + gl.glUniform4f(locs.glFrontMaterial.ambient, ctx.materialData.ambient.x, ctx.materialData.ambient.y, + ctx.materialData.ambient.z, 1f); + ctx.gl_state.glFrontMaterial.ambient.x = 0; + } + if (locs.glFrontMaterial.diffuse != -1 + && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.diffuse.x == Float.NEGATIVE_INFINITY)) + { + gl.glUniform4f(locs.glFrontMaterial.diffuse, ctx.materialData.diffuse.x, ctx.materialData.diffuse.y, + ctx.materialData.diffuse.z, ctx.materialData.diffuse.w); + ctx.gl_state.glFrontMaterial.diffuse.x = 0; + } + if (locs.glFrontMaterial.emission != -1 + && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.emission.x == Float.NEGATIVE_INFINITY)) + { + gl.glUniform4f(locs.glFrontMaterial.emission, ctx.materialData.emission.x, ctx.materialData.emission.y, + ctx.materialData.emission.z, 1f); // note extra alpha value for ease + ctx.gl_state.glFrontMaterial.emission.x = 0; + } + if (locs.glFrontMaterial.specular != -1 + && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.specular.x == Float.NEGATIVE_INFINITY)) + { + gl.glUniform3f(locs.glFrontMaterial.specular, ctx.materialData.specular.x, ctx.materialData.specular.y, + ctx.materialData.specular.z); + ctx.gl_state.glFrontMaterial.specular.x = 0; + } + if (locs.glFrontMaterial.shininess != -1 + && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.shininess != ctx.materialData.shininess)) + { + gl.glUniform1f(locs.glFrontMaterial.shininess, ctx.materialData.shininess); + ctx.gl_state.glFrontMaterial.shininess = ctx.materialData.shininess; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + + // ambient does not come from material notice + if (locs.glLightModelambient != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glLightModelambient.x == Float.NEGATIVE_INFINITY)) + { + gl.glUniform4f(locs.glLightModelambient, ctx.currentAmbientColor.x, ctx.currentAmbientColor.y, ctx.currentAmbientColor.z, + ctx.currentAmbientColor.w); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glLightModelambient.x = 0; + } + } + + // always bind object color, the shader can decide to use it if it's no lighting and no vertex colors + if (locs.objectColor != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.objectColor.x == Float.NEGATIVE_INFINITY)) + { + gl.glUniform4f(locs.objectColor, ctx.objectColor.x, ctx.objectColor.y, ctx.objectColor.z, ctx.objectColor.w); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.objectColor.x = 0; + } + } + + if (locs.transparencyAlpha != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.transparencyAlpha != ctx.transparencyAlpha)) + { + gl.glUniform1f(locs.transparencyAlpha, ctx.transparencyAlpha); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.transparencyAlpha = ctx.transparencyAlpha; + } + } + + // count of enabled lights currentEnabledLights + if (locs.numberOfLights != -1) + { + //note ctx.gl_state.numberOfLights can be -1 for not set + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.numberOfLights != ctx.numberOfLights)) + { + gl.glUniform1i(locs.numberOfLights, ctx.numberOfLights); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.numberOfLights = ctx.numberOfLights; + } + } + + // the lighting structures + int pipelineLightSlotToUse = 0; + for (int shaderLightIndex = 0; shaderLightIndex < ctx.maxLights; shaderLightIndex++) + { + if (locs.glLightSource[pipelineLightSlotToUse] != null) + { + glLightSource glLightSource = ctx.glLightSource[shaderLightIndex]; + if (glLightSource.enabled == 1) + { + //Notice use of == as we want to see it's simply the exact same light source or not + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glLightSource[shaderLightIndex] != glLightSource)) + { + glLightSource.prevLightSlot = pipelineLightSlotToUse;// record for the equals to check for moved + + glLightSourceLocs glLightSourceLocs = locs.glLightSource[pipelineLightSlotToUse]; + if (glLightSourceLocs.position != -1) + gl.glUniform4f(glLightSourceLocs.position, glLightSource.position.x, glLightSource.position.y, + glLightSource.position.z, glLightSource.position.w); + if (glLightSourceLocs.diffuse != -1) + gl.glUniform4f(glLightSourceLocs.diffuse, glLightSource.diffuse.x, glLightSource.diffuse.y, + glLightSource.diffuse.z, glLightSource.diffuse.w); + if (glLightSourceLocs.specular != -1) + gl.glUniform4f(glLightSourceLocs.specular, glLightSource.specular.x, glLightSource.specular.y, + glLightSource.specular.z, glLightSource.specular.w); + if (glLightSourceLocs.constantAttenuation != -1) + gl.glUniform1f(glLightSourceLocs.constantAttenuation, glLightSource.constantAttenuation); + if (glLightSourceLocs.linearAttenuation != -1) + gl.glUniform1f(glLightSourceLocs.linearAttenuation, glLightSource.linearAttenuation); + if (glLightSourceLocs.quadraticAttenuation != -1) + gl.glUniform1f(glLightSourceLocs.quadraticAttenuation, glLightSource.quadraticAttenuation); + if (glLightSourceLocs.spotCutoff != -1) + gl.glUniform1f(glLightSourceLocs.spotCutoff, glLightSource.spotCutoff); + if (glLightSourceLocs.spotExponent != -1) + gl.glUniform1f(glLightSourceLocs.spotExponent, glLightSource.spotExponent); + if (glLightSourceLocs.spotDirection != -1) + gl.glUniform3f(glLightSourceLocs.spotDirection, glLightSource.spotDirection.x, glLightSource.spotDirection.y, + glLightSource.spotDirection.z); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glLightSource[shaderLightIndex] = glLightSource; + } + pipelineLightSlotToUse++; + + } + } + } + + if (locs.alphaTestEnabled != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.alphaTestEnabled != ctx.renderingData.alphaTestEnabled)) + { + gl.glUniform1i(locs.alphaTestEnabled, ctx.renderingData.alphaTestEnabled ? 1 : 0); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.alphaTestEnabled = ctx.renderingData.alphaTestEnabled; + + if (ctx.renderingData.alphaTestEnabled == true) + { + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram + || ctx.gl_state.alphaTestFunction != ctx.renderingData.alphaTestFunction)) + { + gl.glUniform1i(locs.alphaTestFunction, getFunctionValue(ctx.renderingData.alphaTestFunction)); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.alphaTestFunction = ctx.renderingData.alphaTestFunction; + } + + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram + || ctx.gl_state.alphaTestValue != ctx.renderingData.alphaTestValue)) + { + gl.glUniform1f(locs.alphaTestValue, ctx.renderingData.alphaTestValue); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.alphaTestValue = ctx.renderingData.alphaTestValue; + } + } + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + if (locs.textureTransform != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.textureTransform.m00 == Double.NEGATIVE_INFINITY)) + { + // gl.glUniformMatrix4fv(locs.textureTransform, 1, true, ctx.toFB(ctx.textureTransform)); + gl.glUniformMatrix4fv(locs.textureTransform, 1, true, ctx.matrixUtil.toArray(ctx.textureTransform), 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.textureTransform.m00 = 0; + } + } + + // Fog + if (locs.fogData.present && locs.fogData.fogEnabled != -1) + { + if (!MINIMISE_NATIVE_CALLS_FFP || shaderProgramId != ctx.prevShaderProgram + || ctx.gl_state.fogData.fogEnabled != ctx.fogData.fogEnabled) + { + gl.glUniform1i(locs.fogData.fogEnabled, ctx.fogData.fogEnabled); + + ctx.gl_state.fogData.fogEnabled = ctx.fogData.fogEnabled; + + if (ctx.fogData.fogEnabled == 1) + { + if ((shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.fogData.expColor.x == Float.NEGATIVE_INFINITY)) + { + if (locs.fogData.expColor != -1) + gl.glUniform4f(locs.fogData.expColor, ctx.fogData.expColor.x, ctx.fogData.expColor.y, ctx.fogData.expColor.z, + 1.0f); + if (locs.fogData.expDensity != -1) + gl.glUniform1f(locs.fogData.expDensity, ctx.fogData.expDensity); + if (locs.fogData.linearColor != -1) + gl.glUniform4f(locs.fogData.linearColor, ctx.fogData.linearColor.x, ctx.fogData.linearColor.y, + ctx.fogData.linearColor.z, 1.0f); + if (locs.fogData.linearStart != -1) + gl.glUniform1f(locs.fogData.linearStart, ctx.fogData.linearStart); + if (locs.fogData.linearEnd != -1) + gl.glUniform1f(locs.fogData.linearEnd, ctx.fogData.linearEnd); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.fogData.expColor.x = 0; + } + } + } + } + + // record for the next loop through FFP + ctx.prevShaderProgram = shaderProgramId; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + + private boolean NO_PROGRAM_WARNING_GIVEN = false; + + // ---------------------------------------------------------------------- + // Private helper methods for GeometryArrayRetained and IndexedGeometryArrayRetained + // + + private static void loadLocs(Jogl2es2Context ctx, GL2ES2 gl) + { + ProgramData pd = ctx.programData; + if (pd.programToLocationData == null) + { + LocationData locs = new LocationData(); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.programToLocationData++; + + int shaderProgramId = ctx.shaderProgramId; + // shader program can be disabled, but locs still called + if (shaderProgramId != -1) + { + locs.glProjectionMatrix = gl.glGetUniformLocation(shaderProgramId, "glProjectionMatrix"); + locs.glProjectionMatrixInverse = gl.glGetUniformLocation(shaderProgramId, "glProjectionMatrixInverse"); + locs.glModelMatrix = gl.glGetUniformLocation(shaderProgramId, "glModelMatrix"); + locs.glViewMatrix = gl.glGetUniformLocation(shaderProgramId, "glViewMatrix"); + locs.glModelViewMatrix = gl.glGetUniformLocation(shaderProgramId, "glModelViewMatrix"); + locs.glModelViewMatrixInverse = gl.glGetUniformLocation(shaderProgramId, "glModelViewMatrixInverse"); + locs.glModelViewProjectionMatrix = gl.glGetUniformLocation(shaderProgramId, "glModelViewProjectionMatrix"); + locs.glNormalMatrix = gl.glGetUniformLocation(shaderProgramId, "glNormalMatrix"); + locs.ignoreVertexColors = gl.glGetUniformLocation(shaderProgramId, "ignoreVertexColors"); + locs.glLightModelambient = gl.glGetUniformLocation(shaderProgramId, "glLightModelambient"); + locs.objectColor = gl.glGetUniformLocation(shaderProgramId, "objectColor"); + locs.transparencyAlpha = gl.glGetUniformLocation(shaderProgramId, "transparencyAlpha"); + locs.alphaTestEnabled = gl.glGetUniformLocation(shaderProgramId, "alphaTestEnabled"); + locs.alphaTestFunction = gl.glGetUniformLocation(shaderProgramId, "alphaTestFunction"); + locs.alphaTestValue = gl.glGetUniformLocation(shaderProgramId, "alphaTestValue"); + locs.textureTransform = gl.glGetUniformLocation(shaderProgramId, "textureTransform"); + + locs.fogData.fogEnabled = gl.glGetUniformLocation(shaderProgramId, "fogData.fogEnabled"); + locs.fogData.expColor = gl.glGetUniformLocation(shaderProgramId, "fogData.expColor"); + locs.fogData.expDensity = gl.glGetUniformLocation(shaderProgramId, "fogData.expDensity"); + locs.fogData.linearColor = gl.glGetUniformLocation(shaderProgramId, "fogData.linearColor"); + locs.fogData.linearStart = gl.glGetUniformLocation(shaderProgramId, "fogData.linearStart"); + locs.fogData.linearEnd = gl.glGetUniformLocation(shaderProgramId, "fogData.linearEnd"); + locs.fogData.setPresent(); + + locs.glFrontMaterial.lightEnabled = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.lightEnabled"); + locs.glFrontMaterial.ambient = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.ambient"); + locs.glFrontMaterial.diffuse = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.diffuse"); + locs.glFrontMaterial.emission = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.emission"); + locs.glFrontMaterial.specular = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.specular"); + locs.glFrontMaterial.shininess = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.shininess"); + locs.glFrontMaterial.setPresent(); + + locs.numberOfLights = gl.glGetUniformLocation(shaderProgramId, "numberOfLights"); + + // lights, notice the vertex attribute is made of a string concat + // notice we stop once the light loc is not found, as that is the max the shader will accept + for (int i = 0; i < locs.glLightSource.length; i++) + { + int position = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].position"); + if (position != -1) + { + locs.glLightSource[i] = new glLightSourceLocs(); + locs.glLightSource[i].position = position; + locs.glLightSource[i].diffuse = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].diffuse"); + locs.glLightSource[i].specular = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].specular"); + locs.glLightSource[i].constantAttenuation = gl.glGetUniformLocation(shaderProgramId, + "glLightSource[" + i + "].constantAttenuation"); + locs.glLightSource[i].linearAttenuation = gl.glGetUniformLocation(shaderProgramId, + "glLightSource[" + i + "].linearAttenuation"); + locs.glLightSource[i].quadraticAttenuation = gl.glGetUniformLocation(shaderProgramId, + "glLightSource[" + i + "].quadraticAttenuation"); + locs.glLightSource[i].spotCutoff = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].spotCutoff"); + locs.glLightSource[i].spotExponent = gl.glGetUniformLocation(shaderProgramId, + "glLightSource[" + i + "].spotExponent"); + locs.glLightSource[i].spotDirection = gl.glGetUniformLocation(shaderProgramId, + "glLightSource[" + i + "].spotDirection"); + } + else + { + break; + } + } + + ///////ATTRIBUTES!!!!!!!!/////////////////// + locs.glVertex = gl.glGetAttribLocation(shaderProgramId, "glVertex"); + locs.glColor = gl.glGetAttribLocation(shaderProgramId, "glColor"); + locs.glNormal = gl.glGetAttribLocation(shaderProgramId, "glNormal"); + + // tex coords, notice the vertex attribute is made of a string concat + for (int i = 0; i < locs.glMultiTexCoord.length; i++) + { + locs.glMultiTexCoord[i] = gl.glGetAttribLocation(shaderProgramId, "glMultiTexCoord" + i); + } + + // generic attributes, notice allocated on a program basis not per geom + HashMap<String, Integer> attToIndex = pd.progToGenVertAttNameToGenVertAttIndex; + if (attToIndex != null) + { + for (String attrib : attToIndex.keySet()) + { + int index = attToIndex.get(attrib); + int attribLoc = gl.glGetAttribLocation(shaderProgramId, attrib); + locs.genAttIndexToLoc.put(index, new Integer(attribLoc)); + } + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + pd.programToLocationData = locs; + } + } + + /** + * The buffers will be loaded and pointers set in GeometryData for this geometry native id + * Note however morphable data will also be reloaded (only coords for now) + * @param ctx + * @param gl + * @param geo + * @param ignoreVertexColors + * @param vertexCount + * @param vformat + * @param vdefined + * @param fverts + * @param startVertex + * @param fclrs + * @param startClrs + * @return + */ + private static GeometryData loadAllBuffers(Jogl2es2Context ctx, GL2ES2 gl, GeometryArrayRetained geo, boolean ignoreVertexColors, + int vertexCount, int vformat, int vdefined, FloatBuffer fverts, float[] vfarray, int startVertex, FloatBuffer fclrs, + float[] cfarray, int startClrs) + { + if (VERBOSE) + System.err.println("private static GeometryData loadAllBuffers"); + + GeometryData gd = ctx.allGeometryData.get(geo.nativeId); + if (gd == null) + { + gd = new GeometryData(); + geo.nativeId = gd.nativeId; + ctx.allGeometryData.put(geo.nativeId, gd); + } + + if (gd.geoToCoordBuf == -1) + { + + // do we need to covert a float[] + if (vfarray != null) + { + fverts = getVertexArrayBuffer(vfarray); + } + // can it change ever? (GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of this feature) + boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE) + || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE); + + fverts.position(startVertex); + + if (morphable) + { + int[] tmp = new int[2]; + gl.glGenBuffers(2, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + gd.geoToCoordBuf1 = tmp[0]; + gd.geoToCoordBuf2 = tmp[1]; + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW; + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage); + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage); + } + else + { + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW; + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage); + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + gd.geoToCoordBufSize = fverts.remaining(); + + if (ctx.allGeometryData.size() % 500 == 0) + { + System.out.println("Coord buffer count " + ctx.allGeometryData.size()); + } + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + } + + if (!ignoreVertexColors) + { + if (gd.geoToColorBuf == -1) + { + if (cfarray != null) + { + fclrs = getColorArrayBuffer(cfarray); + } + if (fclrs != null) + { + if (fclrs != fverts) + { + fclrs.position(startClrs); + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + gd.geoToColorBuf = tmp[0]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, fclrs.remaining() * Float.SIZE / 8, fclrs, GL2ES2.GL_STATIC_DRAW); + } + else + { + gd.geoToColorBuf = gd.geoToCoordBuf; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + } + } + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + return gd; + } + + private static GeometryData loadAllBuffers(Jogl2es2Context ctx, GL2ES2 gl, GeometryArrayRetained geo, boolean ignoreVertexColors, + int vertexCount, int vformat, int vdefined, FloatBuffer fverts, float[] vfcoords, DoubleBuffer dverts, double[] vdcoords, + FloatBuffer fclrs, float[] cfarray, ByteBuffer bclrs, byte[] cbdata, FloatBuffer norms, float[] narray, int vertexAttrCount, + int[] vertexAttrSizes, FloatBuffer[] vertexAttrBufs, float[][] vertexAttrData, int texCoordMapLength, int[] texCoordSetMap, + int texStride, Object[] texCoords) + { + if (VERBOSE) + System.err.println("private static GeometryData loadAllBuffers"); + + GeometryData gd = ctx.allGeometryData.get(geo.nativeId); + if (gd == null) + { + gd = new GeometryData(); + geo.nativeId = gd.nativeId; + ctx.allGeometryData.put(geo.nativeId, gd); + } + + boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0); + boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0); + boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0); + boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0); + boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0); + boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0); + boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0); + + if (floatCoordDefined) + { + if (gd.geoToCoordBuf == -1) + { + // do we need to covert a float[] + if (vfcoords != null) + { + fverts = getVertexArrayBuffer(vfcoords); + } + + // can it change ever? (GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of this feature) + boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE) + || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE); + + fverts.position(0); + + if (morphable) + { + int[] tmp = new int[2]; + gl.glGenBuffers(2, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + gd.geoToCoordBuf1 = tmp[0]; + gd.geoToCoordBuf2 = tmp[1]; + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1); + int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW; + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage); + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage); + } + else + { + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + gd.geoToCoordBuf = tmp[0]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf); + int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW; + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage); + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + gd.geoToCoordBufSize = fverts.remaining(); + + if (ctx.allGeometryData.size() % 500 == 0) + { + System.out.println("Coord buffer count " + ctx.allGeometryData.size()); + } + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + } + } + + if (floatColorsDefined && !ignoreVertexColors) + { + if (gd.geoToColorBuf == -1) + { + if (cfarray != null) + { + fclrs = getColorArrayBuffer(cfarray); + } + + fclrs.position(0); + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + gd.geoToColorBuf = tmp[0]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, fclrs.remaining() * Float.SIZE / 8, fclrs, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + } + } + + if (normalsDefined) + { + if (gd.geoToNormalBuf == -1) + { + if (narray != null) + { + norms = getNormalArrayBuffer(narray); + } + + norms.position(0); + + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + gd.geoToNormalBuf = tmp[0]; + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, norms.remaining() * Float.SIZE / 8, norms, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + } + } + + if (vattrDefined) + { + if (vertexAttrData != null) + { + vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData); + } + + for (int index = 0; index < vertexAttrCount; index++) + { + FloatBuffer vertexAttrs = vertexAttrBufs[index]; + vertexAttrs.position(0); + + SparseArray<Integer> bufIds = gd.geoToVertAttribBuf; + if (bufIds == null) + { + bufIds = new SparseArray<Integer>(); + gd.geoToVertAttribBuf = bufIds; + } + + Integer bufId = bufIds.get(index); + if (bufId == null) + { + int[] tmp2 = new int[1]; + gl.glGenBuffers(1, tmp2, 0); + bufId = new Integer(tmp2[0]); + bufIds.put(index, bufId); + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, vertexAttrs.remaining() * Float.SIZE / 8, vertexAttrs, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + + } + } + } + + if (textureDefined) + { + // convert from float[][] to FloatBuffer[] + //WOW careful java has a hard time knowing what an Object[] contains can't check float[][] + if (!(texCoords[0] instanceof FloatBuffer)) + { + texCoords = getTexCoordSetBuffer(texCoords); + } + + boolean[] texSetsLoaded = new boolean[texCoords.length]; + for (int texUnit = 0; texUnit < texCoordMapLength; texUnit++) + { + int texSet = texCoordSetMap[texUnit]; + if (texSet != -1 && !texSetsLoaded[texSet]) + { + texSetsLoaded[texSet] = true; + // stupid interface... + FloatBuffer buf = (FloatBuffer) texCoords[texSet]; + buf.position(0); + + SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf; + if (bufIds == null) + { + bufIds = new SparseArray<Integer>(); + gd.geoToTexCoordsBuf = bufIds; + } + + Integer bufId = bufIds.get(texUnit); + if (bufId == null) + { + int[] tmp = new int[1]; + gl.glGenBuffers(1, tmp, 0); + bufId = new Integer(tmp[0]); + + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue()); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, buf.remaining() * Float.SIZE / 8, buf, GL2ES2.GL_STATIC_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + bufIds.put(texUnit, bufId); + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glBufferData++; + } + } + } + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + return gd; + } + + // --Noop + @Override + void setVertexFormat(Context ctx, GeometryArrayRetained geo, int vformat, boolean useAlpha, boolean ignoreVertexColors) + { + // if (VERBOSE) + // System.err.println("JoglPipeline.setVertexFormat()"); + } + + // --------------------------------------------------------------------- + // Native method for readRaster + @Override + void readRaster(Context ctx, int type, int xSrcOffset, int ySrcOffset, int width, int height, int hCanvas, int imageDataType, + int imageFormat, Object imageBuffer, int depthFormat, Object depthBuffer) + { + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + GL2ES2 gl = joglesctx.gl2es2(); + + //gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width); + gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + int yAdjusted = hCanvas - height - ySrcOffset; + + if ((type & Raster.RASTER_COLOR) != 0) + { + int format = 0; + if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) + { + + switch (imageFormat) + { + case ImageComponentRetained.TYPE_BYTE_BGR: + format = GL2ES2.GL_BGR; + break; + case ImageComponentRetained.TYPE_BYTE_RGB: + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_BYTE_ABGR: + format = GL2ES2.GL_RGBA; + break; + case ImageComponentRetained.TYPE_BYTE_RGBA: + // all RGB types are stored as RGBA + format = GL2ES2.GL_RGBA; + break; + case ImageComponentRetained.TYPE_BYTE_LA: + // all LA types are stored as LA8 + format = GL2ES2.GL_LUMINANCE_ALPHA; + break; + case ImageComponentRetained.TYPE_BYTE_GRAY: + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_INT_BGR: + case ImageComponentRetained.TYPE_INT_RGB: + case ImageComponentRetained.TYPE_INT_ARGB: + default: + assert false; + return; + } + + gl.glReadPixels(xSrcOffset, yAdjusted, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, + ByteBuffer.wrap((byte[]) imageBuffer)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) + { + switch (imageFormat) + { + case ImageComponentRetained.TYPE_INT_BGR: + //PJ does this work correctly? + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_RGB: + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_ARGB: + format = GL2ES2.GL_RGBA; + break; + // This method only supports 3 and 4 components formats and INT types. + case ImageComponentRetained.TYPE_BYTE_LA: + case ImageComponentRetained.TYPE_BYTE_GRAY: + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_BYTE_BGR: + case ImageComponentRetained.TYPE_BYTE_RGB: + case ImageComponentRetained.TYPE_BYTE_RGBA: + case ImageComponentRetained.TYPE_BYTE_ABGR: + default: + assert false; + return; + } + + gl.glReadPixels(xSrcOffset, yAdjusted, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, IntBuffer.wrap((int[]) imageBuffer)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + else + { + assert false; + } + } + + if ((type & Raster.RASTER_DEPTH) != 0) + { + throw new UnsupportedOperationException( + "To get depth you should use a shader that return depth info for gl2es2 then read from color"); + /*if (depthFormat == DepthComponentRetained.DEPTH_COMPONENT_TYPE_INT) + { + // yOffset is adjusted for OpenGL - Y upward + gl.glReadPixels(xSrcOffset, yAdjusted, width, height, GL2.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_INT, + IntBuffer.wrap((int[]) depthBuffer)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + // DEPTH_COMPONENT_TYPE_FLOAT + // yOffset is adjusted for OpenGL - Y upward + gl.glReadPixels(xSrcOffset, yAdjusted, width, height, GL2.GL_DEPTH_COMPONENT, GL.GL_FLOAT, + FloatBuffer.wrap((float[]) depthBuffer)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + }*/ + } + + } + + // --------------------------------------------------------------------- + + // + // GLSLShaderProgramRetained methods + // + + // ShaderAttributeValue methods + + @Override + ShaderError setGLSLUniform1i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform1i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value=" + value + ")"); + + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + GL2ES2 gl = joglesctx.gl2es2(); + int loc = unbox(uniformLocation); + if (!MINIMISE_NATIVE_SHADER || joglesctx.gl_state.setGLSLUniform1i[loc] != value) + { + gl.glUniform1i(loc, value); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_SHADER) + joglesctx.gl_state.setGLSLUniform1i[loc] = value; + } + return null; + } + + @Override + ShaderError setGLSLUniform1f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform1f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value=" + value + ")"); + + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + GL2ES2 gl = joglesctx.gl2es2(); + int loc = unbox(uniformLocation); + if (!MINIMISE_NATIVE_SHADER || joglesctx.gl_state.setGLSLUniform1f[loc] != value) + { + gl.glUniform1f(loc, value); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_SHADER) + joglesctx.gl_state.setGLSLUniform1f[loc] = value; + } + return null; + } + + @Override + ShaderError setGLSLUniform2i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform2i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform2i(unbox(uniformLocation), value[0], value[1]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform2f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform2f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform2f(unbox(uniformLocation), value[0], value[1]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform3i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform3i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform3i(unbox(uniformLocation), value[0], value[1], value[2]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform3f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform3f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform3f(unbox(uniformLocation), value[0], value[1], value[2]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform4i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform4i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform4i(unbox(uniformLocation), value[0], value[1], value[2], value[3]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform4f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform4f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform4f(unbox(uniformLocation), value[0], value[1], value[2], value[3]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniformMatrix3f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniformMatrix3f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + // Load attribute + // transpose is true : each matrix is supplied in row major order + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniformMatrix3fv(unbox(uniformLocation), 1, false, ((Jogl2es2Context) ctx).matrixUtil.toFB3(value)); + // gl.glUniformMatrix3fv(unbox(uniformLocation), 1, true, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniformMatrix4f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniformMatrix4f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation=" + + unbox(uniformLocation) + ",value[0]=" + value[0] + ")"); + + // Load attribute + // transpose is true : each matrix is supplied in row major order + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniformMatrix4fv(unbox(uniformLocation), 1, false, ((Jogl2es2Context) ctx).matrixUtil.toFB4(value)); + // gl.glUniformMatrix4fv(unbox(uniformLocation), 1, true, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + // ShaderAttributeArray methods + + @Override + ShaderError setGLSLUniform1iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform1iArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform1iv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform1fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform1fArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform1fv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform2iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform2iArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform2iv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform2fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform2fArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform2fv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform3iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform3iArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform3iv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform3fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform3fArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform3fv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform4iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform4iArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform4iv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniform4fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniform4fArray()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniform4fv(unbox(uniformLocation), numElements, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniformMatrix3fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniformMatrix3fArray()"); + + // Load attribute + // transpose is true : each matrix is supplied in row major order + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniformMatrix3fv(unbox(uniformLocation), numElements, true, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError setGLSLUniformMatrix4fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value) + { + if (VERBOSE) + System.err.println("JoglPipeline.setGLSLUniformMatrix4fArray()"); + + // Load attribute + // transpose is true : each matrix is supplied in row major order + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glUniformMatrix4fv(unbox(uniformLocation), numElements, true, value, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + // interfaces for shader compilation, etc. + @Override + ShaderError createGLSLShader(Context ctx, int shaderType, ShaderId[] shaderId) + { + if (VERBOSE) + System.err.println("JoglPipeline.createGLSLShader()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.createGLSLShader++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + int shaderHandle = 0; + if (shaderType == Shader.SHADER_TYPE_VERTEX) + { + shaderHandle = gl.glCreateShader(GL2ES2.GL_VERTEX_SHADER); + } + else if (shaderType == Shader.SHADER_TYPE_FRAGMENT) + { + shaderHandle = gl.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER); + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (shaderHandle == 0) + { + return new ShaderError(ShaderError.COMPILE_ERROR, "Unable to create native shader object"); + } + + shaderId[0] = new JoglShaderObject(shaderHandle); + + return null; + } + + @Override + ShaderError destroyGLSLShader(Context ctx, ShaderId shaderId) + { + if (VERBOSE) + System.err.println("JoglPipeline.destroyGLSLShader()"); + + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.destroyGLSLShader++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glDeleteShader(unbox(shaderId)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + return null; + } + + @Override + ShaderError compileGLSLShader(Context ctx, ShaderId shaderId, String program) + { + if (VERBOSE) + System.err.println("JoglPipeline.compileGLSLShader()"); + + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.compileGLSLShader++; + + int id = unbox(shaderId); + if (id == 0) + { + throw new AssertionError("shaderId == 0"); + } + + if (program == null) + { + throw new AssertionError("shader program string is null"); + } + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + gl.glShaderSource(id, 1, new String[] { program }, null, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + gl.glCompileShader(id); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + int[] status = new int[1]; + gl.glGetShaderiv(id, GL2ES2.GL_COMPILE_STATUS, status, 0); + if (status[0] == 0) + { + String detailMsg = getShaderInfoLog(gl, id); + ShaderError res = new ShaderError(ShaderError.COMPILE_ERROR, "GLSL shader compile error"); + res.setDetailMessage(detailMsg); + return res; + } + return null; + } + + @Override + ShaderError createGLSLShaderProgram(Context ctx, ShaderProgramId[] shaderProgramId) + { + if (VERBOSE) + System.err.println("JoglPipeline.createGLSLShaderProgram()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.createGLSLShaderProgram++; + + int shaderProgramHandle = gl.glCreateProgram(); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (shaderProgramHandle == 0) + { + return new ShaderError(ShaderError.LINK_ERROR, "Unable to create native shader program object"); + } + shaderProgramId[0] = new JoglShaderObject(shaderProgramHandle); + + return null; + } + + @Override + ShaderError destroyGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId) + { + if (VERBOSE) + System.err.println("JoglPipeline.destroyGLSLShaderProgram()"); + + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.destroyGLSLShaderProgram++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glDeleteShader(unbox(shaderProgramId)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + // just dump data + ((Jogl2es2Context) ctx).allProgramData.remove(unbox(shaderProgramId)); + + return null; + } + + @Override + ShaderError linkGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId, ShaderId[] shaderIds) + { + if (VERBOSE) + System.err.println("JoglPipeline.linkGLSLShaderProgram()"); + + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.linkGLSLShaderProgram++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + int id = unbox(shaderProgramId); + for (int i = 0; i < shaderIds.length; i++) + { + gl.glAttachShader(id, unbox(shaderIds[i])); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + gl.glLinkProgram(id); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + int[] status = new int[1]; + gl.glGetProgramiv(id, GL2ES2.GL_LINK_STATUS, status, 0); + if (status[0] == 0) + { + String detailMsg = getProgramInfoLog(gl, id); + ShaderError res = new ShaderError(ShaderError.LINK_ERROR, "GLSL shader program link error"); + res.setDetailMessage(detailMsg); + return res; + } + return null; + } + + @Override + ShaderError bindGLSLVertexAttrName(Context ctx, ShaderProgramId shaderProgramId, String attrName, int attrIndex) + { + if (VERBOSE) + System.err.println("JoglPipeline.bindGLSLVertexAttrName()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.bindGLSLVertexAttrName++; + + // GL2ES2 gl = context(ctx).getGL().getGL2ES2(); + // gl.glBindAttribLocation(unbox(shaderProgramId), attrIndex + VirtualUniverse.mc.glslVertexAttrOffset, attrName); + + // record this for later, we'll get real locations in the locationData setup + int progId = unbox(shaderProgramId); + Jogl2es2Context joglesContext = (Jogl2es2Context) ctx; + ProgramData pd = joglesContext.allProgramData.get(progId); + if (pd == null) + { + pd = new ProgramData(); + joglesContext.allProgramData.put(progId, pd); + } + + HashMap<String, Integer> attToIndex = pd.progToGenVertAttNameToGenVertAttIndex; + if (attToIndex == null) + { + attToIndex = new HashMap<String, Integer>(); + pd.progToGenVertAttNameToGenVertAttIndex = attToIndex; + } + + attToIndex.put(attrName, attrIndex); + + return null; + } + + @Override + void lookupGLSLShaderAttrNames(Context ctx, ShaderProgramId shaderProgramId, int numAttrNames, String[] attrNames, + ShaderAttrLoc[] locArr, int[] typeArr, int[] sizeArr, boolean[] isArrayArr) + { + if (VERBOSE) + System.err.println("JoglPipeline.lookupGLSLShaderAttrNames()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.lookupGLSLShaderAttrNames++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + // set the loc, type, and size arrays to out-of-bound values + for (int i = 0; i < attrNames.length; i++) + { + locArr[i] = null; + typeArr[i] = -1; + sizeArr[i] = -1; + } + + // Loop through the list of active uniform variables, one at a + // time, searching for a match in the attrNames array. + // + // NOTE: Since attrNames isn't sorted, and we don't have a + // hashtable of names to index locations, we will do a + // brute-force, linear search of the array. This leads to an + // O(n^2) algorithm (actually O(n*m) where n is attrNames.length + // and m is the number of uniform variables), but since we expect + // N to be small, we will not optimize this at this time. + int id = unbox(shaderProgramId); + int[] tmp = new int[1]; + int[] tmp2 = new int[1]; + int[] tmp3 = new int[1]; + + gl.glGetProgramiv(id, GL2ES2.GL_ACTIVE_UNIFORMS, tmp, 0); + int numActiveUniforms = tmp[0]; + gl.glGetProgramiv(id, GL2ES2.GL_ACTIVE_UNIFORM_MAX_LENGTH, tmp, 0); + int maxStrLen = tmp[0]; + byte[] nameBuf = new byte[maxStrLen]; + + for (int i = 0; i < numActiveUniforms; i++) + { + gl.glGetActiveUniform(id, i, maxStrLen, tmp3, 0, tmp, 0, tmp2, 0, nameBuf, 0); + int size = tmp[0]; + int type = tmp2[0]; + String name = null; + try + { + name = new String(nameBuf, 0, tmp3[0], "US-ASCII"); + } + catch (UnsupportedEncodingException e) + { + throw new RuntimeException(e); + } + + // Issue 247 - we need to workaround an ATI bug where they erroneously + // report individual elements of arrays rather than the array itself + if (name.length() >= 3 && name.endsWith("]")) + { + if (name.endsWith("[0]")) + { + name = name.substring(0, name.length() - 3); + } + else + { + // Ignore this name + continue; + } + } + + // Now try to find the name + for (int j = 0; j < numAttrNames; j++) + { + if (name.equals(attrNames[j])) + { + sizeArr[j] = size; + isArrayArr[j] = (size > 1); + typeArr[j] = glslToJ3dType(type); + break; + } + } + } + + // Now lookup the location of each name in the attrNames array + for (int i = 0; i < numAttrNames; i++) + { + // Get uniform attribute location + int loc = gl.glGetUniformLocation(id, attrNames[i]); + locArr[i] = new JoglShaderObject(loc); + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // good ideas about uniform debugging + // http://stackoverflow.com/questions/26164602/unexplainable-gl-invalid-operation-from-gluniform1i-opengl-thinks-an-int-is-a-f + private boolean USE_NULL_SHADER_WARNING_GIVEN = false; + + @Override + ShaderError useGLSLShaderProgram(Context ctx, ShaderProgramId inShaderProgramId) + { + int shaderProgramId = unbox(inShaderProgramId); + if (VERBOSE) + System.err.println("JoglPipeline.useGLSLShaderProgram(shaderProgramId=" + shaderProgramId + ")"); + + Jogl2es2Context joglesContext = (Jogl2es2Context) ctx; + if (OUTPUT_PER_FRAME_STATS) + { + if (joglesContext.gl_state.currentProgramId == shaderProgramId) + { + joglesContext.perFrameStats.redundantUseProgram++; + } + else + { + joglesContext.perFrameStats.useGLSLShaderProgram++; + joglesContext.perFrameStats.usedPrograms.add(inShaderProgramId); + } + } + + if (!MINIMISE_NATIVE_SHADER || joglesContext.gl_state.currentProgramId != shaderProgramId) + { + if (shaderProgramId == -1) + { + if (!USE_NULL_SHADER_WARNING_GIVEN) + System.err.println("Null shader passed for use"); + USE_NULL_SHADER_WARNING_GIVEN = true; + } + + GL2ES2 gl = joglesContext.gl2es2(); + + gl.glUseProgram(shaderProgramId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + joglesContext.setShaderProgram((JoglShaderObject) inShaderProgramId); + loadLocs(joglesContext, gl); + + if (MINIMISE_NATIVE_SHADER) + joglesContext.gl_state.currentProgramId = shaderProgramId; + + } + return null; + } + + // ---------------------------------------------------------------------- + // Helper methods for above shader routines + // + private static int unbox(ShaderAttrLoc loc) + { + if (loc == null) + return -1;//0 is a valid location + return ((JoglShaderObject) loc).getValue(); + } + + private static int unbox(ShaderProgramId id) + { + if (id == null) + return 0; + return ((JoglShaderObject) id).getValue(); + } + + private static int unbox(ShaderId id) + { + if (id == null) + return 0; + return ((JoglShaderObject) id).getValue(); + } + + private static String getShaderInfoLog(GL2ES2 gl, int id) + { + int[] infoLogLength = new int[1]; + gl.glGetShaderiv(id, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0); + if (infoLogLength[0] > 0) + { + byte[] storage = new byte[infoLogLength[0]]; + int[] len = new int[1]; + gl.glGetShaderInfoLog(id, infoLogLength[0], len, 0, storage, 0); + try + { + return new String(storage, 0, len[0], "US-ASCII"); + } + catch (UnsupportedEncodingException e) + { + throw new RuntimeException(e); + } + } + return null; + } + + private static String getProgramInfoLog(GL2ES2 gl, int id) + { + int[] infoLogLength = new int[1]; + gl.glGetProgramiv(id, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0); + if (infoLogLength[0] > 0) + { + byte[] storage = new byte[infoLogLength[0]]; + int[] len = new int[1]; + gl.glGetProgramInfoLog(id, infoLogLength[0], len, 0, storage, 0); + try + { + return new String(storage, 0, len[0], "US-ASCII"); + } + catch (UnsupportedEncodingException e) + { + throw new RuntimeException(e); + } + } + return null; + } + + private static int glslToJ3dType(int type) + { + switch (type) + { + case GL2ES2.GL_BOOL: + case GL2ES2.GL_INT: + case GL2ES2.GL_SAMPLER_2D: + case GL2ES2.GL_SAMPLER_3D: + case GL2ES2.GL_SAMPLER_CUBE: + return ShaderAttributeObjectRetained.TYPE_INTEGER; + + case GL2ES2.GL_FLOAT: + return ShaderAttributeObjectRetained.TYPE_FLOAT; + + case GL2ES2.GL_INT_VEC2: + case GL2ES2.GL_BOOL_VEC2: + return ShaderAttributeObjectRetained.TYPE_TUPLE2I; + + case GL2ES2.GL_FLOAT_VEC2: + return ShaderAttributeObjectRetained.TYPE_TUPLE2F; + + case GL2ES2.GL_INT_VEC3: + case GL2ES2.GL_BOOL_VEC3: + return ShaderAttributeObjectRetained.TYPE_TUPLE3I; + + case GL2ES2.GL_FLOAT_VEC3: + return ShaderAttributeObjectRetained.TYPE_TUPLE3F; + + case GL2ES2.GL_INT_VEC4: + case GL2ES2.GL_BOOL_VEC4: + return ShaderAttributeObjectRetained.TYPE_TUPLE4I; + + case GL2ES2.GL_FLOAT_VEC4: + return ShaderAttributeObjectRetained.TYPE_TUPLE4F; + + // case GL2ES2.GL_FLOAT_MAT2: + + case GL2ES2.GL_FLOAT_MAT3: + return ShaderAttributeObjectRetained.TYPE_MATRIX3F; + + case GL2ES2.GL_FLOAT_MAT4: + return ShaderAttributeObjectRetained.TYPE_MATRIX4F; + + // Java 3D does not support the following sampler types: + // + // case GL2ES2.GL_SAMPLER_1D_ARB: + // case GL2ES2.GL_SAMPLER_1D_SHADOW_ARB: + // case GL2ES2.GL_SAMPLER_2D_SHADOW_ARB: + // case GL2ES2.GL_SAMPLER_2D_RECT_ARB: + // case GL2ES2.GL_SAMPLER_2D_RECT_SHADOW_ARB: + } + + return -1; + } + + // --------------------------------------------------------------------- + + private static final Vector4f black = new Vector4f(); + + // + // DirectionalLightRetained methods + // + @Override + void updateDirectionalLight(Context ctx, int lightSlot, float red, float green, float blue, float dirx, float diry, float dirz) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateDirectionalLight() " + lightSlot + " " + red + " " + green + " " + blue + " " + dirx + + " " + diry + " " + dirz); + + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateDirectionalLight++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + + // note the current state of MV MUST be used by the lights when setting position! + // https://www.opengl.org/discussion_boards/showthread.php/168706-Light-Position-in-eye-s-cordinate + + // note can't use the modelview as it's calced late + + //TODO:? possibly directional should only take the view mat, but surely I'd get a blank model?? + Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, -dirx, -diry, -dirz, 0f); + + if (joglesctx.glLightSource[lightSlot] == null) + { + joglesctx.glLightSource[lightSlot] = new glLightSource(); + joglesctx.gl_state.glLightSource[lightSlot] = null; + } + + joglesctx.glLightSource[lightSlot].diffuse.x = red; + joglesctx.glLightSource[lightSlot].diffuse.y = green; + joglesctx.glLightSource[lightSlot].diffuse.z = blue; + joglesctx.glLightSource[lightSlot].diffuse.w = 1.0f; + joglesctx.glLightSource[lightSlot].specular.x = red; + joglesctx.glLightSource[lightSlot].specular.y = green; + joglesctx.glLightSource[lightSlot].specular.z = blue; + joglesctx.glLightSource[lightSlot].specular.w = 1.0f; + joglesctx.glLightSource[lightSlot].position.x = lightPos.x; + joglesctx.glLightSource[lightSlot].position.y = lightPos.y; + joglesctx.glLightSource[lightSlot].position.z = lightPos.z; + joglesctx.glLightSource[lightSlot].position.w = 0.0f;// 0 means directional light + //joglesctx.glLightSource[lightSlot].ambient = black;// odd + // joglesctx.glLightSource[lightSlot].GL_POSITION = 1.0f; // what is this? + joglesctx.glLightSource[lightSlot].constantAttenuation = 1.0f; + joglesctx.glLightSource[lightSlot].linearAttenuation = 0.0f; + joglesctx.glLightSource[lightSlot].quadraticAttenuation = 0.0f; + joglesctx.glLightSource[lightSlot].spotExponent = 0.0f; + joglesctx.glLightSource[lightSlot].spotCutoff = 180.0f; + } + + // --------------------------------------------------------------------- + + // + // PointLightRetained methods + // + @Override + void updatePointLight(Context ctx, int lightSlot, float red, float green, float blue, float attenx, float atteny, float attenz, + float posx, float posy, float posz) + { + if (VERBOSE) + System.err.println("JoglPipeline.updatePointLight()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updatePointLight++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + + // note the current state of MV MUST be used by the lights when setting position! + // https://www.opengl.org/discussion_boards/showthread.php/168706-Light-Position-in-eye-s-cordinate + + // note can't use the modelview as it's calced late + Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, posx, posy, posz, 1.0f); + + if (joglesctx.glLightSource[lightSlot] == null) + { + joglesctx.glLightSource[lightSlot] = new glLightSource(); + joglesctx.gl_state.glLightSource[lightSlot] = null; + } + + joglesctx.glLightSource[lightSlot].diffuse.x = red; + joglesctx.glLightSource[lightSlot].diffuse.y = green; + joglesctx.glLightSource[lightSlot].diffuse.z = blue; + joglesctx.glLightSource[lightSlot].diffuse.w = 1.0f; + joglesctx.glLightSource[lightSlot].specular.x = red; + joglesctx.glLightSource[lightSlot].specular.y = green; + joglesctx.glLightSource[lightSlot].specular.z = blue; + joglesctx.glLightSource[lightSlot].specular.w = 1.0f; + joglesctx.glLightSource[lightSlot].position.x = lightPos.x; + joglesctx.glLightSource[lightSlot].position.y = lightPos.y; + joglesctx.glLightSource[lightSlot].position.z = lightPos.z; + joglesctx.glLightSource[lightSlot].position.w = 1.0f;// 1 mean pos not dir + //joglesctx.pointLight[lightSlot].ambient = black;// odd + joglesctx.glLightSource[lightSlot].constantAttenuation = attenx; + joglesctx.glLightSource[lightSlot].linearAttenuation = atteny; + joglesctx.glLightSource[lightSlot].quadraticAttenuation = attenz; + joglesctx.glLightSource[lightSlot].spotExponent = 0.0f; + joglesctx.glLightSource[lightSlot].spotCutoff = 180.0f; + } + + // --------------------------------------------------------------------- + + // + // SpotLightRetained methods + // + @Override + void updateSpotLight(Context ctx, int lightSlot, float red, float green, float blue, float attenx, float atteny, float attenz, + float posx, float posy, float posz, float spreadAngle, float concentration, float dirx, float diry, float dirz) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateSpotLight()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateSpotLight++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + + // note the current state of MV MUST be used by the lights when setting position! + //https://www.opengl.org/discussion_boards/showthread.php/168706-Light-Position-in-eye-s-cordinate + + // note can't use the modelview as it's calced late + Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, posx, posy, posz, 1.0f); + + if (joglesctx.glLightSource[lightSlot] == null) + { + joglesctx.glLightSource[lightSlot] = new glLightSource(); + joglesctx.gl_state.glLightSource[lightSlot] = null; + } + + joglesctx.glLightSource[lightSlot].diffuse.x = red; + joglesctx.glLightSource[lightSlot].diffuse.y = green; + joglesctx.glLightSource[lightSlot].diffuse.z = blue; + joglesctx.glLightSource[lightSlot].diffuse.w = 1.0f; + joglesctx.glLightSource[lightSlot].specular.x = red; + joglesctx.glLightSource[lightSlot].specular.y = green; + joglesctx.glLightSource[lightSlot].specular.z = blue; + joglesctx.glLightSource[lightSlot].specular.w = 1.0f; + joglesctx.glLightSource[lightSlot].position.x = lightPos.x; + joglesctx.glLightSource[lightSlot].position.y = lightPos.y; + joglesctx.glLightSource[lightSlot].position.z = lightPos.z; + joglesctx.glLightSource[lightSlot].position.w = 1.0f;// 1 mean pos not dir + //joglesctx.glLightSource[lightSlot].ambient = black;// odd + joglesctx.glLightSource[lightSlot].constantAttenuation = attenx; + joglesctx.glLightSource[lightSlot].linearAttenuation = atteny; + joglesctx.glLightSource[lightSlot].quadraticAttenuation = attenz; + joglesctx.glLightSource[lightSlot].spotDirection.x = dirx; + joglesctx.glLightSource[lightSlot].spotDirection.y = diry; + joglesctx.glLightSource[lightSlot].spotDirection.z = dirz; + joglesctx.glLightSource[lightSlot].spotExponent = concentration; + joglesctx.glLightSource[lightSlot].spotCutoff = (float) (spreadAngle * 180.0f / Math.PI); + + } + + // --------------------------------------------------------------------- + + // + // ExponentialFogRetained methods + // + @Override + void updateExponentialFog(Context ctx, float red, float green, float blue, float density) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateExponentialFog()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateExponentialFog++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY; + joglesctx.fogData.expColor.x = red; + joglesctx.fogData.expColor.y = green; + joglesctx.fogData.expColor.z = blue; + joglesctx.fogData.expDensity = density; + joglesctx.fogData.fogEnabled = 1; + } + + // --------------------------------------------------------------------- + + // + // LinearFogRetained methods + // + @Override + void updateLinearFog(Context ctx, float red, float green, float blue, double fdist, double bdist) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateLinearFog()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateLinearFog++; + + // see + // https://www.opengl.org/discussion_boards/showthread.php/151415-Fog-with-pixel-shader-%28arb_fragment_program%29 + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY; + joglesctx.fogData.linearColor.x = red; + joglesctx.fogData.linearColor.y = green; + joglesctx.fogData.linearColor.z = blue; + joglesctx.fogData.linearStart = (float) fdist; + joglesctx.fogData.linearEnd = (float) bdist; + joglesctx.fogData.fogEnabled = 1; + } + + // native method for disabling fog + @Override + void disableFog(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.disableFog()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.disableFog++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY; + joglesctx.fogData.fogEnabled = 0; + } + + // native method for setting fog enable flag + @Override + void setFogEnableFlag(Context ctx, boolean enable) + { + if (VERBOSE) + System.err.println("JoglPipeline.setFogEnableFlag()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setFogEnableFlag++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY; + joglesctx.fogData.fogEnabled = enable ? 1 : 0; + } + + // --------------------------------------------------------------------- + + // + // LineAttributesRetained methods + // + @Override + void updateLineAttributes(Context ctx, float lineWidth, int linePattern, int linePatternMask, int linePatternScaleFactor, + boolean lineAntialiasing) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateLineAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateLineAttributes++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glLineWidth(lineWidth); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + + // native method for setting default LineAttributes + @Override + void resetLineAttributes(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetLineAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetLineAttributes++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glLineWidth(1.0f); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // --------------------------------------------------------------------- + + // + // MaterialRetained methods + // + @Override + void updateMaterial(Context ctx, float red, float green, float blue, float alpha, float aRed, float aGreen, float aBlue, float eRed, + float eGreen, float eBlue, float dRed, float dGreen, float dBlue, float sRed, float sGreen, float sBlue, float shininess, + int colorTarget, boolean lightEnable) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateMaterial()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateMaterial++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + // will we need to repush to shaders? + if (joglesctx.objectColor.x != red || joglesctx.objectColor.y != green || joglesctx.objectColor.z != blue + || joglesctx.objectColor.w != alpha){ + joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY; + joglesctx.objectColor.x = red; + joglesctx.objectColor.y = green; + joglesctx.objectColor.z = blue; + joglesctx.objectColor.w = alpha;} + + joglesctx.materialData.lightEnabled = lightEnable ? 1 : 0; + joglesctx.materialData.shininess = shininess; + if (joglesctx.materialData.emission.x != eRed || joglesctx.materialData.emission.y != eGreen + || joglesctx.materialData.emission.z != eBlue){ + joglesctx.gl_state.glFrontMaterial.emission.x = Float.NEGATIVE_INFINITY; + joglesctx.materialData.emission.x = eRed; + joglesctx.materialData.emission.y = eGreen; + joglesctx.materialData.emission.z = eBlue;} + if (joglesctx.materialData.ambient.x != aRed || joglesctx.materialData.ambient.y != aGreen + || joglesctx.materialData.ambient.z != aBlue){ + joglesctx.gl_state.glFrontMaterial.ambient.x = Float.NEGATIVE_INFINITY; + joglesctx.materialData.ambient.x = aRed; + joglesctx.materialData.ambient.y = aGreen; + joglesctx.materialData.ambient.z = aBlue;} + if (joglesctx.materialData.specular.x != sRed || joglesctx.materialData.specular.y != sGreen + || joglesctx.materialData.specular.z != sBlue){ + joglesctx.gl_state.glFrontMaterial.specular.x = Float.NEGATIVE_INFINITY; + joglesctx.materialData.specular.x = sRed; + joglesctx.materialData.specular.y = sGreen; + joglesctx.materialData.specular.z = sBlue;} + if (joglesctx.materialData.diffuse.x != dRed || joglesctx.materialData.diffuse.y != dGreen + || joglesctx.materialData.diffuse.z != dBlue || joglesctx.materialData.diffuse.w != alpha){ + joglesctx.gl_state.glFrontMaterial.diffuse.x = Float.NEGATIVE_INFINITY; + joglesctx.materialData.diffuse.x = dRed; + joglesctx.materialData.diffuse.y = dGreen; + joglesctx.materialData.diffuse.z = dBlue; + joglesctx.materialData.diffuse.w = alpha;} + } + + // native method for setting Material when no material is present + @Override + void updateMaterialColor(Context ctx, float r, float g, float b, float a) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateMaterialColor()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateMaterialColor++; + + // update single color in case where material has color and there are no coloring attributes + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + if (joglesctx.objectColor.x != r || joglesctx.objectColor.y != g || joglesctx.objectColor.z != b || joglesctx.objectColor.w != a) + joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY; + joglesctx.objectColor.x = r; + joglesctx.objectColor.y = g; + joglesctx.objectColor.z = b; + joglesctx.objectColor.w = a; + + } + // --------------------------------------------------------------------- + + // + // ColoringAttributesRetained methods + @Override + void updateColoringAttributes(Context ctx, float dRed, float dGreen, float dBlue, float red, float green, float blue, float alpha, + boolean lightEnable, int shadeModel) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateColoringAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateColoringAttributes++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + // note we ignore lightEnabled and always pass the object color to the shader if it wants it + if (joglesctx.objectColor.x != red || joglesctx.objectColor.y != green || joglesctx.objectColor.z != blue + || joglesctx.objectColor.w != alpha) + joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY; + joglesctx.objectColor.x = red; + joglesctx.objectColor.y = green; + joglesctx.objectColor.z = blue; + joglesctx.objectColor.w = alpha; + + //TODO: why is enable light ignored? + + } + + // native method for setting default ColoringAttributes + @Override + void resetColoringAttributes(Context ctx, float r, float g, float b, float a, boolean enableLight) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetColoringAttributes() " + r + " " + g + " " + b + " " + a + " " + enableLight); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetColoringAttributes++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + if (joglesctx.objectColor.x != r || joglesctx.objectColor.y != g || joglesctx.objectColor.z != b || joglesctx.objectColor.w != a) + joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY; + joglesctx.objectColor.x = r; + joglesctx.objectColor.y = g; + joglesctx.objectColor.z = b; + joglesctx.objectColor.w = a; + + //TODO: why is enable light ignored? + } + + // --------------------------------------------------------------------- + + // + // PointAttributesRetained methods + // + // interesting as Points are how particles are done properly!! + // http://stackoverflow.com/questions/3497068/textured-points-in-opengl-es-2-0 + // http://stackoverflow.com/questions/7237086/opengl-es-2-0-equivalent-for-es-1-0-circles-using-gl-point-smooth + @Override + void updatePointAttributes(Context ctx, float pointSize, boolean pointAntialiasing) + { + if (VERBOSE) + System.err.println("JoglPipeline.updatePointAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updatePointAttributes++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + joglesctx.pointSize = pointSize; + + // one time enable call + if (!pointsEnabled) + { + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + // bug in desktop requiring this to be set still + gl.glEnable(0x8642);// GL_VERTEX_PROGRAM_POINT_SIZE + gl.glEnable(34913);// GL.GL_POINT_SPRITE); + pointsEnabled = true; + } + } + + private boolean pointsEnabled = false; + + // native method for setting default PointAttributes + @Override + void resetPointAttributes(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetPointAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetPointAttributes++; + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + joglesctx.pointSize = 1.0f; + } + + // --------------------------------------------------------------------- + + // + // PolygonAttributesRetained methods + // + @Override + void updatePolygonAttributes(Context ctx, int polygonMode, int cullFace, boolean backFaceNormalFlip, float polygonOffset, + float polygonOffsetFactor) + { + if (VERBOSE) + System.err.println("JoglPipeline.updatePolygonAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updatePolygonAttributes++; + + GL2ES2 gl = null;// get only if needed, expensive call + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + if (joglesctx.gl_state.cullFace != cullFace) + { + gl = ((Jogl2es2Context) ctx).gl2es2(); + if (cullFace == PolygonAttributes.CULL_NONE) + { + gl.glDisable(GL2ES2.GL_CULL_FACE); + } + else + { + if (cullFace == PolygonAttributes.CULL_BACK) + { + gl.glCullFace(GL2ES2.GL_BACK); + } + else + { + gl.glCullFace(GL2ES2.GL_FRONT); + } + gl.glEnable(GL2ES2.GL_CULL_FACE); + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.cullFace = cullFace; + } + + if (joglesctx.gl_state.polygonOffsetFactor != polygonOffsetFactor || joglesctx.gl_state.polygonOffset != polygonOffset) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glPolygonOffset(polygonOffsetFactor, polygonOffset); + + if ((polygonOffsetFactor != 0.0f) || (polygonOffset != 0.0f)) + { + gl.glEnable(GL2ES2.GL_POLYGON_OFFSET_FILL); + } + else + { + gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL); + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + { + joglesctx.gl_state.polygonOffsetFactor = polygonOffsetFactor; + joglesctx.gl_state.polygonOffset = polygonOffset; + } + } + joglesctx.polygonMode = polygonMode; + } + + // native method for setting default PolygonAttributes + @Override + void resetPolygonAttributes(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetPolygonAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetPolygonAttributes++; + + GL2ES2 gl = null;// get only if needed, expensive call + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + if (joglesctx.gl_state.cullFace != PolygonAttributes.CULL_BACK) + { + gl = ((Jogl2es2Context) ctx).gl2es2(); + gl.glCullFace(GL2ES2.GL_BACK); + gl.glEnable(GL2ES2.GL_CULL_FACE); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.cullFace = PolygonAttributes.CULL_BACK; + } + + if (joglesctx.gl_state.polygonOffsetFactor != 0.0f || joglesctx.gl_state.polygonOffset != 0.0f) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glPolygonOffset(0.0f, 0.0f); + gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + { + joglesctx.gl_state.polygonOffsetFactor = 0.0f; + joglesctx.gl_state.polygonOffset = 0.0f; + } + } + + joglesctx.polygonMode = PolygonAttributes.POLYGON_FILL; + } + + // --------------------------------------------------------------------- + + // + // RenderingAttributesRetained methods + // + @Override + void updateRenderingAttributes(Context ctx, boolean depthBufferWriteEnableOverride, boolean depthBufferEnableOverride, + boolean depthBufferEnable, boolean depthBufferWriteEnable, int depthTestFunction, float alphaTestValue, int alphaTestFunction, + boolean ignoreVertexColors, boolean rasterOpEnable, int rasterOp, boolean userStencilAvailable, boolean stencilEnable, + int stencilFailOp, int stencilZFailOp, int stencilZPassOp, int stencilFunction, int stencilReferenceValue, + int stencilCompareMask, int stencilWriteMask) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateRenderingAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateRenderingAttributes++; + + GL2ES2 gl = null;// get late expensive + + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + if (joglesctx.gl_state.depthBufferEnableOverride != depthBufferEnable || joglesctx.gl_state.depthBufferEnable != depthBufferEnable + || joglesctx.gl_state.depthTestFunction != depthTestFunction) + { + if (!depthBufferEnableOverride) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + if (depthBufferEnable) + { + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glDepthFunc(getFunctionValue(depthTestFunction)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + gl.glDisable(GL2ES2.GL_DEPTH_TEST); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + } + + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.depthBufferEnableOverride = depthBufferEnable; + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.depthBufferEnable = depthBufferEnable; + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.depthTestFunction = depthTestFunction; + } + + if (!depthBufferWriteEnableOverride) + { + if (depthBufferWriteEnable) + { + if (joglesctx.gl_state.glDepthMask != true) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDepthMask(true); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.glDepthMask = true; + } + } + else + { + if (joglesctx.gl_state.glDepthMask != false) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDepthMask(false); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.glDepthMask = true; + } + } + } + + if (alphaTestFunction == RenderingAttributes.ALWAYS) + { + joglesctx.renderingData.alphaTestEnabled = false; + } + else + { + joglesctx.renderingData.alphaTestEnabled = true; + joglesctx.renderingData.alphaTestFunction = getFunctionValue(alphaTestFunction); + joglesctx.renderingData.alphaTestValue = alphaTestValue; + } + + joglesctx.renderingData.ignoreVertexColors = ignoreVertexColors ? 1 : 0; + + if (rasterOpEnable) + { + System.err.println("rasterOpEnable!!!! no no no!"); + } + + if (userStencilAvailable) + { + if (stencilEnable) + { + if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == false || joglesctx.gl_state.stencilFailOp != stencilFailOp + || joglesctx.gl_state.stencilZFailOp != stencilZFailOp || joglesctx.gl_state.stencilZPassOp != stencilZPassOp + || joglesctx.gl_state.stencilFunction != stencilFunction + || joglesctx.gl_state.stencilReferenceValue != stencilReferenceValue + || joglesctx.gl_state.stencilCompareMask != stencilCompareMask + || joglesctx.gl_state.stencilWriteMask != stencilWriteMask) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glEnable(GL2ES2.GL_STENCIL_TEST); + gl.glStencilOp(getStencilOpValue(stencilFailOp), getStencilOpValue(stencilZFailOp), getStencilOpValue(stencilZPassOp)); + gl.glStencilFunc(getFunctionValue(stencilFunction), stencilReferenceValue, stencilCompareMask); + gl.glStencilMask(stencilWriteMask); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.glEnableGL_STENCIL_TEST = true; + } + } + else + { + if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == true) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDisable(GL2ES2.GL_STENCIL_TEST); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.glEnableGL_STENCIL_TEST = false; + } + } + } + + } + + // native method for setting default RenderingAttributes + @Override + void resetRenderingAttributes(Context ctx, boolean depthBufferWriteEnableOverride, boolean depthBufferEnableOverride) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetRenderingAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetRenderingAttributes++; + + GL2ES2 gl = null; // get late expensive + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + if (!depthBufferWriteEnableOverride) + { + if (joglesctx.gl_state.glDepthMask != true) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDepthMask(true); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.glDepthMask = true; + } + } + if (!depthBufferEnableOverride) + { + if (joglesctx.gl_state.depthBufferEnable != true) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.depthBufferEnable = true; + } + } + if (joglesctx.gl_state.depthTestFunction != RenderingAttributes.LESS_OR_EQUAL) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDepthFunc(GL2ES2.GL_LEQUAL); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.depthTestFunction = RenderingAttributes.LESS_OR_EQUAL; + } + + joglesctx.renderingData.alphaTestEnabled = false; + joglesctx.renderingData.alphaTestFunction = RenderingAttributes.ALWAYS; + joglesctx.renderingData.alphaTestValue = 0; + joglesctx.renderingData.ignoreVertexColors = 0; + + if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == true) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDisable(GL2ES2.GL_STENCIL_TEST); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_OTHER) + joglesctx.gl_state.glEnableGL_STENCIL_TEST = false; + } + + } + + @Override + void updateTransparencyAttributes(Context ctx, float alpha, int geometryType, int polygonMode, boolean lineAA, boolean pointAA, + int transparencyMode, int srcBlendFunction, int dstBlendFunction) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTransparencyAttributes() " + alpha + " " + geometryType + " " + polygonMode + " " + + lineAA + " " + pointAA + " " + transparencyMode + " " + srcBlendFunction + " " + dstBlendFunction); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateTransparencyAttributes++; + + GL2ES2 gl = null;//get late expensive + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + + joglesctx.transparencyAlpha = alpha; + + if ((transparencyMode < TransparencyAttributes.SCREEN_DOOR) + || ((((geometryType & RenderMolecule.LINE) != 0) || (polygonMode == PolygonAttributes.POLYGON_LINE)) && lineAA) + || ((((geometryType & RenderMolecule.POINT) != 0) || (polygonMode == PolygonAttributes.POLYGON_POINT)) && pointAA)) + { + if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != true + || joglesctx.gl_state.srcBlendFunction != srcBlendFunction || joglesctx.gl_state.dstBlendFunction != dstBlendFunction)) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glEnable(GL2ES2.GL_BLEND); + // valid range of blendFunction 0..3 is already verified in shared code. + gl.glBlendFunc(blendFunctionTable[srcBlendFunction], blendFunctionTable[dstBlendFunction]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) + { + joglesctx.gl_state.glEnableGL_BLEND = true; + joglesctx.gl_state.srcBlendFunction = srcBlendFunction; + joglesctx.gl_state.dstBlendFunction = dstBlendFunction; + } + } + + } + else + { + if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != false)) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDisable(GL2ES2.GL_BLEND); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) + joglesctx.gl_state.glEnableGL_BLEND = false; + } + } + + } + + // native method for setting default TransparencyAttributes + @Override + void resetTransparency(Context ctx, int geometryType, int polygonMode, boolean lineAA, boolean pointAA) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetTransparency()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetTransparency++; + + GL2ES2 gl = null; //get late expensive + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + + joglesctx.transparencyAlpha = 1.0f; + + if (((((geometryType & RenderMolecule.LINE) != 0) || (polygonMode == PolygonAttributes.POLYGON_LINE)) && lineAA) + || ((((geometryType & RenderMolecule.POINT) != 0) || (polygonMode == PolygonAttributes.POLYGON_POINT)) && pointAA)) + { + if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != true + || joglesctx.gl_state.srcBlendFunction != TransparencyAttributes.BLEND_SRC_ALPHA + || joglesctx.gl_state.dstBlendFunction != TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA)) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glEnable(GL2ES2.GL_BLEND); + gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) + { + joglesctx.gl_state.glEnableGL_BLEND = true; + joglesctx.gl_state.srcBlendFunction = TransparencyAttributes.BLEND_SRC_ALPHA; + joglesctx.gl_state.dstBlendFunction = TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA; + } + } + } + else + { + if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != false)) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glDisable(GL2ES2.GL_BLEND); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) + joglesctx.gl_state.glEnableGL_BLEND = false; + } + } + } + + // + // TextureAttributesRetained methods + // + @Override + void updateTextureAttributes(Context ctx, double[] transform, boolean isIdentity, int textureMode, int perspCorrectionMode, + float textureBlendColorRed, float textureBlendColorGreen, float textureBlendColorBlue, float textureBlendColorAlpha, + int textureFormat) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTextureAttributes() " + lineString(transform)); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateTextureAttributes++; + + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + joglesctx.gl_state.textureTransform.m00 = Double.NEGATIVE_INFINITY; + joglesctx.textureTransform.set(transform); + } + + // native method for setting default TextureAttributes + @Override + void resetTextureAttributes(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetTextureAttributes()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetTextureAttributes++; + + // set Identity + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + joglesctx.gl_state.textureTransform.m00 = Double.NEGATIVE_INFINITY; + joglesctx.textureTransform.setIdentity(); + + } + + // --------------------------------------------------------------------- + + // native method for setting default TexCoordGeneration -Noop + @Override + void resetTexCoordGeneration(Context ctx) + { + // TexCoordGeneration must be done in shaders + // if (VERBOSE) + // System.err.println("JoglPipeline.resetTexCoordGeneration()"); + // if (OUTPUT_PER_FRAME_STATS) + // ((JoglesContext) ctx).perFrameStats.resetTexCoordGeneration++; + } + + // --------------------------------------------------------------------- + + // + // TextureUnitStateRetained methods + // + @Override + void updateTextureUnitState(Context ctx, int index, boolean enable) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTextureUnitState(index=" + index + ",enable=" + enable + ")"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.updateTextureUnitState++; + + Jogl2es2Context joglesContext = (Jogl2es2Context) ctx; + GL2ES2 gl = null;//get late expensive + + if (index >= 0) + { + if (!MINIMISE_NATIVE_CALLS_TEXTURE || (joglesContext.gl_state.glActiveTexture != (index + GL2ES2.GL_TEXTURE0))) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glActiveTexture(index + GL2ES2.GL_TEXTURE0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_TEXTURE) + joglesContext.gl_state.glActiveTexture = (index + GL2ES2.GL_TEXTURE0); + } + } + } + + // --------------------------------------------------------------------- + + // + // TextureRetained methods + // Texture2DRetained methods + // + @Override + void bindTexture2D(Context ctx, int objectId, boolean enable) + { + if (VERBOSE) + System.err.println("JoglPipeline.bindTexture2D(objectId=" + objectId + ",enable=" + enable + ")"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.bindTexture2D++; + + Jogl2es2Context joglesContext = (Jogl2es2Context) ctx; + GL2ES2 gl = null;// get late expensive + + if (enable) + { + if (!MINIMISE_NATIVE_CALLS_TEXTURE + || (joglesContext.gl_state.glBindTextureGL_TEXTURE_2D[joglesContext.gl_state.glActiveTexture] != objectId)) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glBindTexture(GL2ES2.GL_TEXTURE_2D, objectId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_TEXTURE) + joglesContext.gl_state.glBindTextureGL_TEXTURE_2D[joglesContext.gl_state.glActiveTexture] = objectId; + } + } + } + + @Override + void updateTexture2DImage(Context ctx, int numLevels, int level, int textureFormat, int imageFormat, int width, int height, + int boundaryWidth, int dataType, Object data, boolean useAutoMipMap) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTexture2DImage(width=" + width + ",height=" + height + ",level=" + level + ")"); + + updateTexture2DImage(ctx, GL2ES2.GL_TEXTURE_2D, numLevels, level, textureFormat, imageFormat, width, height, boundaryWidth, + dataType, data, useAutoMipMap); + } + + // oddly in use when I press escape twice??? + @Override + void updateTexture2DSubImage(Context ctx, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, int imgXOffset, + int imgYOffset, int tilew, int width, int height, int dataType, Object data, boolean useAutoMipMap) + { + + // Note: useAutoMipMap is not use for SubImage in the jogl pipe + + if (VERBOSE) + System.err.println("JoglPipeline.updateTexture2DSubImage()"); + + updateTexture2DSubImage(ctx, GL2ES2.GL_TEXTURE_2D, level, xoffset, yoffset, textureFormat, imageFormat, imgXOffset, imgYOffset, + tilew, width, height, dataType, data); + } + + @Override + void updateTexture2DLodRange(Context ctx, int baseLevel, int maximumLevel, float minimumLOD, float maximumLOD) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTexture2DLodRange()"); + + updateTextureLodRange(ctx, GL2ES2.GL_TEXTURE_2D, baseLevel, maximumLevel, minimumLOD, maximumLOD); + } + + @Override + void updateTexture2DBoundary(Context ctx, int boundaryModeS, int boundaryModeT, float boundaryRed, float boundaryGreen, + float boundaryBlue, float boundaryAlpha) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTexture2DBoundary()"); + + updateTextureBoundary(ctx, GL2ES2.GL_TEXTURE_2D, boundaryModeS, boundaryModeT, -1, boundaryRed, boundaryGreen, boundaryBlue, + boundaryAlpha); + } + + @Override + void updateTexture2DFilterModes(Context ctx, int minFilter, int magFilter) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTexture2DFilterModes()"); + + updateTextureFilterModes(ctx, GL2ES2.GL_TEXTURE_2D, minFilter, magFilter); + } + + @Override + void updateTexture2DAnisotropicFilter(Context ctx, float degree) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTexture2DAnisotropicFilter()"); + + updateTextureAnisotropicFilter(ctx, GL2ES2.GL_TEXTURE_2D, degree); + } + + private static void updateTextureLodRange(Context ctx, int target, int baseLevel, int maximumLevel, float minimumLOD, float maximumLOD) + { + //GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + // I notice these 4 parameters don't appear under GL2ES2 + + // target is good, pname can't have any of the 4 given, though I wonder if this is an extension somehow? + // confirmed here http://stackoverflow.com/questions/34499219/correct-way-to-unbind-an-open-gl-es-texture + + // target Specifies the target texture of the active texture unit, + // which must be either GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. + // pname Specifies the symbolic name of a single-valued texture/ parameter. + // pname can be one of the following: GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, + // GL_TEXTURE_WRAP_S, or GL_TEXTURE_WRAP_T. + + // checking of the availability of the extension is already done + // in the shared code + // Apparently these are available in ES3 + + // gl.glTexParameteri(target, GL2ES3.GL_TEXTURE_BASE_LEVEL, baseLevel); + + // http://stackoverflow.com/questions/12767917/is-using-gl-nearest-mipmap-or-gl-linear-mipmap-for-gl-texture-min-filter-con + // ES2 throws a 1280 invalid enum here + + //if (gl.isGL2ES3()) + // gl.glTexParameteri(target, GL2ES3.GL_TEXTURE_MAX_LEVEL, maximumLevel); + // gl.glTexParameterf(target, GL2ES3.GL_TEXTURE_MIN_LOD, minimumLOD); + // gl.glTexParameterf(target, GL2ES3.GL_TEXTURE_MAX_LOD, maximumLOD); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + private static void updateTextureAnisotropicFilter(Context ctx, int target, float degree) + { + // FIXME: is this a true thing to send in? + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + // it appears GL_TEXTURE_MAX_ANISOTROPY_EXT is still part of ES2 + // but not allowed for glTexParameterf + // here http://www.informit.com/articles/article.aspx?p=770639&seqNum=2 suggest the + // parameter may still be passed if the EXT is enabled + + // checking of the availability of anisotropic filter functionality + // is already done in the shared code + gl.glTexParameterf(target, GL2ES2.GL_TEXTURE_MAX_ANISOTROPY_EXT, degree); + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // --------------------------------------------------------------------- + + // + // TextureCubeMapRetained methods + // + @Override + void bindTextureCubeMap(Context ctx, int objectId, boolean enable) + { + if (VERBOSE) + System.err.println("JoglPipeline.bindTextureCubeMap()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.bindTextureCubeMap++; + + GL2ES2 gl = null;// get late expensive + + // TextureCubeMap will take precedents over 3D Texture so + // there is no need to disable 3D Texture here. + if (!enable) + { + // gl.glDisable(GL2ES2.GL_TEXTURE_CUBE_MAP); + } + else + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glBindTexture(GL2ES2.GL_TEXTURE_CUBE_MAP, objectId); + // gl.glEnable(GL2ES2.GL_TEXTURE_CUBE_MAP); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + } + + @Override + void updateTextureCubeMapImage(Context ctx, int face, int numLevels, int level, int textureFormat, int imageFormat, int width, + int height, int boundaryWidth, int dataType, Object data, boolean useAutoMipMap) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTextureCubeMapImage()"); + + updateTexture2DImage(ctx, _gl_textureCubeMapFace[face], numLevels, level, textureFormat, imageFormat, width, height, boundaryWidth, + dataType, data, useAutoMipMap); + } + + @Override + void updateTextureCubeMapSubImage(Context ctx, int face, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, + int imgXOffset, int imgYOffset, int tilew, int width, int height, int dataType, Object data, boolean useAutoMipMap) + { + // PJ why is this the case? + throw new UnsupportedOperationException(); + } + + @Override + void updateTextureCubeMapLodRange(Context ctx, int baseLevel, int maximumLevel, float minimumLod, float maximumLod) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTextureCubeMapLodRange()"); + + updateTextureLodRange(ctx, GL2ES2.GL_TEXTURE_CUBE_MAP, baseLevel, maximumLevel, minimumLod, maximumLod); + } + + @Override + void updateTextureCubeMapBoundary(Context ctx, int boundaryModeS, int boundaryModeT, float boundaryRed, float boundaryGreen, + float boundaryBlue, float boundaryAlpha) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTextureCubeMapBoundary()"); + + updateTextureBoundary(ctx, GL2ES2.GL_TEXTURE_CUBE_MAP, boundaryModeS, boundaryModeT, -1, boundaryRed, boundaryGreen, boundaryBlue, + boundaryAlpha); + } + + @Override + void updateTextureCubeMapFilterModes(Context ctx, int minFilter, int magFilter) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTextureCubeMapFilterModes()"); + + updateTextureFilterModes(ctx, GL2ES2.GL_TEXTURE_CUBE_MAP, minFilter, magFilter); + } + + @Override + void updateTextureCubeMapAnisotropicFilter(Context ctx, float degree) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateTextureCubeMapAnisotropicFilter()"); + + updateTextureAnisotropicFilter(ctx, GL2ES2.GL_TEXTURE_CUBE_MAP, degree); + } + + // ---------------------------------------------------------------------- + // + // Helper routines for above texture methods + // + + private void updateTexture2DImage(Context ctx, int target, int numLevels, int level, int textureFormat, int imageFormat, int width, + int height, int boundaryWidth, int dataType, Object data, boolean useAutoMipMap) + { + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + // FIXME: there is a new call glGenerateMipmap() which is only in ES2 not GL2 so on pure ES2 + // add back in checking for mipmap support under properties, then add that call after bind texture + // which mean the gl.glTexParameteri(target, GL2ES2.GL_GENERATE_MIPMAP, GL2ES2.GL_TRUE); are gone + //the extensions need to have an ES2 version + // the glPixelTransferf alpha madness which I don't understand can be deleted along with the texture formats + // the other look like they are ok, though the supported compressed will be different + + /* from ES2 spec + format + Specifies the format of the pixel data. + The following symbolic values are accepted: + GL_ALPHA, + GL_RGB, + GL_RGBA, + GL_LUMINANCE, and + GL_LUMINANCE_ALPHA. + type + Specifies the data type of the pixel data. + The following symbolic values are accepted: + GL_UNSIGNED_BYTE, + GL_UNSIGNED_SHORT_5_6_5, + GL_UNSIGNED_SHORT_4_4_4_4, and + GL_UNSIGNED_SHORT_5_5_5_1.*/ + + int internalFormat = 0; + + switch (textureFormat) + { + case Texture.INTENSITY: + new Throwable("Texture.INTENSITY not supported").printStackTrace(); + // internalFormat = GL2.GL_INTENSITY; + break; + case Texture.LUMINANCE: + internalFormat = GL2ES2.GL_LUMINANCE; + break; + case Texture.ALPHA: + internalFormat = GL2ES2.GL_ALPHA; + break; + case Texture.LUMINANCE_ALPHA: + internalFormat = GL2ES2.GL_LUMINANCE_ALPHA; + break; + case Texture.RGB: + internalFormat = GL2ES2.GL_RGB; + break; + case Texture.RGBA: + internalFormat = GL2ES2.GL_RGBA; + break; + default: + assert false; + } + + boolean createMipMaps = useAutoMipMap; + + int format = 0; + + if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) + || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) + { + + switch (imageFormat) + { + case ImageComponentRetained.TYPE_BYTE_BGR: + format = GL2ES2.GL_BGR; + break; + case ImageComponentRetained.TYPE_BYTE_RGB: + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_BYTE_ABGR: + if (isExtensionAvailable.GL_EXT_abgr(gl)) + { + // If its zero, should never come here! + format = GL2.GL_ABGR_EXT; + } + else + { + assert false; + return; + } + break; + case ImageComponentRetained.TYPE_BYTE_RGBA: + // all RGB types are stored as RGBA + format = GL2ES2.GL_RGBA; + break; + case ImageComponentRetained.TYPE_BYTE_LA: + // all LA types are stored as LA8 + format = GL2ES2.GL_LUMINANCE_ALPHA; + break; + case ImageComponentRetained.TYPE_BYTE_GRAY: + if (internalFormat == GL2ES2.GL_ALPHA) + { + format = GL2ES2.GL_ALPHA; + } + else + { + format = GL2ES2.GL_LUMINANCE; + } + break; + /////////////////////////////////////////////////// PJPJPJ//////////////////// + // DXT uncompressed D3DFMT_A8R8G8B8 indicator + case GL2.GL_RGBA_S3TC: + internalFormat = GL2ES2.GL_RGBA; + format = GL2ES2.GL_RGBA; + break; + // notice fall through + // DXT + case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL2.GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + // ETC2 + // https://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml + case GL3.GL_COMPRESSED_RGBA8_ETC2_EAC: + case GL3.GL_COMPRESSED_RGB8_ETC2: + case GL3.GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + case GL3.GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + case GL3.GL_COMPRESSED_SRGB8_ETC2: + case GL3.GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + // ASTC + case GL3.GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + case GL3.GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + internalFormat = imageFormat; + format = -1;// indicate compressed + break; + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_INT_BGR: + case ImageComponentRetained.TYPE_INT_RGB: + case ImageComponentRetained.TYPE_INT_ARGB: + default: + assert false; + return; + } + + if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) + { + gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE, + ByteBuffer.wrap((byte[]) data)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + if (format == -1) + { + + ByteBuffer bb = (ByteBuffer) data; + + gl.glCompressedTexImage2D(target, level, internalFormat, width, height, boundaryWidth, bb.limit(), bb); + + if (DO_OUTPUT_ERRORS) + { + int err = gl.glGetError(); + if (err != GL2ES2.GL_NO_ERROR) + { + System.out.println("glCompressedTexImage2D Error " + err + " target " + target + " level " + level + + " internalFormat " + internalFormat); + System.out.println("width " + width + " height " + height + " boundaryWidth " + boundaryWidth + " bb.limit() " + + bb.limit()); + // https://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml + } + } + } + else + { + gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE, + (Buffer) data); + if (DO_OUTPUT_ERRORS) + { + int err = gl.glGetError(); + if (err != GL2ES2.GL_NO_ERROR) + { + System.out.println("glTexImage2D Error " + err + " target " + target + " level " + level + " internalFormat " + + internalFormat); + System.out.println("width " + width + " height " + height + " boundaryWidth " + boundaryWidth + " format " + + format + " bb.limit() " + ((Buffer) data).limit()); + // https://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml + } + } + } + } + } + else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) + || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) + { + switch (imageFormat) + { + case ImageComponentRetained.TYPE_INT_BGR: + //PJ does this work correctly? + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_RGB: + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_ARGB: + format = GL2ES2.GL_RGBA; + break; + // This method only supports 3 and 4 components formats and INT types. + case ImageComponentRetained.TYPE_BYTE_LA: + case ImageComponentRetained.TYPE_BYTE_GRAY: + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_BYTE_BGR: + case ImageComponentRetained.TYPE_BYTE_RGB: + case ImageComponentRetained.TYPE_BYTE_RGBA: + case ImageComponentRetained.TYPE_BYTE_ABGR: + default: + assert false; + return; + } + + if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) + { + gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE, + IntBuffer.wrap((int[]) data)); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE, + (Buffer) data); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + } + else + { + assert false; + } + + if(createMipMaps && level == 0) + { + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR_MIPMAP_LINEAR); + gl.glHint(GL.GL_GENERATE_MIPMAP_HINT, GL.GL_NICEST); + gl.glGenerateMipmap(target); + // as a new feature that happens seldom, output errors + outputErrors(ctx); + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + private void updateTexture2DSubImage(Context ctx, int target, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, + int imgXOffset, int imgYOffset, int tilew, int width, int height, int dataType, Object data) + { + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + if (imgXOffset > 0 || (width < tilew)) + { + // PJ not sure what should be happening here + // new Throwable("(imgXOffset > 0 || (width < tilew))").printStackTrace(); + } + + int internalFormat = 0; + + switch (textureFormat) + { + case Texture.INTENSITY: + // internalFormat = GL2.GL_INTENSITY; + new Throwable("Texture.INTENSITY not supported").printStackTrace(); + break; + case Texture.LUMINANCE: + internalFormat = GL2ES2.GL_LUMINANCE; + break; + case Texture.ALPHA: + internalFormat = GL2ES2.GL_ALPHA; + break; + case Texture.LUMINANCE_ALPHA: + internalFormat = GL2ES2.GL_LUMINANCE_ALPHA; + break; + case Texture.RGB: + internalFormat = GL2ES2.GL_RGB; + break; + case Texture.RGBA: + internalFormat = GL2ES2.GL_RGBA; + break; + default: + assert false; + } + + if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) + || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) + { + int format = 0; + int numBytes = 0; + + switch (imageFormat) + { + case ImageComponentRetained.TYPE_BYTE_BGR: + format = GL2ES2.GL_BGR; + numBytes = 3; + break; + case ImageComponentRetained.TYPE_BYTE_RGB: + format = GL2ES2.GL_RGB; + numBytes = 3; + break; + case ImageComponentRetained.TYPE_BYTE_ABGR: + if (isExtensionAvailable.GL_EXT_abgr(gl)) + { + // If its zero, should never come here! + format = GL2.GL_ABGR_EXT; + numBytes = 4; + } + else + { + assert false; + return; + } + break; + case ImageComponentRetained.TYPE_BYTE_RGBA: + // all RGB types are stored as RGBA + format = GL2ES2.GL_RGBA; + numBytes = 4; + break; + case ImageComponentRetained.TYPE_BYTE_LA: + // all LA types are stored as LA8 + format = GL2ES2.GL_LUMINANCE_ALPHA; + numBytes = 2; + break; + case ImageComponentRetained.TYPE_BYTE_GRAY: + if (internalFormat == GL2ES2.GL_ALPHA) + { + format = GL2ES2.GL_ALPHA; + numBytes = 1; + } + else + { + format = GL2ES2.GL_LUMINANCE; + numBytes = 1; + } + break; + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_INT_BGR: + case ImageComponentRetained.TYPE_INT_RGB: + case ImageComponentRetained.TYPE_INT_ARGB: + default: + assert false; + return; + } + + ByteBuffer buf = null; + if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) + { + buf = ByteBuffer.wrap((byte[]) data); + } + else + { + buf = (ByteBuffer) data; + } + + // offset by the imageOffset + buf.position((tilew * imgYOffset + imgXOffset) * numBytes); + gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, buf); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) + || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) + { + int format = 0; + switch (imageFormat) + { + case ImageComponentRetained.TYPE_INT_BGR: + //PJ does this work correctly? + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_RGB: + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_ARGB: + format = GL2ES2.GL_RGBA; + break; + // This method only supports 3 and 4 components formats and INT types. + case ImageComponentRetained.TYPE_BYTE_LA: + case ImageComponentRetained.TYPE_BYTE_GRAY: + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_BYTE_BGR: + case ImageComponentRetained.TYPE_BYTE_RGB: + case ImageComponentRetained.TYPE_BYTE_RGBA: + case ImageComponentRetained.TYPE_BYTE_ABGR: + default: + assert false; + return; + } + + IntBuffer buf = null; + if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) + { + buf = IntBuffer.wrap((int[]) data); + } + else + { + buf = (IntBuffer) data; + } + + // offset by the imageOffset + buf.position(tilew * imgYOffset + imgXOffset); + gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, buf); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + assert false; + return; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + } + + private static void updateTextureFilterModes(Context ctx, int target, int minFilter, int magFilter) + { + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + // FIXME: unclear whether we really need to set up the enum values + // in the JoglContext as is done in the native code depending on + // extension availability; maybe this is the defined fallback + // behavior of the various Java3D modes + + // set texture min filter + switch (minFilter) + { + case Texture.FASTEST: + case Texture.BASE_LEVEL_POINT: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_NEAREST); + break; + case Texture.BASE_LEVEL_LINEAR: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR); + break; + case Texture.MULTI_LEVEL_POINT: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_NEAREST_MIPMAP_NEAREST); + break; + case Texture.NICEST: + case Texture.MULTI_LEVEL_LINEAR: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR_MIPMAP_LINEAR); + break; + case Texture.FILTER4: + // We should never get here as we've disabled the FILTER4 feature + // gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, + // GL2ES2.GL_FILTER4_SGIS); + break; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + // set texture mag filter + switch (magFilter) + { + case Texture.FASTEST: + case Texture.BASE_LEVEL_POINT: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MAG_FILTER, GL2ES2.GL_NEAREST); + break; + case Texture.NICEST: + case Texture.BASE_LEVEL_LINEAR: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MAG_FILTER, GL2ES2.GL_LINEAR); + break; + case Texture.LINEAR_SHARPEN: + case Texture.LINEAR_SHARPEN_RGB: + case Texture.LINEAR_SHARPEN_ALPHA: + case Texture2D.LINEAR_DETAIL: + case Texture2D.LINEAR_DETAIL_RGB: + case Texture2D.LINEAR_DETAIL_ALPHA: + case Texture.FILTER4: + default: + assert false; + return; + } + + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + void updateTextureBoundary(Context ctx, int target, int boundaryModeS, int boundaryModeT, int boundaryModeR, float boundaryRed, + float boundaryGreen, float boundaryBlue, float boundaryAlpha) + { + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + // except the R gear at bottom and boundary color + // but I'm dropping 3dtexture support so no probs and who cares about boundary color + // CLAMP_TO_BOUNDARYand GL_CLAMP are gone so now just set as GL_CLAMP_TO_EDGE + // FIXME: GL_MIRRORED_REPEAT needs to be added + + // set texture wrap parameter + switch (boundaryModeS) + { + case Texture.WRAP: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_REPEAT); + break; + case Texture.CLAMP: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE); + break; + case Texture.CLAMP_TO_EDGE: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE); + break; + case Texture.CLAMP_TO_BOUNDARY: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE); + break; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + switch (boundaryModeT) + { + case Texture.WRAP: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_REPEAT); + break; + case Texture.CLAMP: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE); + break; + case Texture.CLAMP_TO_EDGE: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE); + break; + case Texture.CLAMP_TO_BOUNDARY: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE); + break; + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + // applies to Texture3D only + /* if (boundaryModeR != -1) + { + switch (boundaryModeR) + { + case Texture.WRAP: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_R, GL2ES2.GL_REPEAT); + break; + + case Texture.CLAMP: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_R, GL2ES2.GL_CLAMP); + break; + case Texture.CLAMP_TO_EDGE: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_R, GL2ES2.GL_CLAMP_TO_EDGE); + break; + case Texture.CLAMP_TO_BOUNDARY: + gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_R, GL2ES2.GL_CLAMP_TO_BORDER); + break; + } + }*/ + + //http://stackoverflow.com/questions/913801/glteximage2d + // texture border no longer supported on ES2 + + /*if (boundaryModeS == Texture.CLAMP || boundaryModeT == Texture.CLAMP || boundaryModeR == Texture.CLAMP) + { + // set texture border color + float[] color = new float[4]; + color[0] = boundaryRed; + color[1] = boundaryGreen; + color[2] = boundaryBlue; + color[3] = boundaryAlpha; + gl.glTexParameterfv(target, GL2ES2.GL_TEXTURE_BORDER_COLOR, color, 0); + }*/ + + } + + // mapping from java enum to gl enum + private static final int[] _gl_textureCubeMapFace = { GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, + GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_Z, + GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, }; + + // The following three methods are used in multi-pass case + + // native method for setting blend color + @Override + void setBlendColor(Context ctx, float red, float green, float blue, float alpha) + { + if (VERBOSE) + System.err.println("JoglPipeline.setBlendColor()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setBlendColor++; + + GL2ES2 gl = null;// get late expensive + + if (isExtensionAvailable.GL_ARB_imaging(gl)) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glBlendColor(red, green, blue, alpha); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + } + + // native method for setting blend func + @Override + void setBlendFunc(Context ctx, int srcBlendFunction, int dstBlendFunction) + { + if (VERBOSE) + System.err.println("JoglPipeline.setBlendFunc()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setBlendFunc++; + + GL2ES2 gl = null;// get late expensive + Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx); + + if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != true + || joglesctx.gl_state.srcBlendFunction != srcBlendFunction || joglesctx.gl_state.dstBlendFunction != dstBlendFunction)) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glEnable(GL2ES2.GL_BLEND); + gl.glBlendFunc(blendFunctionTable[srcBlendFunction], blendFunctionTable[dstBlendFunction]); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) + { + joglesctx.gl_state.glEnableGL_BLEND = true; + joglesctx.gl_state.srcBlendFunction = srcBlendFunction; + joglesctx.gl_state.dstBlendFunction = dstBlendFunction; + } + } + } + + // native method for setting light enables + @Override + void setLightEnables(Context ctx, long enableMask, int maxLights) + { + if (VERBOSE) + System.err.println("JoglPipeline.setLightEnables()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setLightEnables++; + + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + joglesctx.maxLights = maxLights; + joglesctx.numberOfLights = 0; + for (int i = 0; i < maxLights; i++) + { + boolean enable = (enableMask & (1 << i)) >> i != 0; + if (joglesctx.glLightSource[i] == null) + { + joglesctx.glLightSource[i] = new glLightSource(); + } + + joglesctx.glLightSource[i].enabled = enable ? 1 : 0; + joglesctx.numberOfLights += enable ? 1 : 0; + + // clear gl_state + joglesctx.gl_state.glLightSource[i] = null; // this is a pointer not a container + } + } + + // native method for setting scene ambient + @Override + void setSceneAmbient(Context ctx, float red, float green, float blue) + { + if (VERBOSE) + System.err.println("JoglPipeline.setSceneAmbient()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setSceneAmbient++; + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + + // do we need to push onto the shader now? + if (joglesctx.currentAmbientColor.x != red || joglesctx.currentAmbientColor.y != green || joglesctx.currentAmbientColor.z != blue) + { joglesctx.gl_state.glLightModelambient.x = Float.NEGATIVE_INFINITY; + + joglesctx.currentAmbientColor.x = red; + joglesctx.currentAmbientColor.y = green; + joglesctx.currentAmbientColor.z = blue; + joglesctx.currentAmbientColor.w = 1.0f;} + + } + + // native method for disabling modelClip + // this is called as a reset + @Override + void disableModelClip(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.disableModelClip()"); + } + + // native method for activating a particular texture unit + @Override + void activeTextureUnit(Context ctx, int texUnitIndex) + { + if (VERBOSE) + System.err.println("JoglPipeline.activeTextureUnit(texUnitIndex= " + texUnitIndex + ")"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.activeTextureUnit++; + + Jogl2es2Context joglesContext = (Jogl2es2Context) ctx; + GL2ES2 gl = null;// get late expensive + + if (texUnitIndex >= 0) + { + if (!MINIMISE_NATIVE_CALLS_TEXTURE || (joglesContext.gl_state.glActiveTexture != (texUnitIndex + GL2ES2.GL_TEXTURE0))) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glActiveTexture(texUnitIndex + GL2ES2.GL_TEXTURE0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_TEXTURE) + joglesContext.gl_state.glActiveTexture = (texUnitIndex + GL2ES2.GL_TEXTURE0); + } + } + } + + // native method for setting default texture + @Override + void resetTextureNative(Context ctx, int texUnitIndex) + { + if (VERBOSE) + System.err.println("JoglPipeline.resetTextureNative(texUnitIndex=" + texUnitIndex + ")"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.resetTextureNative++; + + Jogl2es2Context joglesContext = (Jogl2es2Context) ctx; + GL2ES2 gl = null;// get late expensive + + if (texUnitIndex >= 0) + { + if (!MINIMISE_NATIVE_CALLS_TEXTURE || (joglesContext.gl_state.glActiveTexture != (texUnitIndex + GL2ES2.GL_TEXTURE0))) + { + gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl; + gl.glActiveTexture(texUnitIndex + GL2ES2.GL_TEXTURE0); + // TODO: should I bind these to 0? + // gl.glBindTexture(GL2ES2.GL_TEXTURE_2D, 0);//-1 is no texture , 0 is default + // gl.glBindTexture(GL2ES2.GL_TEXTURE_CUBE_MAP, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_TEXTURE) + joglesContext.gl_state.glActiveTexture = (texUnitIndex + GL2ES2.GL_TEXTURE0); + } + } + } + + // The native method for setting the ModelView matrix. + @Override + void setModelViewMatrix(Context ctx, double[] viewMatrix, double[] modelMatrix) + { + if (VERBOSE) + System.err.println("JoglPipeline.setModelViewMatrix(viewMatrix= " + lineString(viewMatrix) + " modelMatrix= " + + lineString(modelMatrix) + ")"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setModelViewMatrix++; + + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + + //joglesctx.matrixUtil.deburnV.set(viewMatrix); + //joglesctx.matrixUtil.deburnV.transpose();// now done in ffp by call to native + joglesctx.currentViewMat.set(viewMatrix); + + //joglesctx.matrixUtil.deburnM.set(modelMatrix); + //joglesctx.matrixUtil.deburnM.transpose();// now done in ffp by call to native + joglesctx.currentModelMat.set(modelMatrix); + + joglesctx.gl_state.modelMatrix.m00 = Double.NEGATIVE_INFINITY;// indicate needs pushing onto shader + joglesctx.gl_state.glModelViewMatrix.m00 = Double.NEGATIVE_INFINITY; + joglesctx.gl_state.glModelViewMatrixInverse.m00 = Double.NEGATIVE_INFINITY; + joglesctx.gl_state.glModelViewProjectionMatrix.m00 = Double.NEGATIVE_INFINITY; + joglesctx.gl_state.glNormalMatrix.m00 = Double.NEGATIVE_INFINITY; + + //Moved up into setffp and only calc'ed if requested + joglesctx.currentModelViewMat.m00 = Double.NEGATIVE_INFINITY;// indicate no longer valid + joglesctx.currentModelViewMatInverse.m00 = Double.NEGATIVE_INFINITY; + joglesctx.currentModelViewProjMat.m00 = Double.NEGATIVE_INFINITY; + joglesctx.currentNormalMat.m00 = Double.NEGATIVE_INFINITY; + + /* + + joglesctx.currentModelViewMat.mul(joglesctx.matrixUtil.deburnV, joglesctx.matrixUtil.deburnM); + + + joglesctx.currentModelViewProjMat.mul(joglesctx.currentProjMat, joglesctx.currentModelViewMat); + + // use only the upper left as it is a 3x3 rotation matrix + JoglesMatrixUtil.transposeInvert(joglesctx.currentModelViewMat, joglesctx.currentNormalMat); + */ + + // note this MV MUST be used by the lights when setting position! + //https://www.opengl.org/discussion_boards/showthread.php/168706-Light-Position-in-eye-s-cordinate + } + + // The native method for setting the Projection matrix. + @Override + void setProjectionMatrix(Context ctx, double[] projMatrix) + { + if (VERBOSE) + System.err.println("JoglPipeline.setProjectionMatrix()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setProjectionMatrix++; + + Jogl2es2Context joglesctx = (Jogl2es2Context) ctx; + + // Invert the Z value in clipping coordinates because OpenGL uses + // left-handed clipping coordinates, while Java3D defines right-handed + // coordinates everywhere. + projMatrix[8] *= -1.0; + projMatrix[9] *= -1.0; + projMatrix[10] *= -1.0; + projMatrix[11] *= -1.0; + + joglesctx.currentProjMat.set(projMatrix); + // joglesctx.currentProjMat.transpose(); // done in set ffp now + + // reverse it back in case others use it + projMatrix[8] *= -1.0; + projMatrix[9] *= -1.0; + projMatrix[10] *= -1.0; + projMatrix[11] *= -1.0; + + } + + // The native method for setting the Viewport. + @Override + void setViewport(Context ctx, int x, int y, int width, int height) + { + if (VERBOSE) + System.err.println("JoglPipeline.setViewport()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setViewport++; + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setViewportTime = System.nanoTime(); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + gl.glViewport(x, y, width, height); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + private static String lineString(double[] da) + { + String ret = "double["; + for (double d : da) + ret += " " + d; + return ret + "]"; + } + + private static String lineString(float[] fa) + { + String ret = "float["; + for (float f : fa) + ret += " " + f; + return ret + "]"; + } + + @Override + void freeTexture(Context ctx, int id) + { + if (VERBOSE) + System.err.println("JoglPipeline.freeTexture()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.freeTexture++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + if (id > 0) + { + int[] tmp = new int[1]; + tmp[0] = id; + gl.glDeleteTextures(1, tmp, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + System.err.println("tried to delete tex with texid <= 0"); + } + } + + @Override + int generateTexID(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.generateTexID()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.generateTexID++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + int[] tmp = new int[] { -1 }; + gl.glGenTextures(1, tmp, 0); + + if (tmp[0] < 1) + return -1; + + return tmp[0]; + } + + @Override + void texturemapping(Context ctx, int px, int py, int minX, int minY, int maxX, int maxY, int texWidth, int texHeight, int rasWidth, + int format, int objectId, byte[] imageYdown, int winWidth, int winHeight) + { + if (VERBOSE) + System.err.println("JoglPipeline.texturemapping()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + int glType = GL.GL_RGBA; + + disableAttribFor2D(gl); + + gl.glDepthMask(false); + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); + gl.glBindTexture(GL.GL_TEXTURE_2D, objectId); + // set up texture parameter + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); + + gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); + + if (isExtensionAvailable.GL_EXT_abgr(gl)) + { + glType = GL2.GL_ABGR_EXT; + } + else + { + switch (format) + { + case ImageComponentRetained.TYPE_BYTE_RGBA: + glType = GL.GL_RGBA; + break; + case ImageComponentRetained.TYPE_BYTE_RGB: + glType = GL.GL_RGB; + break; + } + } + + gl.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, minX, minY, maxX - minX, maxY - minY, glType, GL.GL_UNSIGNED_BYTE, + ByteBuffer.wrap(imageYdown)); + + float texMinU = (float) minX / (float) texWidth; + float texMinV = (float) minY / (float) texHeight; + float texMaxU = (float) maxX / (float) texWidth; + float texMaxV = (float) maxY / (float) texHeight; + float halfWidth = winWidth / 2.0f; + float halfHeight = winHeight / 2.0f; + + float mapMinX = ((px + minX) - halfWidth) / halfWidth; + float mapMinY = (halfHeight - (py + maxY)) / halfHeight; + float mapMaxX = (px + maxX - halfWidth) / halfWidth; + float mapMaxY = (halfHeight - (py + minY)) / halfHeight; + + float mapZ = 0; + + //NOTE!!!!!! very very well, tex*V is swapped max/min in order to upright the Y of the image!! + renderTexturedQuad(ctx, texMinU, texMaxU, texMaxV, texMinV, mapMinX, mapMaxX, mapMinY, mapMaxY, mapZ); + + // Java 3D always clears the Z-buffer + gl.glDepthMask(true); + gl.glClear(GL.GL_DEPTH_BUFFER_BIT); + } + + @Override + boolean initTexturemapping(Context ctx, int texWidth, int texHeight, int objectId) + { + if (VERBOSE) + System.err.println("JoglPipeline.initTexturemapping()"); + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + gl.glBindTexture(GL.GL_TEXTURE_2D, objectId); + + int glType = GL.GL_RGBA; + if (isExtensionAvailable.GL_EXT_abgr(gl)) + { + glType = GL2.GL_ABGR_EXT; + } + else + { + glType = GL.GL_RGBA; + } + //some sort of memory space check below? + /*gl.glTexImage2D(GL2.GL_PROXY_TEXTURE_2D, 0, GL2ES2.GL_RGBA, texWidth, texHeight, 0, glType, GL.GL_UNSIGNED_BYTE, null); + + int[] width = new int[1]; + gl.glGetTexLevelParameteriv(GL2.GL_PROXY_TEXTURE_2D, 0, GL2.GL_TEXTURE_WIDTH, width, 0); + + if (width[0] <= 0) + { + return false; + }*/ + + // init texture size only without filling the pixels + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, texWidth, texHeight, 0, glType, GL.GL_UNSIGNED_BYTE, null); + + return true; + } + + // Set glDepthMask. + @Override + void setDepthBufferWriteEnable(Context ctx, boolean mode) + { + if (VERBOSE) + System.err.println("JoglPipeline.setDepthBufferWriteEnable()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setDepthBufferWriteEnable++; + + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + + if (mode) + { + gl.glDepthMask(true); + } + else + { + gl.glDepthMask(false); + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // Set internal render mode to one of FIELD_ALL, FIELD_LEFT or + // FIELD_RIGHT. Note that it is up to the caller to ensure that + // stereo is available before setting the mode to FIELD_LEFT or + // FIELD_RIGHT. The boolean doubleBuffer is TRUE for double buffered mode, FALSE + // for single buffering. + @Override + void setRenderMode(Context ctx, int mode, boolean doubleBuffer) + { + if (VERBOSE) + System.err.println("JoglPipeline.setRenderMode()"); + + // TODO: why is this not done in swap or sync? + // UGLY HACK the render mode is set to Canvas3D.FIELD_ALL after all + // geoms are drawn + // so I take the opportunity to unbind the vertex array + + GL2ES3 gl2es3 = ((Jogl2es2Context) ctx).gl2es3(); + if (gl2es3 != null) + { + gl2es3.glBindVertexArray(0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + // GL2ES2 gl = context(ctx).getGL().getGL2ES2(); + // no no drawBuffer, possibly just skip it for now + // ES2 is much more complex with buffers https://www.khronos.org/registry/gles/extensions/EXT/EXT_draw_buffers.txt + + /* int drawBuf = 0; + if (doubleBuffer) + { + drawBuf = GL2ES2.GL_BACK; + switch (mode) + { + case Canvas3D.FIELD_LEFT: + drawBuf = GL2ES2.GL_BACK_LEFT; + break; + case Canvas3D.FIELD_RIGHT: + drawBuf = GL2ES2.GL_BACK_RIGHT; + break; + case Canvas3D.FIELD_ALL: + drawBuf = GL2ES2.GL_BACK; + break; + } + } + else + { + drawBuf = GL2ES2.GL_FRONT; + switch (mode) + { + case Canvas3D.FIELD_LEFT: + drawBuf = GL2ES2.GL_FRONT_LEFT; + break; + case Canvas3D.FIELD_RIGHT: + drawBuf = GL2ES2.GL_FRONT_RIGHT; + break; + case Canvas3D.FIELD_ALL: + drawBuf = GL2ES2.GL_FRONT; + break; + } + } + + gl.glDrawBuffer(drawBuf);*/ + } + + private static int getFunctionValue(int func) + { + switch (func) + { + case RenderingAttributes.ALWAYS: + func = GL2ES2.GL_ALWAYS; + break; + case RenderingAttributes.NEVER: + func = GL2ES2.GL_NEVER; + break; + case RenderingAttributes.EQUAL: + func = GL2ES2.GL_EQUAL; + break; + case RenderingAttributes.NOT_EQUAL: + func = GL2ES2.GL_NOTEQUAL; + break; + case RenderingAttributes.LESS: + func = GL2ES2.GL_LESS; + break; + case RenderingAttributes.LESS_OR_EQUAL: + func = GL2ES2.GL_LEQUAL; + break; + case RenderingAttributes.GREATER: + func = GL2ES2.GL_GREATER; + break; + case RenderingAttributes.GREATER_OR_EQUAL: + func = GL2ES2.GL_GEQUAL; + break; + } + + return func; + } + + private static int getStencilOpValue(int op) + { + switch (op) + { + case RenderingAttributes.STENCIL_KEEP: + op = GL2ES2.GL_KEEP; + break; + case RenderingAttributes.STENCIL_ZERO: + op = GL2ES2.GL_ZERO; + break; + case RenderingAttributes.STENCIL_REPLACE: + op = GL2ES2.GL_REPLACE; + break; + case RenderingAttributes.STENCIL_INCR: + op = GL2ES2.GL_INCR; + break; + case RenderingAttributes.STENCIL_DECR: + op = GL2ES2.GL_DECR; + break; + case RenderingAttributes.STENCIL_INVERT: + op = GL2ES2.GL_INVERT; + break; + } + + return op; + } + + // --------------------------------------------------------------------- + + // + // TransparencyAttributesRetained methods + // + + private static final int[] blendFunctionTable = new int[TransparencyAttributes.MAX_BLEND_FUNC_TABLE_SIZE]; + + static + { + blendFunctionTable[TransparencyAttributes.BLEND_ZERO] = GL2ES2.GL_ZERO; + blendFunctionTable[TransparencyAttributes.BLEND_ONE] = GL2ES2.GL_ONE; + blendFunctionTable[TransparencyAttributes.BLEND_SRC_ALPHA] = GL2ES2.GL_SRC_ALPHA; + blendFunctionTable[TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA] = GL2ES2.GL_ONE_MINUS_SRC_ALPHA; + blendFunctionTable[TransparencyAttributes.BLEND_DST_COLOR] = GL2ES2.GL_DST_COLOR; + blendFunctionTable[TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR] = GL2ES2.GL_ONE_MINUS_DST_COLOR; + blendFunctionTable[TransparencyAttributes.BLEND_SRC_COLOR] = GL2ES2.GL_SRC_COLOR; + blendFunctionTable[TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR] = GL2ES2.GL_ONE_MINUS_SRC_COLOR; + blendFunctionTable[TransparencyAttributes.BLEND_CONSTANT_COLOR] = GL2ES2.GL_CONSTANT_COLOR; + } + + // ---------------------------------------------------------------------- + // Helper private functions for Canvas3D + // + // USED BY CONTEXT QUERIER BELOW which is used for create new context + private static boolean getPropertiesFromCurrentContext(JoglContext ctx, GL2ES2 gl) + { + // FIXME: this is a heavily abridged set of the stuff in Canvas3D.c; + // probably need to pull much more in + int[] tmp = new int[1]; + gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, tmp, 0); + ctx.setMaxTexCoordSets(tmp[0]); + if (VirtualUniverse.mc.transparentOffScreen) + { + ctx.setAlphaClearValue(0.0f); + } + else + { + ctx.setAlphaClearValue(1.0f); + } + return true; + } + + // Used by createNewContext below + private static int[] extractVersionInfo(String versionString) + { + // FIXME: use the second flash regex system to get the first number out + // examples + // OpenGL ES 3.0 [email protected] AU@ (GIT@I3fa967cfef) + // 4.5.0 NVIDIA 353.82 + // System.err.println("versionString: " + versionString); + if (versionString.startsWith("OpenGL ES ")) + versionString = versionString.substring("OpenGL ES ".length()); + StringTokenizer tok = new StringTokenizer(versionString, ". "); + int major = Integer.valueOf(tok.nextToken()).intValue(); + int minor = Integer.valueOf(tok.nextToken()).intValue(); + + // See if there's vendor-specific information which might + // imply a more recent OpenGL version + tok = new StringTokenizer(versionString, " "); + if (tok.hasMoreTokens()) + { + tok.nextToken(); + if (tok.hasMoreTokens()) + { + Pattern p = Pattern.compile("\\D*(\\d+)\\.(\\d+)\\.?(\\d*).*"); + Matcher m = p.matcher(tok.nextToken()); + if (m.matches()) + { + int altMajor = Integer.valueOf(m.group(1)).intValue(); + int altMinor = Integer.valueOf(m.group(2)).intValue(); + // Avoid possibly confusing situations by requiring + // major version to match + if (altMajor == major && altMinor > minor) + { + minor = altMinor; + } + } + } + } + return new int[] { major, minor }; + } + + // Used by createNewContext below + private static void checkTextureExtensions(Canvas3D cv, JoglContext ctx, GL2ES2 gl, boolean gl13) + { + if (gl13) + { + + // FIXME: setting this to cv.maxTexCoordSets = 8; and cutting the rest out doesn't work! + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_MULTI_TEXTURE; + cv.multiTexAccelerated = true; + int[] tmp = new int[1]; + gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, tmp, 0); + cv.maxTextureUnits = tmp[0]; + cv.maxTexCoordSets = cv.maxTextureUnits; + } + + //Combine function gone as shader not FFP + /*if (gl.isExtensionAvailable("GL_ARB_texture_env_combine")) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE; + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE_SUBTRACT; + } + else if (gl.isExtensionAvailable("GL_EXT_texture_env_combine")) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE; + } + + if (gl.isExtensionAvailable("GL_ARB_texture_env_dot3") || gl.isExtensionAvailable("GL_EXT_texture_env_dot3")) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE_DOT3; + }*/ + + if (gl13) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_CUBE_MAP; + } + + if (gl.isExtensionAvailable("GL_EXT_texture_filter_anisotropic")) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_ANISOTROPIC_FILTER; + float[] tmp = new float[1]; + gl.glGetFloatv(GL2ES2.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, tmp, 0); + cv.anisotropicDegreeMax = tmp[0]; + } + + //Gles uses the GL_OES_texture_npot extension + if (!VirtualUniverse.mc.enforcePowerOfTwo + && (gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two") || gl.isExtensionAvailable("GL_OES_texture_npot"))) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO; + } + + //autoMipMapGeneration + //if (gl.isExtensionAvailable("GL_SGIS_generate_mipmap")) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION; + } + + } + + // Used by createNewContext above + private static void checkGLSLShaderExtensions(Canvas3D cv, JoglContext ctx, GL2ES2 gl, boolean hasgl13) + { + + //PJPJ Gl2ES2 MUST support shaders, and the support is NOT an extension + // Force shaders to be disabled, since no multitexture support + // if (!hasgl13) + // return; + + // if ((gl.isExtensionAvailable("GL_ARB_shader_objects") // + // && gl.isExtensionAvailable("GL_ARB_shading_language_100")) // + // || gl.isExtensionAvailable("GL_AMD_program_binary_Z400")) + { + + // FIXME: this isn't complete and would need to set up the + // JoglContext for dispatch of various routines such as those + // related to vertex attributes + int[] tmp = new int[1]; + gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, tmp, 0); + cv.maxTextureImageUnits = tmp[0]; + gl.glGetIntegerv(GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, tmp, 0); + cv.maxVertexTextureImageUnits = tmp[0]; + gl.glGetIntegerv(GL2ES2.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, tmp, 0); + cv.maxCombinedTextureImageUnits = tmp[0]; + int vertexAttrOffset = VirtualUniverse.mc.glslVertexAttrOffset; + ctx.setGLSLVertexAttrOffset(vertexAttrOffset); + gl.glGetIntegerv(GL2ES2.GL_MAX_VERTEX_ATTRIBS, tmp, 0); + cv.maxVertexAttrs = tmp[0]; + // decr count to allow for reserved vertex attrs + cv.maxVertexAttrs -= vertexAttrOffset; + if (cv.maxVertexAttrs < 0) + { + cv.maxVertexAttrs = 0; + } + + //http://stackoverflow.com/questions/26682631/webgl-shaders-maximum-number-of-varying-variables + gl.glGetIntegerv(GL2ES2.GL_MAX_VARYING_VECTORS, tmp, 0); + cv.maxVaryingVectors = tmp[0]; + + cv.shadingLanguageGLSL = true; + } + } + + // Used by createNewContext below + private static void setupCanvasProperties(Canvas3D cv, JoglContext ctx, GL2ES2 gl) + { + // Note: this includes relevant portions from both the + // NativePipeline's getPropertiesFromCurrentContext and setupCanvasProperties + + // Reset all fields + cv.multiTexAccelerated = false; + cv.maxTextureUnits = 1; + cv.maxTexCoordSets = 1; + cv.maxTextureImageUnits = 0; + cv.maxVertexTextureImageUnits = 0; + cv.maxCombinedTextureImageUnits = 0; + cv.maxVertexAttrs = 0; + cv.maxVaryingVectors = 0; + cv.extensionsSupported = 0; + cv.textureExtendedFeatures = 0; + cv.textureColorTableSize = 0; + cv.anisotropicDegreeMax = 0; + cv.textureBoundaryWidthMax = 0; + cv.textureWidthMax = 0; + cv.textureHeightMax = 0; + cv.texture3DWidthMax = 0; + cv.texture3DHeightMax = 0; + cv.texture3DDepthMax = 0; + cv.shadingLanguageGLSL = false; + + // Now make queries and set up these fields + String glVersion = gl.glGetString(GL2ES2.GL_VERSION); + String glVendor = gl.glGetString(GL2ES2.GL_VENDOR); + String glRenderer = gl.glGetString(GL2ES2.GL_RENDERER); + cv.nativeGraphicsVersion = glVersion; + cv.nativeGraphicsVendor = glVendor; + cv.nativeGraphicsRenderer = glRenderer; + + // just for debug + // System.out.println("***glVersion " +glVersion); + // System.out.println("***glVendor " +glVendor); + // System.out.println("***glRenderer " +glRenderer); + // System.out.println( ctx.getGLContext().toString()); + + // find out the version, major and minor version number + int[] versionNumbers = extractVersionInfo(glVersion); + int major = versionNumbers[0]; + int minor = versionNumbers[1]; + + /////////////////////////////////////////// + // setup the graphics context properties // + + // NOTE: Java 3D now requires OpenGL 1.3 for full functionality. + // For backwards compatibility with certain older graphics cards and + // drivers (e.g., the Linux DRI driver for older ATI cards), + // we will try to run on OpenGL 1.2 in an unsupported manner. However, + // we will not attempt to use OpenGL extensions for any features that + // are available in OpenGL 1.3, specifically multitexture, multisample, + // and cube map textures. + + if (major < 1 || (major == 1 && minor < 2)) + { + // In some double createNewContext uses or where getPreferredConfiguration is called before a Frame is constructed + // the disabling of D3D can cause this issue + // see Bug 1201 - Crash with option "sun.java2d.d3d=false" + // https://jogamp.org/bugzilla/show_bug.cgi?id=1201 + + // In the case of Java > 1.8u51 Win10 and an Intel HD2000/3000 driver, the driver will not load because + // the java.exe manifest has a "supportedOS Id" that the drivers don't like (the drivers are too old) + // see Bug 1278 - Windows 10 returns software Profile + // https://jogamp.org/bugzilla/show_bug.cgi?id=1278 + // So we will detect Win10/Oracle Jre u > 51 and offer advice to down grade jre + + if (glVendor.equalsIgnoreCase("Microsoft Corporation") && // + glRenderer.equalsIgnoreCase("GDI Generic") && // + glVersion.equalsIgnoreCase("1.1.0")) + { + System.err.println("Java3D - GDI Generic Driver use detected."); + System.err.println("This may be caused by any of the following issues."); + + if (System.getProperty("sun.java2d.noddraw", "false").equals("true") + || System.getProperty("sun.java2d.d3d", "true").equals("false")) + { + System.err.println("Issue: Use of System.setProperty(\"sun.java2d.noddraw\", \"true\");"); + System.err.println("or System.setProperty(\"sun.java2d.d3d\", \"false\");"); + System.err.println("If either of these are being used please try either reversing or removing them,"); + System.err.println("or if they are required else where try adding System.setProperty(\"sun.awt.nopixfmt\", \"true\");"); + } + + if (Platform.getOSName().equalsIgnoreCase("Windows 10") && //win10 + (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version19) >= 0) || // 1.9 or 1.8 > 51 + (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version18) >= 0 && Platform.JAVA_VERSION_UPDATE > 51) && // + Platform.getJavaVMName().toLowerCase().startsWith("java hotspot(tm)"))// e.g. Java HotSpot(TM) 64-Bit Server VM ; OpenJDK would give OpenJDK 64-Bit Server VM + { + System.err.println("Issue: The use of an Intel HD2000/3000 driver in combination with Windows 10 and"); + System.err.println("a JRE greater than 1.8 update 51. Please downgrade the JRE in use to JRE 1.8u51 or lower."); + System.err.println("For more information please see https://jogamp.org/bugzilla/show_bug.cgi?id=1278."); + } + System.err.println("If this software has been supplied to you and you are unable to modify it's configuration"); + System.err.println("please contact the suppler of this software with this entire message."); + } + + throw new IllegalRenderingStateException( + "Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=" + major + "." + minor + ")"); + } + + boolean gl20 = false; + boolean gl14 = false; + boolean gl13 = false; + + if (major == 1) + { + if (minor == 2) + { + System.err.println("JAVA 3D: OpenGL 1.2 detected; will run with reduced functionality"); + } + if (minor >= 3) + { + gl13 = true; + } + if (minor >= 4) + { + gl14 = true; + } + } + else + // major >= 2 + { + gl13 = true; + gl14 = true; + gl20 = true; + } + + if (gl20) + { + assert gl13; + assert gl14; + assert gl.isExtensionAvailable("GL_VERSION_2_0"); + } + + if (gl14) + { + assert gl13; + assert gl.isExtensionAvailable("GL_VERSION_1_4"); + } + + if (gl13) + { + assert gl.isExtensionAvailable("GL_VERSION_1_3"); + } + + // Note that we don't query for GL_ARB_imaging here + + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_LOD_RANGE; + + /* + if (gl14) + { + cv.textureExtendedFeatures |= Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION; + }*/ + + // look for OpenGL 2.0 features + // Fix to Issue 455 : Need to disable NPOT textures for older cards that claim to support it. + // Some older cards (e.g., Nvidia fx500 and ATI 9800) claim to support OpenGL 2.0. + // This means that these cards have to support non-power-of-two (NPOT) texture, + // but their lack the necessary HW force the vendors the emulate this feature in software. + // The result is a ~100x slower down compare to power-of-two textures. + // Do not check for gl20 but instead check of GL_ARB_texture_non_power_of_two extension string + // if (gl20) { + // if(!VirtualUniverse.mc.enforcePowerOfTwo) { + // cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO; + // } + // } + + // Setup GL_EXT_abgr + if (gl.isExtensionAvailable("GL_EXT_abgr")) + { + cv.extensionsSupported |= Canvas3D.EXT_ABGR; + } + + // GL_BGR is always supported + cv.extensionsSupported |= Canvas3D.EXT_BGR; + + // Setup multisample + // FIXME: this is not correct for the Windows platform yet + // FIXME: this might be tricky, if I muck around the accum calls turn on again + // ES2 has new enable/disable on GL_SAMPLE_ALPHA_TO_COVERAGE and GL_SAMPLE_COVERAGE + // and GL2 and ES2 both have glSampleCoverage calls + // Renderer line 1158 is the guy that goes for accum if this is not set + if (gl13) + { + cv.extensionsSupported |= Canvas3D.MULTISAMPLE; + ctx.setHasMultisample(true); + } + + if ((cv.extensionsSupported & Canvas3D.MULTISAMPLE) != 0 && !VirtualUniverse.mc.implicitAntialiasing) + { + //with a bit of luck ES2 will ignore this call and leave sampling on + //gl.glDisable(GL2ES2.GL_MULTISAMPLE); + } + + checkTextureExtensions(cv, ctx, gl, gl13); + + checkGLSLShaderExtensions(cv, ctx, gl, gl13); + + cv.textureBoundaryWidthMax = 1; + + int[] tmp = new int[1]; + gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_SIZE, tmp, 0); + cv.textureWidthMax = tmp[0]; + cv.textureHeightMax = tmp[0]; + } + + private static void disableAttribFor2D(GL2ES2 gl) + { + gl.glDisable(GL.GL_BLEND); + gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL.GL_DEPTH_TEST); + gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + gl.glDisable(GL.GL_STENCIL_TEST); + } + + private static void disableAttribForRaster(GL2ES2 gl) + { + gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + } + + // Not needed generally as transpose can be called on the interface with gl + public static void copyTranspose(double[] src, double[] dst) + { + dst[0] = src[0]; + dst[1] = src[4]; + dst[2] = src[8]; + dst[3] = src[12]; + dst[4] = src[1]; + dst[5] = src[5]; + dst[6] = src[9]; + dst[7] = src[13]; + dst[8] = src[2]; + dst[9] = src[6]; + dst[10] = src[10]; + dst[11] = src[14]; + dst[12] = src[3]; + dst[13] = src[7]; + dst[14] = src[11]; + dst[15] = src[15]; + } + + @Override + void clear(Context ctx, float r, float g, float b, boolean clearStencil) + { + if (VERBOSE) + System.err.println("JoglPipeline.clear()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.clear++; + + Jogl2es2Context jctx = (Jogl2es2Context) ctx; + GL2ES2 gl = jctx.gl2es2(); + + // Mask of which buffers to clear, this always includes color & depth + int clearMask = GL2ES2.GL_DEPTH_BUFFER_BIT | GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_STENCIL_BUFFER_BIT; + + // NOTE stencil always cleared + + gl.glDepthMask(true); + gl.glClearColor(r, g, b, jctx.getAlphaClearValue()); + gl.glClear(clearMask); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + private static int createSimpleTextureShaderProgram(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.createSimpleTextureShaderProgram()"); + + // now create and set shader + String vertexProgram = "#version 120\n"; + vertexProgram += "attribute vec2 glMultiTexCoord0;\n"; + vertexProgram += "attribute vec4 glVertex;\n"; + vertexProgram += "varying vec2 glTexCoord0;\n"; + vertexProgram += "void main( void ){\n"; + vertexProgram += "gl_Position = glVertex;\n"; + vertexProgram += "glTexCoord0 = glMultiTexCoord0.st;\n"; + vertexProgram += "}"; + + String fragmentProgram = "#version 120\n"; + fragmentProgram += "precision mediump float;\n"; + fragmentProgram += "varying vec2 glTexCoord0;\n"; + fragmentProgram += "uniform sampler2D BaseMap;\n"; + fragmentProgram += "void main( void ){\n "; + fragmentProgram += "vec4 baseMap = texture2D( BaseMap, glTexCoord0.st );\n"; + fragmentProgram += "gl_FragColor = baseMap;\n"; + //fragmentProgram += "gl_FragColor = vec4(1,1,0.5,1);\n"; + fragmentProgram += "}"; + + int programId = createShaderProgram(ctx, vertexProgram, fragmentProgram); + + // now record the locations + Jogl2es2Context jctx = (Jogl2es2Context) ctx; + GL2ES2 gl = jctx.gl2es2(); + jctx.simpleTextureShaderProgramVertLoc = gl.glGetAttribLocation(programId, "glVertex"); + jctx.simpleTextureShaderProgramTexCoordLoc = gl.glGetAttribLocation(programId, "glMultiTexCoord0"); + jctx.simpleTextureShaderProgramBaseMapLoc = gl.glGetUniformLocation(programId, "BaseMap"); + + return programId; + } + + private static int createShaderProgram(Context ctx, String vertexProgram, String fragmentProgram) + { + if (VERBOSE) + System.err.println("JoglPipeline.createShaderProgram()"); + + Jogl2es2Context jctx = (Jogl2es2Context) ctx; + GL2ES2 gl = jctx.gl2es2(); + + int shaderHandleV = gl.glCreateShader(GL2ES2.GL_VERTEX_SHADER); + int shaderHandleF = gl.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER); + + int shaderProgramHandle = gl.glCreateProgram(); + + gl.glAttachShader(shaderProgramHandle, shaderHandleV); + gl.glAttachShader(shaderProgramHandle, shaderHandleF); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + gl.glShaderSource(shaderHandleV, 1, new String[] { vertexProgram }, null, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + gl.glCompileShader(shaderHandleV); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + int[] status = new int[1]; + gl.glGetShaderiv(shaderHandleV, GL2ES2.GL_COMPILE_STATUS, status, 0); + if (status[0] == 0) + { + String detailMsg = getShaderInfoLog(gl, shaderHandleV); + System.err.println(detailMsg); + } + gl.glShaderSource(shaderHandleF, 1, new String[] { fragmentProgram }, null, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + gl.glCompileShader(shaderHandleF); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + gl.glGetShaderiv(shaderHandleF, GL2ES2.GL_COMPILE_STATUS, status, 0); + if (status[0] == 0) + { + String detailMsg = getShaderInfoLog(gl, shaderHandleF); + System.err.println(detailMsg); + } + + gl.glLinkProgram(shaderProgramHandle); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + gl.glGetProgramiv(shaderProgramHandle, GL2ES2.GL_LINK_STATUS, status, 0); + if (status[0] == 0) + { + String detailMsg = getProgramInfoLog(gl, shaderProgramHandle); + System.err.println(detailMsg); + } + + return shaderProgramHandle; + } + + /** + * Texture 0 must be bound by now + * @param texMinU + */ + private static void renderTexturedQuad(Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX, + float mapMaxX, float mapMinY, float mapMaxY, float mapZ) + { + if (VERBOSE) + System.err.println("JoglPipeline.renderTexturedQuad()"); + + Jogl2es2Context jctx = (Jogl2es2Context) ctx; + GL2ES2 gl = jctx.gl2es2(); + + //NOTE .order(ByteOrder.nativeOrder())!!! + int vcount = 6; + FloatBuffer verts = ByteBuffer.allocateDirect(Float.SIZE / 8 * 3 * vcount).order(ByteOrder.nativeOrder()).asFloatBuffer(); + FloatBuffer tcs = ByteBuffer.allocateDirect(Float.SIZE / 8 * 2 * vcount).order(ByteOrder.nativeOrder()).asFloatBuffer(); + + //CCW windings for fun (cull face should make unnecessary + tcs.put(texMinU).put(texMinV); + verts.put(mapMinX).put(mapMinY).put(mapZ); + tcs.put(texMaxU).put(texMaxV); + verts.put(mapMaxX).put(mapMaxY).put(mapZ); + tcs.put(texMinU).put(texMaxV); + verts.put(mapMinX).put(mapMaxY).put(mapZ); + + tcs.put(texMinU).put(texMinV); + verts.put(mapMinX).put(mapMinY).put(mapZ); + tcs.put(texMaxU).put(texMinV); + verts.put(mapMaxX).put(mapMinY).put(mapZ); + tcs.put(texMaxU).put(texMaxV); + verts.put(mapMaxX).put(mapMaxY).put(mapZ); + + verts.position(0); + tcs.position(0); + + int[] tmp = new int[2]; + gl.glGenBuffers(2, tmp, 0); + int vertBufId = tmp[0]; + int tcBufId = tmp[1]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, vertBufId); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_STREAM_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, tcBufId); + gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (tcs.remaining() * Float.SIZE / 8), tcs, GL2ES2.GL_STREAM_DRAW); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (jctx.simpleTextureShaderProgramId == -1) + jctx.simpleTextureShaderProgramId = createSimpleTextureShaderProgram(ctx); + + gl.glUseProgram(jctx.simpleTextureShaderProgramId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + jctx.prevShaderProgram = jctx.simpleTextureShaderProgramId; + + boolean bindingRequired = true; + + // always create a new one + int vaoId = -1; + if (gl.isGL2ES3()) + { + GL2ES3 gl2es3 = (GL2ES3)gl; + if (vaoId == -1) + { + int[] tmp2 = new int[1]; + gl2es3.glGenVertexArrays(1, tmp2, 0); + vaoId = tmp2[0]; + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + bindingRequired = false; + } + gl2es3.glBindVertexArray(vaoId); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + if (bindingRequired) + { + if (jctx.simpleTextureShaderProgramVertLoc != -1) + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, vertBufId); + gl.glVertexAttribPointer(jctx.simpleTextureShaderProgramVertLoc, 3, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(jctx.simpleTextureShaderProgramVertLoc); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + if (jctx.simpleTextureShaderProgramTexCoordLoc != -1) + { + gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, tcBufId); + gl.glVertexAttribPointer(jctx.simpleTextureShaderProgramTexCoordLoc, 2, GL2ES2.GL_FLOAT, false, 0, 0); + gl.glEnableVertexAttribArray(jctx.simpleTextureShaderProgramTexCoordLoc); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + if (jctx.simpleTextureShaderProgramBaseMapLoc != -1) + { + gl.glUniform1i(jctx.simpleTextureShaderProgramBaseMapLoc, 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, vcount); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + // clean u as we have to recreate each pass + if (vaoId != -1) + ((GL2ES3)gl).glDeleteVertexArrays(1, new int[] { vaoId }, 0); + + if (vertBufId != -1) + gl.glDeleteBuffers(1, new int[] { vertBufId }, 0); + + if (tcBufId != -1) + gl.glDeleteBuffers(1, new int[] { tcBufId }, 0); + } + + @Override + void textureFillBackground(Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX, float mapMaxX, + float mapMinY, float mapMaxY, boolean useBilinearFilter) + { + if (VERBOSE) + System.err.println("JoglPipeline.textureFillBackground()"); + + Jogl2es2Context jctx = (Jogl2es2Context) ctx; + GL2ES2 gl = jctx.gl2es2(); + + disableAttribFor2D(gl); + + // Setup filter mode if needed + if (useBilinearFilter) + { + // System.err.println("JoglPipeline - Raster : use bilinear filter\n"); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + //gl.glColor4f(1.0f, 1.0f, 1.0f, alpha); + //TODO: alpha value!! make sure blending on and use the alpha value in shader + + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + //gl.glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); //note [0,1] not the normal [-1,1] + + // add a Z so we stay closer to textureFillRaster + float mapZ = 0f; + + //NOTE!!!!!! very very well, tex*V is swapped max/min in order to upright the Y of the image!! + renderTexturedQuad(ctx, texMinU, texMaxU, texMaxV, texMinV, mapMinX, mapMaxX, mapMinY, mapMaxY, mapZ); + } + + @Override + void textureFillRaster(Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX, float mapMaxX, + float mapMinY, float mapMaxY, float mapZ, float alpha, boolean useBilinearFilter) + { + + if (VERBOSE) + System.err.println("JoglPipeline.textureFillRaster()"); + + Jogl2es2Context jctx = (Jogl2es2Context) ctx; + GL2ES2 gl = jctx.gl2es2(); + + disableAttribForRaster(gl); + + // Setup filter mode if needed + if (useBilinearFilter) + { + // System.err.println("JoglPipeline - Raster : use bilinear filter\n"); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + + //gl.glColor4f(1.0f, 1.0f, 1.0f, alpha); + //TODO: alpha value!! make sure blending on and use the alpha value in shader + + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + //gl.glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); //note [0,1] not the normal [-1,1] + + //NOTE!!!!!! very very well, tex*V is swapped max/min in order to upright the Y of the image!! + renderTexturedQuad(ctx, texMinU, texMaxU, texMaxV, texMinV, mapMinX, mapMaxX, mapMinY, mapMaxY, mapZ); + + } + + @Override + void executeRasterDepth(Context ctx, float posX, float posY, float posZ, int srcOffsetX, int srcOffsetY, int rasterWidth, + int rasterHeight, int depthWidth, int depthHeight, int depthFormat, Object depthData) + { + if (VERBOSE) + System.err.println("JoglPipeline.executeRasterDepth()"); + + //Jogl2es2Context jctx = (Jogl2es2Context) ctx; + //GL2ES2 gl = jctx.gl2es2(); + + throw new UnsupportedOperationException( + "To get depth you should use a shader that return depth info for gl2es2 then read from color"); + /* + gl.glRasterPos3f(posX, posY, posZ); + + int[] drawBuf = new int[1]; + gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, drawBuf, 0); + // disable draw buffer + gl.glDrawBuffer(GL.GL_NONE); + + + // raster position is upper left corner, default for Java3D + // ImageComponent currently has the data reverse in Y + + gl.glPixelZoom(1.0f, -1.0f); + gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, depthWidth); + if (srcOffsetX >= 0) + { + gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, srcOffsetX); + if (srcOffsetX + rasterWidth > depthWidth) + { + rasterWidth = depthWidth - srcOffsetX; + } + } + else + { + rasterWidth += srcOffsetX; + if (rasterWidth > depthWidth) + { + rasterWidth = depthWidth; + } + } + if (srcOffsetY >= 0) + { + gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, srcOffsetY); + if (srcOffsetY + rasterHeight > depthHeight) + { + rasterHeight = depthHeight - srcOffsetY; + } + } + else + { + rasterHeight += srcOffsetY; + if (rasterHeight > depthHeight) + { + rasterHeight = depthHeight; + } + } + + if (depthFormat == DepthComponentRetained.DEPTH_COMPONENT_TYPE_INT) + { + gl.glDrawPixels(rasterWidth, rasterHeight, GL2.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_INT, IntBuffer.wrap((int[]) depthData)); + } + else + { // DepthComponentRetained.DEPTH_COMPONENT_TYPE_FLOAT + gl.glDrawPixels(rasterWidth, rasterHeight, GL2.GL_DEPTH_COMPONENT, GL.GL_FLOAT, FloatBuffer.wrap((float[]) depthData)); + } + + // re-enable draw buffer + gl.glDrawBuffer(drawBuf[0]); + + gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, 0); + gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, 0); + gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, 0); + */ + } + + /** + * This native method makes sure that the rendering for this canvas gets + * done now. + */ + @Override + // render is it's own thread so finish stops nothing + void syncRender(Context ctx, boolean wait) + { + + if (VERBOSE) + System.err.println("JoglPipeline.syncRender() " + wait); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.syncRenderTime = System.nanoTime(); + + // clean up any buffers that need freeing + doClearBuffers(ctx); + + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).outputPerFrameData(); + + // also seems to be ok, just do it as well + if (!NEVER_RELEASE_CONTEXT) + { + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + if (wait) + gl.glFinish(); + else + gl.glFlush(); + } + + } + + // The native method for swapBuffers - onscreen only + @Override + void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) + { + if (VERBOSE) + System.err.println("JoglPipeline.swapBuffers()"); + + GLDrawable draw = drawable(drawable); + draw.swapBuffers(); + + ((Jogl2es2Context) ctx).gl_state.clear(); + } + + private static void outputErrors(Context ctx) + { + if (DO_OUTPUT_ERRORS) + { + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + int err = gl.glGetError(); + if (err != GL2ES2.GL_NO_ERROR) + { + // GL_NO_ERROR = 0x0 + // GL_INVALID_ENUM = 0x500; 1280 + // GL_INVALID_VALUE = 0x501; 1281 + // GL_INVALID_OPERATION = 0x502; 1282 + // GL_INVALID_FRAMEBUFFER_OPERATION = 0x506; 1286 + // GL_OUT_OF_MEMORY= 0x505; 1285 + // GL_STACK_UNDERFLOW 503? + // GL_STACK_OVERFLOW 504? + + // check for no current shader program (likely a switch between scenes or something) + if (err == GL2ES2.GL_INVALID_OPERATION) + { + int[] res = new int[1]; + gl.glGetIntegerv(GL2ES2.GL_CURRENT_PROGRAM, res, 0); + // 0 is no current program + if (res[0] == 0) + return; + } + + System.err.println("JoglesPipeline GL error reported " + err); + StackTraceElement[] st = new Throwable().getStackTrace(); + if (st.length > 1) + System.err.println("Occured in " + st[1]); + + // seems to produce heaps? + /*err = gl.glGetError(); + if (err != GL2ES2.GL_NO_ERROR) + { + System.err.println("woooh second error too! "+ err); + err = gl.glGetError(); + if (err != GL2ES2.GL_NO_ERROR) + { + System.err.println("woooh third error too! "+ err); + } + }*/ + } + } + } + + // The native method that sets this ctx to be the current one + @Override + boolean useCtx(Context ctx, Drawable drawable) + { + if (!NEVER_RELEASE_CONTEXT || !currently_current) + { + if (VERBOSE) + System.err.println("JoglPipeline.useCtx()**********************************"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.useCtx++; + + GLContext context = context(ctx); + + if (context.getGLDrawable() == null) + System.out.println("context.getGLDrawable() == null!"); + + currently_current = true; + int res = context.makeCurrent(); + return (res != GLContext.CONTEXT_NOT_CURRENT); + } + return true; + } + + //only used for NEVER_RELEASE_CONTEXT, just to spot first call + public static boolean currently_current = false; + + // Optionally release the context. Returns true if the context was released. + @Override + boolean releaseCtx(Context ctx) + { + if (!NEVER_RELEASE_CONTEXT) + { + if (VERBOSE) + System.err.println("JoglPipeline.releaseCtx()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.releaseCtx++; + GLContext context = context(ctx); + + if (context.isCurrent()) + context.release(); + } + return true; + } + + // --------------------------------------------------------------------- + + // + // MasterControl methods + // + + // Maximum lights supported by the native API + @Override + int getMaximumLights() + { + if (VERBOSE) + System.err.println("JoglPipeline.getMaximumLights()"); + + // FIXME: this isn't quite what the NativePipeline returns but + // is probably close enough + return 8; + } + + // This is the native for reading the image from the offscreen buffer + @Override + void readOffScreenBuffer(Canvas3D cv, Context ctx, int format, int dataType, Object data, int width, int height) + { + if (VERBOSE) + System.err.println("JoglPipeline.readOffScreenBuffer()"); + + GLDrawable glDrawable = ((JoglDrawable) cv.drawable).getGLDrawable(); + GLCapabilitiesImmutable chosenCaps = glDrawable.getChosenGLCapabilities(); + GLFBODrawable fboDrawable = null; + + GL2ES2 gl = context(ctx).getGL().getGL2ES2(); + + // If FBO + if (chosenCaps.isFBO()) + { + + fboDrawable = (GLFBODrawable) glDrawable; + + if (chosenCaps.getDoubleBuffered()) + { + // swap = resolve multisampling or flip back/front FBO + fboDrawable.swapBuffers(); + // unbind texture render target, we read from FBO + gl.glBindTexture(GL.GL_TEXTURE_2D, 0); + } + + // bind FBO for reading pixel data + // GL_FRONT = SamplingSinkFBO if double buffered and multisampled + // GL_FRONT if double buffered ( = GL_BAck before swap was called) + // GL_FRONT = GL_BACK if single buffered (single FBO) + + fboDrawable.getFBObject(GL.GL_FRONT).bind(gl); + } + // else pbuffer + + //gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width); + gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1); + + int type = 0; + + if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) + || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) + { + + switch (format) + { + // GL_BGR + case ImageComponentRetained.TYPE_BYTE_BGR: + type = GL2.GL_BGR;// not ok + break; + case ImageComponentRetained.TYPE_BYTE_RGB: + type = GL.GL_RGB;//ok + break; + // GL_ABGR_EXT + case ImageComponentRetained.TYPE_BYTE_ABGR: + if (isExtensionAvailable.GL_EXT_abgr(gl)) + { // If false, should never come here! + type = GL2.GL_ABGR_EXT; //ok + } + else + { + assert false; + return; + } + break; + case ImageComponentRetained.TYPE_BYTE_RGBA: + type = GL.GL_RGBA;// this a valid case for GL2ES2 + break; + + /* + * This method only supports 3 and 4 components formats and BYTE + * types. + */ + case ImageComponentRetained.TYPE_BYTE_LA: + case ImageComponentRetained.TYPE_BYTE_GRAY: + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_INT_BGR: + case ImageComponentRetained.TYPE_INT_RGB: + case ImageComponentRetained.TYPE_INT_ARGB: + default: + throw new AssertionError("illegal format " + format); + } + + ByteBuffer buf = null; + if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) + { + buf = ByteBuffer.wrap((byte[]) data); + } + else + { + buf = (ByteBuffer) data; + } + + gl.glReadPixels(0, 0, width, height, type, GL.GL_UNSIGNED_BYTE, buf); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) + || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) + { + switch (format) + { + // GL_BGR + case ImageComponentRetained.TYPE_INT_BGR: + type = GL2.GL_BGR;// not ok + break; + case ImageComponentRetained.TYPE_INT_RGB: + type = GL.GL_RGB;//ok + break; + case ImageComponentRetained.TYPE_INT_ARGB: + type = GL.GL_RGBA;// this a valid case for GL2ES2 + break; + + /* + * This method only supports 3 and 4 components formats and INT + * types. + */ + case ImageComponentRetained.TYPE_BYTE_LA: + case ImageComponentRetained.TYPE_BYTE_GRAY: + case ImageComponentRetained.TYPE_USHORT_GRAY: + case ImageComponentRetained.TYPE_BYTE_BGR: + case ImageComponentRetained.TYPE_BYTE_RGB: + case ImageComponentRetained.TYPE_BYTE_RGBA: + default: + throw new AssertionError("illegal format " + format); + } + + IntBuffer buf = null; + if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) + { + buf = IntBuffer.wrap((int[]) data); + } + else + { + buf = (IntBuffer) data; + } + + gl.glReadPixels(0, 0, width, height, type, GL.GL_UNSIGNED_BYTE, buf); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + } + else + { + throw new AssertionError("illegal image data type " + dataType + " Try creating a BufferedImage of type TYPE_3BYTE_BGR"); + } + + // If FBO + if (chosenCaps.isFBO()) + { + // bind FBO for drawing + fboDrawable.getFBObject(GL.GL_BACK).bind(gl); + } + } + + // ----------------------- Below here are initialization methods + + // Number of milliseconds to wait for windows to pop up on screen + private static final int WAIT_TIME = 1000; + // Configurable constant just in case we want to change this later + private static final int MIN_FRAME_SIZE = 1; + + private GLProfile profile; + + private Object mainThreadContext; // Fix for Bug 983 + + // Fix for Bug 983 + private void checkAppContext() + { + if (mainThreadContext == null) + return; + + try + { + // Check by reflection that sun.awt.AppContext.getAppContext() + // doesn't return null + // (required by ImageIO.write() and other JMF internal calls) to + // apply workaround proposed at + // http://stackoverflow.com/questions/17223304/appcontext-is-null-from-rmi-thread-with-java-7-update-25 + final Class<?> appContextClass = Class.forName("sun.awt.AppContext"); + if (appContextClass.getMethod("getAppContext").invoke(null) == null) + { + final Field field = appContextClass.getDeclaredField("threadGroup2appContext"); + field.setAccessible(true); + final Map threadGroup2appContext = (Map) field.get(null); + final ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup(); + threadGroup2appContext.put(currentThreadGroup, mainThreadContext); + } + } + catch (Throwable ex) + { + // Let's consider app context is not necessary for the program + } + // Don't need mainThreadContext anymore + mainThreadContext = null; + } + + // This is the native method for creating the underlying graphics context. + @Override + Context createNewContext(Canvas3D cv, Drawable drawable, Context shareCtx, boolean isSharedCtx, boolean offScreen) + { + if (VERBOSE) + System.err.println("JoglPipeline.createNewContext()"); + + checkAppContext(); + GLDrawable glDrawable = null; + GLContext glContext = null; + + if (offScreen) + { + glDrawable = drawable(cv.drawable); // cv.drawable != null, set in + // 'createOffScreenBuffer' + glContext = glDrawable.createContext(context(shareCtx)); + } + else + { + // determined in 'getBestConfiguration' + GraphicsConfigInfo gcInf0 = Canvas3D.graphicsConfigTable.get(cv.graphicsConfiguration); + AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) gcInf0.getPrivateData(); + + // JAWTWindow + JAWTWindow nativeWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(cv, awtConfig); + nativeWindow.lockSurface(); + try + { + glDrawable = GLDrawableFactory.getFactory(profile).createGLDrawable(nativeWindow); + glContext = glDrawable.createContext(context(shareCtx)); + } + finally + { + nativeWindow.unlockSurface(); + } + + cv.drawable = new JoglDrawable(glDrawable, nativeWindow); + } + + // assuming that this only gets called after addNotify has been called + if (!glDrawable.isRealized()) + glDrawable.setRealized(true); + + // Apparently we are supposed to make the context current at this point + // and set up a bunch of properties + + // Work around for some low end graphics driver bug, such as Intel + // Chipset. + // Issue 324 : Lockup J3D program and throw exception using JOGL + // renderer + boolean failed = false; + int failCount = 0; + int MAX_FAIL_COUNT = 5; + do + { + failed = false; + int res = glContext.makeCurrent(); + if (res == GLContext.CONTEXT_NOT_CURRENT) + { + // System.err.println("makeCurrent fail : " + failCount); + failed = true; + ++failCount; + try + { + Thread.sleep(100); + } + catch (InterruptedException e) + { + } + } + } + while (failed && (failCount < MAX_FAIL_COUNT)); + + if (failCount == MAX_FAIL_COUNT) + { + throw new IllegalRenderingStateException("Unable to make new context current after " + failCount + "tries"); + } + + GL2ES2 gl = glContext.getGL().getGL2ES2(); + + Jogl2es2Context ctx = new Jogl2es2Context(glContext); + + try + { + if (!getPropertiesFromCurrentContext(ctx, gl)) + { + throw new IllegalRenderingStateException("Unable to fetch properties from current OpenGL context"); + } + + if (!isSharedCtx) + { + // Set up fields in Canvas3D + setupCanvasProperties(cv, ctx, gl); + } + + // Enable rescale normal + // gl.glEnable(GL2.GL_RESCALE_NORMAL); + + // gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE); + gl.glDepthFunc(GL.GL_LEQUAL); + // gl.glEnable(GL2.GL_COLOR_MATERIAL); + + /* + * OpenGL specs: glReadBuffer specifies a color buffer as the source + * for subsequent glReadPixels. This source mode is initially + * GL_FRONT in single-buffered and GL_BACK in double-buffered + * configurations. + * + * We leave this mode unchanged in on-screen rendering and adjust it + * in off-screen rendering. See below. + */ + // gl.glReadBuffer(GL_FRONT); // off window, default for + // single-buffered non-stereo window + + // Issue 417: JOGL: Mip-mapped NPOT textures rendered incorrectly + // J3D images are aligned to 1 byte + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); + + // Workaround for issue 400: Enable separate specular by default + // gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, + // GL2.GL_SEPARATE_SPECULAR_COLOR); + + // Mac OS X / JRE 7 : onscreen rendering = offscreen rendering + // bind FBO + if (!offScreen && glDrawable instanceof GLFBODrawable) + { + GLFBODrawable fboDrawable = (GLFBODrawable) glDrawable; + // bind GLFBODrawable's drawing FBObject + // GL_BACK returns the correct FBOObject for single/double + // buffering, incl. multisampling + fboDrawable.getFBObject(GL.GL_BACK).bind(gl); + } + + // FBO or pbuffer + if (offScreen) + { + + // Final caps + GLCapabilitiesImmutable chosenCaps = glDrawable.getChosenGLCapabilities(); + + // FBO + if (glDrawable instanceof GLFBODrawable) + { + GLFBODrawable fboDrawable = (GLFBODrawable) glDrawable; + // bind GLFBODrawable's drawing FBObject + // GL_BACK returns the correct FBOObject for single/double + // buffering, incl. multisampling + fboDrawable.getFBObject(GL.GL_BACK).bind(gl); + } + // pbuffer + else + { + // Double buffering: read from back buffer, as we don't swap + // Even this setting is identical to the initially mode it + // is set explicitly + /* + * if (chosenCaps.getDoubleBuffered()) { + * gl.glReadBuffer(GL.GL_BACK); } else { + * gl.glReadBuffer(GL.GL_FRONT); } + */ + } + } + } + finally + { + glContext.release(); + } + + return ctx; + } + + @Override + void createQueryContext(Canvas3D cv, Drawable drawable, boolean offScreen, int width, int height) + { + if (VERBOSE) + System.err.println("JoglPipeline.createQueryContext()"); + + // Assumes createQueryContext is never called for a drawable != null + + if (offScreen) + { + + Drawable offDrawable = createOffScreenBuffer(cv, null, width, height); + + GLDrawable glDrawable = drawable(offDrawable); + + glDrawable.setRealized(true); + + GLContext glContext = glDrawable.createContext(null); + glContext.makeCurrent(); + + Jogl2es2Context ctx = new Jogl2es2Context(glContext); + + GL2ES2 gl = glContext.getGL().getGL2ES2(); + + // get current context properties + getPropertiesFromCurrentContext(ctx, gl); + // Set up fields in Canvas3D + setupCanvasProperties(cv, ctx, gl); + + // Done ! + + glContext.release(); + glContext.destroy(); + glDrawable.setRealized(false); + } + else + { + + // TODO can't find an implementation which avoids the use of + // QueryCanvas + // JOGL requires a visible Frame for an onscreen context + Frame f = new Frame(); + Dialog d = new Dialog(f); + d.setUndecorated(true); + d.setLayout(new BorderLayout()); + + ContextQuerier querier = new ContextQuerier(cv); + + AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) Canvas3D.graphicsConfigTable.get(cv.graphicsConfiguration) + .getPrivateData(); + + QueryCanvas canvas = new QueryCanvas(awtConfig, querier); + + d.add(canvas, BorderLayout.CENTER); + d.setSize(MIN_FRAME_SIZE, MIN_FRAME_SIZE); + d.setVisible(true); + canvas.doQuery(); + // Attempt to wait for the frame to become visible, but don't block + // the EDT + if (!EventQueue.isDispatchThread()) + { + synchronized (querier) + { + if (!querier.done()) + { + try + { + querier.wait(WAIT_TIME); + } + catch (InterruptedException e) + { + } + } + } + } + + disposeOnEDT(d); + disposeOnEDT(f); + } + } + + //Offscreen rendering methods below ----------------------- + static boolean isOffscreenLayerSurfaceEnabled(Canvas3D cv) + { + if (cv.drawable == null || cv.offScreen) + return false; + + JoglDrawable joglDrawble = (JoglDrawable) cv.drawable; + if (joglDrawble.getNativeWindow() instanceof OffscreenLayerOption) + { + OffscreenLayerOption olo = (OffscreenLayerOption) joglDrawble.getNativeWindow(); + if (olo == null) + return false; + else + return olo.isOffscreenLayerSurfaceEnabled(); + } + return false; + } + + static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) + { + if (!(jdraw.getGLDrawable() instanceof GLFBODrawable)) + return false; + + FBObject fboBack = ((GLFBODrawable) jdraw.getGLDrawable()).getFBObject(GL.GL_BACK); + if (fboBack == null) + return false; + + return (width != fboBack.getWidth() || height != fboBack.getHeight()); + } + + // Mac/JRE 7; called from Renderer when resizing is detected + // Implementation follows the approach in + // jogamp.opengl.GLDrawableHelper.resizeOffscreenDrawable(..) + @Override + void resizeOffscreenLayer(Canvas3D cv, int cvWidth, int cvHeight) + { + if (!isOffscreenLayerSurfaceEnabled(cv)) + return; + + JoglDrawable joglDrawable = (JoglDrawable) cv.drawable; + if (!hasFBObjectSizeChanged(joglDrawable, cvWidth, cvHeight)) + return; + + int newWidth = Math.max(1, cvWidth); + int newHeight = Math.max(1, cvHeight); + + GLDrawable glDrawble = joglDrawable.getGLDrawable(); + GLContext glContext = context(cv.ctx); + + // Assuming glContext != null + + final NativeSurface surface = glDrawble.getNativeSurface(); + final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface) surface : null; + + final int lockRes = surface.lockSurface(); + + try + { + // propagate new size - seems not relevant here + if (proxySurface != null) + { + final UpstreamSurfaceHook ush = proxySurface.getUpstreamSurfaceHook(); + if (ush instanceof UpstreamSurfaceHook.MutableSize) + { + ((UpstreamSurfaceHook.MutableSize) ush).setSurfaceSize(newWidth, newHeight); + } + } + /* + else if(DEBUG) { + // we have to assume surface contains the new size already, hence size check @ bottom + System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen surface n.a. ProxySurface, but " + +ns.getClass().getName()+": "+ns); } + */ + + GL2ES2 gl = glContext.getGL().getGL2ES2(); + + // FBO : should be the default case on Mac OS X + if (glDrawble instanceof GLFBODrawable) + { + + // Resize GLFBODrawable + // TODO msaa gets lost + // ((GLFBODrawable)glDrawble).resetSize(gl); + + // Alternative: resize GL_BACK FBObject directly, + // if multisampled the FBO sink (GL_FRONT) will be resized + // before the swap is executed + int numSamples = ((GLFBODrawable) glDrawble).getChosenGLCapabilities().getNumSamples(); + FBObject fboObjectBack = ((GLFBODrawable) glDrawble).getFBObject(GL.GL_BACK); + fboObjectBack.reset(gl, newWidth, newHeight, numSamples/* , false */); // false = don't reset + // SamplingSinkFBO + // immediately + fboObjectBack.bind(gl); + + // If double buffered without antialiasing the GL_FRONT FBObject + // will be resized by glDrawble after the next swap-call + } + // pbuffer - not tested because Mac OS X 10.7+ supports FBO + else + { + // Create new GLDrawable (pbuffer) and update the coresponding + // GLContext + + final GLContext currentContext = GLContext.getCurrent(); + final GLDrawableFactory factory = glDrawble.getFactory(); + + // Ensure to sync GL command stream + if (currentContext != glContext) + { + glContext.makeCurrent(); + } + gl.glFinish(); + glContext.release(); + + if (proxySurface != null) + { + proxySurface.enableUpstreamSurfaceHookLifecycle(false); + } + + try + { + glDrawble.setRealized(false); + // New GLDrawable + glDrawble = factory.createGLDrawable(surface); + glDrawble.setRealized(true); + + joglDrawable.setGLDrawable(glDrawble); + } + finally + { + if (proxySurface != null) + { + proxySurface.enableUpstreamSurfaceHookLifecycle(true); + } + } + + glContext.setGLDrawable(glDrawble, true); // re-association + + // make current last current context + if (currentContext != null) + { + currentContext.makeCurrent(); + } + } + } + finally + { + surface.unlockSurface(); + } + } + + // This is the native for creating an offscreen buffer + @Override + Drawable createOffScreenBuffer(Canvas3D cv, Context ctx, int width, int height) + { + + //OK general problem, 2 calls to setOffscreen buffer o a canvas3d will call this method once, attaching a + // a new drawable all good, but + // will then call makeNewContext twice using that same drawable, and that drawable doesn't like make current called twice + + if (VERBOSE) + System.err.println("JoglPipeline.createOffScreenBuffer()"); + + // ctx unused, doesn't exist yet + + // Offscreen Canvas3D's JoglGraphicsConfiguration + JoglGraphicsConfiguration jgc = (JoglGraphicsConfiguration) cv.graphicsConfiguration; + + // Retrieve the offscreen Canvas3D's GraphicsConfigInfo + GraphicsConfigInfo gcInf0 = Canvas3D.graphicsConfigTable.get(jgc); + + // Offscreen Canvas3D's graphics configuration, determined in + // 'getBestConfiguration' + AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) gcInf0.getPrivateData(); + + // TODO Offscreen Canvas3D's graphics devise, determined in + // 'getBestConfiguration' + // AbstractGraphicsDevice device = awtConfig.getScreen().getDevice(); // + // throws exception + // Alternative: default graphics device + AbstractGraphicsDevice device = GLDrawableFactory.getDesktopFactory().getDefaultDevice(); + + // Offscreen Canvas3D's capabilites, determined in + // 'getBestConfiguration' + GLCapabilities canvasCaps = (GLCapabilities) awtConfig.getChosenCapabilities(); + + // For further investigations : the user's GraphicsConfigTemplate3D (not + // used yet) + GraphicsConfigTemplate3D gct3D = gcInf0.getGraphicsConfigTemplate3D(); + + // Assuming that the offscreen drawable will/can support the chosen + // GLCapabilities + // of the offscreen Canvas3D + + final GLCapabilities offCaps = new GLCapabilities(profile); + offCaps.copyFrom(canvasCaps); + + // double bufffering only if scene antialiasing is required/preferred + // and supported + if (offCaps.getSampleBuffers() == false) + { + offCaps.setDoubleBuffered(false); + offCaps.setNumSamples(0); + } + + // Never stereo + offCaps.setStereo(false); + + // Set preferred offscreen drawable : framebuffer object (FBO) or + // pbuffer + offCaps.setFBO(true); // switches to pbuffer if FBO is not supported + // caps.setPBuffer(true); + + // !! a 'null' capability chooser; JOGL doesn't call a chooser for + // offscreen drawable + + // If FBO : 'offDrawable' is of type com.jogamp.opengl.GLFBODrawable + GLDrawable offDrawable = GLDrawableFactory.getFactory(profile).createOffscreenDrawable(device, offCaps, null, width, height); + + // !! these chosen caps are not final as long as the corresponding + // context is made current + // System.out.println("createOffScreenBuffer chosenCaps = " + + // offDrawable.getChosenGLCapabilities()); + + return new JoglDrawable(offDrawable, null); + } + + // 'destroyContext' is called first if context exists + @Override + void destroyOffScreenBuffer(Canvas3D cv, Context ctx, Drawable drawable) + { + if (VERBOSE) + System.err.println("JoglPipeline.destroyOffScreenBuffer()"); + + // it is done in 'destroyContext' + } + + + // Setup the full scene antialising in D3D and ogl when GL_ARB_multisamle supported + @Override + // looks like one time call in renderer.doWork + void setFullSceneAntialiasing(Context ctx, boolean enable) + { + if (VERBOSE) + System.err.println("JoglPipeline.setFullSceneAntialiasing()"); + if (OUTPUT_PER_FRAME_STATS) + ((Jogl2es2Context) ctx).perFrameStats.setFullSceneAntialiasing++; + + JoglContext joglctx = (JoglContext) ctx; + GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2(); + // not supported in ES2, possibly just part of context generally + // http://stackoverflow.com/questions/27035893/antialiasing-in-opengl-es-2-0 + // FIXME: This is working under GL2ES2 but will need to change I think + // https://github.com/adrian110288/gdc2011-android-opengl/blob/master/src/com/example/gdc11/GDC11Activity.java + + if (joglctx.getHasMultisample() && !VirtualUniverse.mc.implicitAntialiasing) + { + if (enable) + { + System.out.println("I just set MULTISAMPLE just then"); + gl.glEnable(GL2ES2.GL_MULTISAMPLE); + } + else + { + gl.glDisable(GL2ES2.GL_MULTISAMPLE); + } + } + } + + // Native method to update separate specular color control + // looks like a one time call at the start of renderer.doWork + @Override + void updateSeparateSpecularColorEnable(Context ctx, boolean enable) + { + if (VERBOSE) + System.err.println("JoglPipeline.updateSeparateSpecularColorEnable()"); + + /* GL2 gl = context(ctx).getGL().getGL2(); + //GL2ES2 gl = context(ctx).getGL().getGL2ES2(); + // bound to be not supported as definately shader work now + + if (enable) + { + gl.glLightModeli(GL2ES2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2ES2.GL_SEPARATE_SPECULAR_COLOR); + } + else + { + gl.glLightModeli(GL2ES2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2ES2.GL_SINGLE_COLOR); + }*/ + } + + // --------------------------------------------------------------------- + + // + // Canvas3D methods - native wrappers + // + + @Override + void destroyContext(Drawable drawable, Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.destroyContext()"); + + JoglDrawable joglDrawable = (JoglDrawable) drawable; + GLContext context = context(ctx); + + // google below and see its a bug on marshmallow + // 04-19 00:33:36.941 18278-18322/com.ingenieur.ese.eseandroid E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb8dc6060 + // 04-19 00:33:37.182 18278-18278/com.ingenieur.ese.eseandroid D/JogAmp.NEWT: onStop.0 + + // after this a restart and a swapBuffers call + // gl_window.getDelegatedDrawable().swapBuffers(); + // gets a + // com.jogamp.opengl.GLException: Error swapping buffers, eglError 0x300d, jogamp.opengl.egl.EGLDrawable[realized true, + + if (joglDrawable != null) + { + if (GLContext.getCurrent() == context) + { + context.release(); + } + context.destroy(); + + // assuming this is the right point at which to make this call + joglDrawable.getGLDrawable().setRealized(false); + + joglDrawable.destroyNativeWindow(); + } + } + + // This is the native method for getting the number of lights the underlying + // native library can support. + @Override + int getNumCtxLights(Context ctx) + { + if (VERBOSE) + System.err.println("JoglPipeline.getNumCtxLights()"); + + /* GL2ES2 gl = context(ctx).getGL().getGL2ES2(); + int[] res = new int[1]; + gl.glGetIntegerv(GL2ES2.GL_MAX_LIGHTS, res, 0); + return res[0];*/ + + // lights are now me! this is not called anyway + return 8; + } + + // True under Solaris, + // False under windows when display mode <= 8 bit + @Override + // probably pointless? + boolean validGraphicsMode() + { + if (VERBOSE) + System.err.println("JoglPipeline.validGraphicsMode()"); + + // FIXME: believe this should do exactly what the native code + // used to, but not 100% sure (also in theory should only run + // this code on the Windows platform? What about Mac OS X?) + /* DisplayMode currentMode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode(); + // Note: on X11 platforms, a bit depth < 0 simply indicates that + // multiple visuals are supported on the current display mode + + if (VERBOSE) + System.err.println(" Returning " + (currentMode.getBitDepth() < 0 || currentMode.getBitDepth() > 8)); + + return (currentMode.getBitDepth() < 0 || currentMode.getBitDepth() > 8);*/ + + return true; + } + + // Native method for eye lighting + @Override + void ctxUpdateEyeLightingEnable(Context ctx, boolean localEyeLightingEnable) + { + if (VERBOSE) + System.err.println("JoglPipeline.ctxUpdateEyeLightingEnable()"); + + // lighting is entirely in shaders now so this should affect nothing? + + /* GL2 gl = context(ctx).getGL().getGL2(); + //GL2ES2 gl = context(ctx).getGL().getGL2ES2(); + + if (localEyeLightingEnable) + { + gl.glLightModeli(GL2ES2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL2ES2.GL_TRUE); + } + else + { + gl.glLightModeli(GL2ES2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL2ES2.GL_FALSE); + }*/ + } + // --------------------------------------------------------------------- + + // + // DrawingSurfaceObject methods + // + + // Method to construct a new DrawingSurfaceObject + @Override + DrawingSurfaceObject createDrawingSurfaceObject(Canvas3D cv) + { + if (VERBOSE) + System.err.println("JoglPipeline.createDrawingSurfaceObject()"); + return new JoglDrawingSurfaceObject(cv); + } + + // Method to free the drawing surface object + @Override + // NOOP + void freeDrawingSurface(Canvas3D cv, DrawingSurfaceObject drawingSurfaceObject) + { + if (VERBOSE) + System.err.println("JoglPipeline.freeDrawingSurface()"); + // This method is a no-op + } + + // Method to free the native drawing surface object + @Override + // NOOP + void freeDrawingSurfaceNative(Object o) + { + if (VERBOSE) + System.err.println("JoglPipeline.freeDrawingSurfaceNative()"); + // This method is a no-op + } + + // ---------------------------------------------------------------------- + // Context-related routines + // + + // Helper used everywhere + // USED heaps + private static GLContext context(Context ctx) + { + if (ctx == null) + return null; + return ((JoglContext) ctx).getGLContext(); + } + + // Helper used everywhere + // USED a small amount + private static GLDrawable drawable(Drawable drawable) + { + if (drawable == null) + return null; + return ((JoglDrawable) drawable).getGLDrawable(); + } + + // ---------------------------------------------------------------------- + // General helper routines + // + private static ThreadLocal<ShortBuffer> nioIndexTemp = new ThreadLocal<ShortBuffer>(); + private static ThreadLocal<FloatBuffer> nioVertexTemp = new ThreadLocal<FloatBuffer>(); + private static ThreadLocal<DoubleBuffer> nioVertexDoubleTemp = new ThreadLocal<DoubleBuffer>(); + private static ThreadLocal<FloatBuffer> nioColorTemp = new ThreadLocal<FloatBuffer>(); + private static ThreadLocal<ByteBuffer> nioColorByteTemp = new ThreadLocal<ByteBuffer>(); + private static ThreadLocal<FloatBuffer> nioNormalTemp = new ThreadLocal<FloatBuffer>(); + private static ThreadLocal<FloatBuffer[]> nioTexCoordSetTemp = new ThreadLocal<FloatBuffer[]>(); + private static ThreadLocal<FloatBuffer[]> nioVertexAttrSetTemp = new ThreadLocal<FloatBuffer[]>(); + + // I think these are not used often as nio buffers sort it out + // but they are used a bit mind you + + private static ShortBuffer getIndexArrayBuffer(int[] indexArray) + { + return getIndexArrayBuffer(indexArray, true); + } + + private static ShortBuffer getIndexArrayBuffer(int[] indexArray, boolean copyData) + { + return getNIOBuffer(indexArray, nioIndexTemp, copyData); + } + + private static FloatBuffer getVertexArrayBuffer(float[] vertexArray) + { + return getVertexArrayBuffer(vertexArray, true); + } + + private static FloatBuffer getVertexArrayBuffer(float[] vertexArray, boolean copyData) + { + return getNIOBuffer(vertexArray, nioVertexTemp, copyData); + } + + private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray) + { + return getVertexArrayBuffer(vertexArray, true); + } + + private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray, boolean copyData) + { + return getNIOBuffer(vertexArray, nioVertexDoubleTemp, true); + } + + private static FloatBuffer getColorArrayBuffer(float[] colorArray) + { + return getColorArrayBuffer(colorArray, true); + } + + private static FloatBuffer getColorArrayBuffer(float[] colorArray, boolean copyData) + { + return getNIOBuffer(colorArray, nioColorTemp, true); + } + + private static ByteBuffer getColorArrayBuffer(byte[] colorArray) + { + return getColorArrayBuffer(colorArray, true); + } + + private static ByteBuffer getColorArrayBuffer(byte[] colorArray, boolean copyData) + { + return getNIOBuffer(colorArray, nioColorByteTemp, true); + } + + private static FloatBuffer getNormalArrayBuffer(float[] normalArray) + { + return getNormalArrayBuffer(normalArray, true); + } + + private static FloatBuffer getNormalArrayBuffer(float[] normalArray, boolean copyData) + { + return getNIOBuffer(normalArray, nioNormalTemp, true); + } + + private static FloatBuffer[] getTexCoordSetBuffer(Object[] texCoordSet) + { + return getNIOBuffer(texCoordSet, nioTexCoordSetTemp); + } + + private static FloatBuffer[] getVertexAttrSetBuffer(Object[] vertexAttrSet) + { + return getNIOBuffer(vertexAttrSet, nioVertexAttrSetTemp); + } + + //NOTE! int array copied, ShortBuffer returned + private static ShortBuffer getNIOBuffer(int[] array, ThreadLocal<ShortBuffer> threadLocal, boolean copyData) + { + if (array == null) + { + return null; + } + ShortBuffer buf = threadLocal.get(); + if (buf == null) + { + buf = Buffers.newDirectShortBuffer(array.length); + threadLocal.set(buf); + } + else + { + buf.rewind(); + if (buf.remaining() < array.length) + { + int newSize = Math.max(2 * buf.remaining(), array.length); + buf = Buffers.newDirectShortBuffer(newSize); + threadLocal.set(buf); + } + } + if (copyData) + { + //NOTE! int array copied + short[] shorts = new short[array.length]; + for(int i=0;i<array.length;i++) + shorts[i] = (short)array[i]; + + buf.put(shorts); + buf.rewind(); + buf.limit(array.length); + } + return buf; + } + + private static FloatBuffer getNIOBuffer(float[] array, ThreadLocal<FloatBuffer> threadLocal, boolean copyData) + { + if (array == null) + { + return null; + } + FloatBuffer buf = threadLocal.get(); + if (buf == null) + { + buf = Buffers.newDirectFloatBuffer(array.length); + threadLocal.set(buf); + } + else + { + buf.rewind(); + if (buf.remaining() < array.length) + { + int newSize = Math.max(2 * buf.remaining(), array.length); + buf = Buffers.newDirectFloatBuffer(newSize); + threadLocal.set(buf); + } + } + if (copyData) + { + buf.put(array); + buf.rewind(); + buf.limit(array.length); + } + return buf; + } + + private static DoubleBuffer getNIOBuffer(double[] array, ThreadLocal<DoubleBuffer> threadLocal, boolean copyData) + { + if (array == null) + { + return null; + } + DoubleBuffer buf = threadLocal.get(); + if (buf == null) + { + buf = Buffers.newDirectDoubleBuffer(array.length); + threadLocal.set(buf); + } + else + { + buf.rewind(); + if (buf.remaining() < array.length) + { + int newSize = Math.max(2 * buf.remaining(), array.length); + buf = Buffers.newDirectDoubleBuffer(newSize); + threadLocal.set(buf); + } + } + if (copyData) + { + buf.put(array); + buf.rewind(); + buf.limit(array.length); + } + return buf; + } + + private static ByteBuffer getNIOBuffer(byte[] array, ThreadLocal<ByteBuffer> threadLocal, boolean copyData) + { + if (array == null) + { + return null; + } + ByteBuffer buf = threadLocal.get(); + if (buf == null) + { + buf = Buffers.newDirectByteBuffer(array.length); + threadLocal.set(buf); + } + else + { + buf.rewind(); + if (buf.remaining() < array.length) + { + int newSize = Math.max(2 * buf.remaining(), array.length); + buf = Buffers.newDirectByteBuffer(newSize); + threadLocal.set(buf); + } + } + if (copyData) + { + buf.put(array); + buf.rewind(); + buf.limit(array.length); + } + return buf; + } + + private static FloatBuffer[] getNIOBuffer(Object[] array, ThreadLocal<FloatBuffer[]> threadLocal) + { + if (array == null) + { + return null; + } + FloatBuffer[] bufs = threadLocal.get(); + + // First resize array of FloatBuffers + if (bufs == null) + { + bufs = new FloatBuffer[array.length]; + threadLocal.set(bufs); + } + else if (bufs.length < array.length) + { + FloatBuffer[] newBufs = new FloatBuffer[array.length]; + System.arraycopy(bufs, 0, newBufs, 0, bufs.length); + bufs = newBufs; + threadLocal.set(bufs); + } + + // Now go down array of arrays, converting each into a direct FloatBuffer + for (int i = 0; i < array.length; i++) + { + float[] cur = (float[]) array[i]; + FloatBuffer buf = bufs[i]; + if (buf == null) + { + buf = Buffers.newDirectFloatBuffer(cur.length); + bufs[i] = buf; + } + else + { + buf.rewind(); + if (buf.remaining() < cur.length) + { + int newSize = Math.max(2 * buf.remaining(), cur.length); + buf = Buffers.newDirectFloatBuffer(newSize); + bufs[i] = buf; + } + } + buf.put(cur); + buf.rewind(); + buf.limit(cur.length); + } + + return bufs; + } + + // PJ: requesting caps is expensive, caps are unlikely to change during live + // times, so we use a variable that is lazy initialized for each + private isExtensionAvailable isExtensionAvailable = new isExtensionAvailable(); + + private class isExtensionAvailable + { + private int GL_EXT_abgr = 0; + + private boolean GL_EXT_abgr(GL2ES2 gl) + { + if (GL_EXT_abgr == 0) + GL_EXT_abgr = gl.isExtensionAvailable("GL_EXT_abgr") ? 1 : -1; + + return GL_EXT_abgr == 1; + } + + private int GL_ARB_imaging = 0; + + private boolean GL_ARB_imaging(GL2ES2 gl) + { + if (GL_ARB_imaging == 0) + GL_ARB_imaging = gl.isExtensionAvailable("GL_ARB_imaging") ? 1 : -1; + + return GL_ARB_imaging == 1; + } + + } + + // Methods to get actual capabilities from Canvas3D + @Override + boolean hasDoubleBuffer(Canvas3D cv) + { + if (VERBOSE) + System.err.println("JoglPipeline.hasDoubleBuffer()"); + if (VERBOSE) + System.err.println(" Returning " + caps(cv).getDoubleBuffered()); + return caps(cv).getDoubleBuffered(); + } + + @Override + boolean hasStereo(Canvas3D cv) + { + if (VERBOSE) + System.err.println("JoglPipeline.hasStereo()"); + if (VERBOSE) + System.err.println(" Returning " + caps(cv).getStereo()); + return caps(cv).getStereo(); + } + + @Override + int getStencilSize(Canvas3D cv) + { + if (VERBOSE) + System.err.println("JoglPipeline.getStencilSize()"); + if (VERBOSE) + System.err.println(" Returning " + caps(cv).getStencilBits()); + return caps(cv).getStencilBits(); + } + + @Override + boolean hasSceneAntialiasingMultisample(Canvas3D cv) + { + if (VERBOSE) + System.err.println("JoglPipeline.hasSceneAntialiasingMultisample()"); + if (VERBOSE) + System.err.println(" Returning " + caps(cv).getSampleBuffers()); + + return caps(cv).getSampleBuffers(); + } + + @Override + boolean hasSceneAntialiasingAccum(Canvas3D cv) + { + if (VERBOSE) + System.err.println("JoglPipeline.hasSceneAntialiasingAccum()"); + // Accum style antialiasing is gone + return false; + /*GLCapabilities caps = caps(cv); + if (VERBOSE) + System.err + .println(" Returning " + (caps.getAccumRedBits() > 0 && caps.getAccumGreenBits() > 0 && caps.getAccumBlueBits() > 0)); + return (caps.getAccumRedBits() > 0 && caps.getAccumGreenBits() > 0 && caps.getAccumBlueBits() > 0); + */ + + } + + // Used to get caps for the canvas3d + private static GLCapabilities caps(Canvas3D ctx) + { + if (ctx.drawable != null) + { + // latest state for on- and offscreen drawables + return (GLCapabilities) drawable(ctx.drawable).getChosenGLCapabilities(); + } + else + { + // state at the time of 'getBestConfiguration' + return ((JoglGraphicsConfiguration) ctx.graphicsConfiguration).getGLCapabilities(); + } + } + + // AWT AWT AWT AWT AWT AWT AWT AWT AWT + // everything below here demands or is used by awt code + // --------------------------------------------------------------------- + + // Determine whether specified graphics config is supported by pipeline + @Override + boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D gct, GraphicsConfiguration gc) + { + if (VERBOSE) + System.err.println("JoglPipeline.isGraphicsConfigSupported()"); + + // FIXME: it looks like this method is implemented incorrectly + // in the existing NativePipeline in both the Windows and X11 + // ports. According to the semantics of the javadoc, it looks + // like this method is supposed to figure out the OpenGL + // capabilities which would be requested by the passed + // GraphicsConfiguration object were it to be used, and see + // whether it is possible to create a context with them. + // Instead, on both platforms, the implementations basically set + // up a query based on the contents of the + // GraphicsConfigTemplate3D object, using the + // GraphicsConfiguration object only to figure out on which + // GraphicsDevice and screen we're making the request, and see + // whether it's possible to choose an OpenGL pixel format based + // on that information. This makes this method less useful and + // we can probably just safely return true here uniformly + // without breaking anything. + return true; + } + // + // Canvas3D / GraphicsConfigTemplate3D methods - logic dealing with + // native graphics configuration or drawing surface + // + + // Return a graphics config based on the one passed in. Note that we can + // assert that the input config is non-null and was created from a + // GraphicsConfigTemplate3D. + // This method must return a valid GraphicsConfig, or else it must throw + // an exception if one cannot be returned. + @Override + GraphicsConfiguration getGraphicsConfig(GraphicsConfiguration gconfig) + { + + if (VERBOSE) + System.err.println("JoglPipeline.getGraphicsConfig()"); + + GraphicsConfigInfo gcInf0 = Canvas3D.graphicsConfigTable.get(gconfig); + AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) gcInf0.getPrivateData(); + + return awtConfig.getAWTGraphicsConfiguration(); + } + + private enum DisabledCaps + { + STEREO, AA, DOUBLE_BUFFER, + } + + // Get best graphics config from pipeline + @Override + GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D gct, GraphicsConfiguration[] gc) + { + if (VERBOSE) + System.err.println("JoglPipeline.getBestConfiguration()"); + + //PJ this bug turns up in web start from 7u25 onwards, this fix should have been called from here from the beginning + // as getBestConfiguration calls new Component eventually where the bug surfaces + checkAppContext(); + + // Create a GLCapabilities based on the GraphicsConfigTemplate3D + final GLCapabilities caps = new GLCapabilities(profile); + + caps.setDoubleBuffered(gct.getDoubleBuffer() != GraphicsConfigTemplate.UNNECESSARY); + + caps.setStereo(gct.getStereo() != GraphicsConfigTemplate.UNNECESSARY); + + // Scene antialiasing only if double buffering + if (gct.getSceneAntialiasing() != GraphicsConfigTemplate.UNNECESSARY && gct.getDoubleBuffer() != GraphicsConfigTemplate.UNNECESSARY) + { + caps.setSampleBuffers(true); + int numSamples = MasterControl.getIntegerProperty("j3d.numSamples", 2); + caps.setNumSamples(numSamples); + } + else + { + caps.setSampleBuffers(false); + caps.setNumSamples(0); + } + + caps.setDepthBits(gct.getDepthSize()); + caps.setStencilBits(gct.getStencilSize()); + + caps.setRedBits(Math.max(5, gct.getRedSize())); + caps.setGreenBits(Math.max(5, gct.getGreenSize())); + caps.setBlueBits(Math.max(5, gct.getBlueSize())); + + // Issue 399: Request alpha buffer if transparentOffScreen is set + if (VirtualUniverse.mc.transparentOffScreen) + { + caps.setAlphaBits(1); + } + + // Add PREFERRED capabilities in order of least to highest priority and + // we will try disabling them + ArrayList<DisabledCaps> capsToDisable = new ArrayList<DisabledCaps>(); + + if (gct.getStereo() == GraphicsConfigTemplate.PREFERRED) + { + capsToDisable.add(DisabledCaps.STEREO); + } + + if (gct.getSceneAntialiasing() == GraphicsConfigTemplate.PREFERRED) + { + capsToDisable.add(DisabledCaps.AA); + } + + // if AA is required, so is double buffering. + if (gct.getSceneAntialiasing() != GraphicsConfigTemplate.REQUIRED && gct.getDoubleBuffer() == GraphicsConfigTemplate.PREFERRED) + { + capsToDisable.add(DisabledCaps.DOUBLE_BUFFER); + } + + // Pick an arbitrary graphics device. + GraphicsDevice device = gc[0].getDevice(); + AbstractGraphicsScreen screen = (device != null) ? AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT) + : AWTGraphicsScreen.createDefault(); + + // Create a Frame and dummy GLCanvas to perform eager pixel format + // selection + + // Note that we loop in similar fashion to the NativePipeline's + // native code in the situation where we need to disable certain + // capabilities which aren't required + boolean tryAgain = true; + CapabilitiesCapturer capturer = null; + AWTGraphicsConfiguration awtConfig = null; + while (tryAgain) + { + Frame f = new Frame(); + Dialog d = new Dialog(f); + d.setUndecorated(true); + d.setLayout(new BorderLayout()); + capturer = new CapabilitiesCapturer(); + try + { + awtConfig = createAwtGraphicsConfiguration(caps, capturer, screen); + QueryCanvas canvas = new QueryCanvas(awtConfig, capturer); + d.add(canvas, BorderLayout.CENTER); + d.setSize(MIN_FRAME_SIZE, MIN_FRAME_SIZE); + d.setVisible(true); + canvas.doQuery(); + if (DEBUG_CONFIG) + { + System.err.println("Waiting for CapabilitiesCapturer"); + } + // Try to wait for result without blocking EDT + if (!EventQueue.isDispatchThread()) + { + synchronized (capturer) + { + if (!capturer.done()) + { + try + { + capturer.wait(WAIT_TIME); + } + catch (InterruptedException e) + { + } + } + } + } + disposeOnEDT(d); + disposeOnEDT(f); + tryAgain = false; + } + catch (GLException e) + { + // Failure to select a pixel format; try switching off one + // of the only-preferred capabilities + if (capsToDisable.size() == 0) + { + tryAgain = false; + } + else + { + switch (capsToDisable.remove(0)) + { + case STEREO: + caps.setStereo(false); + break; + case AA: + caps.setSampleBuffers(false); + break; + case DOUBLE_BUFFER: + caps.setDoubleBuffered(false); + break; + } + awtConfig = null; + } + } + } + int chosenIndex = capturer.getChosenIndex(); + GLCapabilities chosenCaps = null; + if (chosenIndex < 0) + { + if (DEBUG_CONFIG) + { + System.err.println("CapabilitiesCapturer returned invalid index"); + } + // It's possible some platforms or implementations might not + // support the GLCapabilitiesChooser mechanism; feed in the + // same GLCapabilities later which we gave to the selector + chosenCaps = caps; + } + else + { + if (DEBUG_CONFIG) + { + System.err.println("CapabilitiesCapturer returned index=" + chosenIndex); + } + chosenCaps = capturer.getCapabilities(); + } + + // FIXME chosenIndex isn't used anymore, used -1 instead of finding it. + JoglGraphicsConfiguration config = new JoglGraphicsConfiguration(chosenCaps, chosenIndex, device); + + // FIXME: because of the fact that JoglGraphicsConfiguration + // doesn't override hashCode() or equals(), we will basically be + // creating a new one each time getBestConfiguration() is + // called; in theory, we should probably map the same + // GLCapabilities on the same GraphicsDevice to the same + // JoglGraphicsConfiguration object + + // Cache the GraphicsTemplate3D + GraphicsConfigInfo gcInf0 = new GraphicsConfigInfo(gct); + gcInf0.setPrivateData(awtConfig); + + synchronized (Canvas3D.graphicsConfigTable) + { + Canvas3D.graphicsConfigTable.put(config, gcInf0); + } + + return config; + } + + private boolean checkedForGetScreenMethod = false; + private Method getScreenMethod = null; + + @Override + // Screen3D class calls during init and that init is only called in the init + // of Canvas3D + // Notice this is using reflection on the GraphicsDevice! + int getScreen(final GraphicsDevice graphicsDevice) + { + if (VERBOSE) + System.err.println("JoglPipeline.getScreen()"); + + if (!checkedForGetScreenMethod) + { + // All of the Sun GraphicsDevice implementations have a method + // int getScreen(); + // which we want to call reflectively if it's available. + AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() + { + try + { + getScreenMethod = graphicsDevice.getClass().getDeclaredMethod("getScreen", new Class[] {}); + getScreenMethod.setAccessible(true); + } + catch (Exception e) + { + } + checkedForGetScreenMethod = true; + return null; + } + }); + } + + if (getScreenMethod != null) + { + try + { + return ((Integer) getScreenMethod.invoke(graphicsDevice, (Object[]) null)).intValue(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + return 0; + } + + // getBestConfiguration ONLY below here + // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV + // Non pipeline interface too + + // ---------------------------------------------------------------------- + // Helper classes and methods to support query context functionality + // and pixel format selection + // Used by Query Canvas apabilitiesCapturer and therefore only get best + // configuration + private interface ExtendedCapabilitiesChooser extends GLCapabilitiesChooser + { + public void init(GLContext context); + } + + // Canvas subclass to help with various query operations such as the + // "query context" mechanism and pixel format selection. + // Must defeat and simplify the single-threading behavior of JOGL's + // GLCanvas in order to be able to set up a temporary pixel format + // and OpenGL context. Apparently simply turning off the + // single-threaded mode isn't enough to do this. + + // Used by get best configuration + private final class QueryCanvas extends Canvas + { + + private GLDrawable glDrawable; + private ExtendedCapabilitiesChooser chooser; + private boolean alreadyRan; + + private AWTGraphicsConfiguration awtConfig = null; + private JAWTWindow nativeWindow = null; + + private QueryCanvas(AWTGraphicsConfiguration awtConfig, ExtendedCapabilitiesChooser chooser) + { + // The platform-specific GLDrawableFactory will only provide a + // non-null GraphicsConfiguration on platforms where this is + // necessary (currently only X11, as Windows allows the pixel + // format of the window to be set later and Mac OS X seems to + // handle this very differently than all other platforms). On + // other platforms this method returns null; it is the case (at + // least in the Sun AWT implementation) that this will result in + // equivalent behavior to calling the no-arg super() constructor + // for Canvas. + super(awtConfig.getAWTGraphicsConfiguration()); + + this.awtConfig = awtConfig; + this.chooser = chooser; + } + + @Override + public void addNotify() + { + super.addNotify(); + + nativeWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); + nativeWindow.lockSurface(); + try + { + glDrawable = GLDrawableFactory.getFactory(profile).createGLDrawable(nativeWindow); + } + finally + { + nativeWindow.unlockSurface(); + } + + glDrawable.setRealized(true); + } + + // It seems that at least on Mac OS X we need to do the OpenGL + // context-related work outside of the addNotify call because the + // Canvas hasn't been resized to a non-zero size by that point + private void doQuery() + { + if (alreadyRan) + return; + GLContext context = glDrawable.createContext(null); + int res = context.makeCurrent(); + if (res != GLContext.CONTEXT_NOT_CURRENT) + { + try + { + chooser.init(context); + } + finally + { + context.release(); + } + } + context.destroy(); + alreadyRan = true; + + glDrawable.setRealized(false); + nativeWindow.destroy(); + } + } + + // Used by get best configuration + private static AWTGraphicsConfiguration createAwtGraphicsConfiguration(GLCapabilities capabilities, CapabilitiesChooser chooser, + AbstractGraphicsScreen screen) + { + GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilities.class); + AWTGraphicsConfiguration awtGraphicsConfiguration = (AWTGraphicsConfiguration) factory.chooseGraphicsConfiguration(capabilities, + capabilities, chooser, screen, VisualIDHolder.VID_UNDEFINED); + return awtGraphicsConfiguration; + } + + // Used in conjunction with IndexCapabilitiesChooser in pixel format + // selection -- see getBestConfiguration + + // Used by getBestConfiguration + private static class CapabilitiesCapturer extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser + { + private boolean done; + private GLCapabilities capabilities; + private int chosenIndex = -1; + + public boolean done() + { + return done; + } + + public GLCapabilities getCapabilities() + { + return capabilities; + } + + public int getChosenIndex() + { + return chosenIndex; + } + + public int chooseCapabilities(GLCapabilities desired, GLCapabilities[] available, int windowSystemRecommendedChoice) + { + int res = super.chooseCapabilities(desired, Arrays.asList(available), windowSystemRecommendedChoice); + capabilities = available[res]; + chosenIndex = res; + markDone(); + return res; + } + + @Override + public void init(GLContext context) + { + // Avoid hanging things up for several seconds + kick(); + } + + private void markDone() + { + synchronized (this) + { + done = true; + notifyAll(); + } + } + + private void kick() + { + synchronized (this) + { + notifyAll(); + } + } + } + + // Used to support the query context mechanism -- needs to be more + // than just a GLCapabilitiesChooser + + // ONLY used by createQuerycontext above, hence unused + // What possibly invoked via some sort of crazy reflect, do not delete + // can't seem to get it invoked now? + private final class ContextQuerier extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser + { + private Canvas3D canvas; + private boolean done; + + public ContextQuerier(Canvas3D canvas) + { + this.canvas = canvas; + } + + public boolean done() + { + return done; + } + + @Override + public void init(GLContext context) + { + // This is basically a temporary, NOTE not JoglesContext either + JoglContext jctx = new JoglContext(context); + GL2ES2 gl = context.getGL().getGL2ES2(); + // Set up various properties + if (getPropertiesFromCurrentContext(jctx, gl)) + { + setupCanvasProperties(canvas, jctx, gl); + } + markDone(); + } + + private void markDone() + { + synchronized (this) + { + done = true; + notifyAll(); + } + } + } + + // used by getBestConfiguration above + private static void disposeOnEDT(final Window f) + { + Runnable r = new Runnable() { + @Override + public void run() + { + f.setVisible(false); + f.dispose(); + } + }; + if (!EventQueue.isDispatchThread()) + { + EventQueue.invokeLater(r); + } + else + { + r.run(); + } + } + +} diff --git a/src/javax/media/j3d/JoglContext.java b/src/main/java/org/jogamp/java3d/JoglContext.java index 718a092..fda2a33 100644 --- a/src/javax/media/j3d/JoglContext.java +++ b/src/main/java/org/jogamp/java3d/JoglContext.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.nio.Buffer; import java.nio.FloatBuffer; @@ -36,7 +36,7 @@ import com.jogamp.opengl.GLContext; * Graphics context objects for Jogl rendering pipeline. */ class JoglContext implements Context { - private GLContext context; + protected GLContext context; // Properties we need to keep track of for efficiency private int maxTexCoordSets; diff --git a/src/javax/media/j3d/JoglDrawable.java b/src/main/java/org/jogamp/java3d/JoglDrawable.java index 54c134e..efffc34 100644 --- a/src/javax/media/j3d/JoglDrawable.java +++ b/src/main/java/org/jogamp/java3d/JoglDrawable.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import com.jogamp.nativewindow.NativeWindow; import com.jogamp.opengl.GLDrawable; diff --git a/src/javax/media/j3d/JoglDrawingSurfaceObject.java b/src/main/java/org/jogamp/java3d/JoglDrawingSurfaceObject.java index 960e27a..7841e20 100644 --- a/src/javax/media/j3d/JoglDrawingSurfaceObject.java +++ b/src/main/java/org/jogamp/java3d/JoglDrawingSurfaceObject.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The DrawingSurfaceObject class is used to manage native drawing surface diff --git a/src/javax/media/j3d/JoglGraphicsConfiguration.java b/src/main/java/org/jogamp/java3d/JoglGraphicsConfiguration.java index 181dcec..4ae4a8b 100644 --- a/src/javax/media/j3d/JoglGraphicsConfiguration.java +++ b/src/main/java/org/jogamp/java3d/JoglGraphicsConfiguration.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.AWTException; import java.awt.DisplayMode; diff --git a/src/javax/media/j3d/JoglPipeline.java b/src/main/java/org/jogamp/java3d/JoglPipeline.java index 430fd3e..f386f0b 100644 --- a/src/javax/media/j3d/JoglPipeline.java +++ b/src/main/java/org/jogamp/java3d/JoglPipeline.java @@ -24,10 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.BorderLayout; import java.awt.Canvas; +import java.awt.Dialog; import java.awt.DisplayMode; import java.awt.EventQueue; import java.awt.Frame; @@ -35,6 +36,7 @@ import java.awt.GraphicsConfigTemplate; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; +import java.awt.Window; import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -52,7 +54,6 @@ import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.jogamp.common.nio.Buffers; import com.jogamp.nativewindow.AbstractGraphicsDevice; import com.jogamp.nativewindow.AbstractGraphicsScreen; import com.jogamp.nativewindow.CapabilitiesChooser; @@ -62,12 +63,7 @@ import com.jogamp.nativewindow.NativeWindowFactory; import com.jogamp.nativewindow.ProxySurface; import com.jogamp.nativewindow.UpstreamSurfaceHook; import com.jogamp.nativewindow.VisualIDHolder; -import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; -import com.jogamp.nativewindow.awt.AWTGraphicsDevice; -import com.jogamp.nativewindow.awt.AWTGraphicsScreen; -import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.opengl.DefaultGLCapabilitiesChooser; -import com.jogamp.opengl.FBObject; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2; import com.jogamp.opengl.GLCapabilities; @@ -81,6 +77,14 @@ import com.jogamp.opengl.GLFBODrawable; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.Threading; +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.Platform; +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.awt.JAWTWindow; +import com.jogamp.opengl.FBObject; + /** * Concrete implementation of Pipeline class for the JOGL rendering * pipeline. @@ -6540,39 +6544,41 @@ class JoglPipeline extends Pipeline { glDrawable.setRealized(false); } else { - ContextQuerier querier = new ContextQuerier(cv); + + ContextQuerier querier = new ContextQuerier(cv); AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration)Canvas3D.graphicsConfigTable.get(cv.graphicsConfiguration).getPrivateData(); QueryCanvas canvas = new QueryCanvas(awtConfig, querier); - // TODO can't find an implementation which avoids the use of QueryCanvas + // TODO can't find an implementation which avoids the use of QueryCanvas // JOGL requires a visible Frame for an onscreen context - - Frame f = new Frame(canvas.getGraphicsConfiguration()); - f.setUndecorated(true); - f.setLayout(new BorderLayout()); - - f.add(canvas, BorderLayout.CENTER); - f.setSize(MIN_FRAME_SIZE, MIN_FRAME_SIZE); - f.setVisible(true); - canvas.doQuery(); + Frame f = new Frame(canvas.getGraphicsConfiguration()); + Dialog d = new Dialog(f); + d.setUndecorated(true); + d.setLayout(new BorderLayout()); + + d.add(canvas, BorderLayout.CENTER); + d.setSize(MIN_FRAME_SIZE, MIN_FRAME_SIZE); + d.setVisible(true); + canvas.doQuery(); // Attempt to wait for the frame to become visible, but don't block the EDT - if (!EventQueue.isDispatchThread()) { - synchronized(querier) { - if (!querier.done()) { - try { - querier.wait(WAIT_TIME); + if (!EventQueue.isDispatchThread()) { + synchronized(querier) { + if (!querier.done()) { + try { + querier.wait(WAIT_TIME); + } + catch (InterruptedException e) { } - catch (InterruptedException e) { - } - } - } - } + } + } + } - disposeOnEDT(f); - } + disposeOnEDT(d); + disposeOnEDT(f); + } } // This is the native for creating an offscreen buffer @@ -7219,10 +7225,10 @@ void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) { GL2 gl = context(ctx).getGL().getGL2(); - if (!enableLight) { - // FIXME: Removed call to glColor4f because of segfault issues in Parallels Desktop driver - // gl.glColor4f(r, g, b, a); - } + if (!enableLight) { + // FIXME: Removed call to glColor4f because of segfault issues in Parallels Desktop driver + // gl.glColor4f(r, g, b, a); + } gl.glShadeModel(GL2.GL_SMOOTH); } @@ -7256,6 +7262,7 @@ void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) { boolean releaseCtx(Context ctx) { if (VERBOSE) System.err.println("JoglPipeline.releaseCtx()"); GLContext context = context(ctx); + if(context.isCurrent()) context.release(); return true; } @@ -7695,11 +7702,12 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - gl.glEnable(GL.GL_TEXTURE_2D); - gl.glPushAttrib(GL2.GL_TRANSFORM_BIT); - gl.glMatrixMode(GL.GL_TEXTURE); - gl.glLoadIdentity(); - gl.glPopAttrib(); + gl.glEnable(GL.GL_TEXTURE_2D); + + gl.glPushAttrib(GL2.GL_TRANSFORM_BIT); + gl.glMatrixMode(GL.GL_TEXTURE); + gl.glLoadIdentity(); + gl.glPopAttrib(); // loaded identity modelview and projection matrix gl.glMatrixMode(GL2.GL_PROJECTION); @@ -8086,6 +8094,46 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) // and cube map textures. if (major < 1 || (major == 1 && minor < 2)) { + + // In some double createNewContext uses or getPerferredConfiguration called before a Frame is constructed + // the disabling of D3D can cause this issue + // see Bug 1201 - Crash with option "sun.java2d.d3d=false" + // https://jogamp.org/bugzilla/show_bug.cgi?id=1201 + + // In the case of Java > 1.8u51 Win10 and an Intel HD2000/3000 driver, the driver will not load because + // the java.exe manifest has a "supportedOS Id" that the drivers don't like (the drivers are too old) + // see Bug 1278 - Windows 10 returns software Profile + // https://jogamp.org/bugzilla/show_bug.cgi?id=1278 + // So we will detect Win10/Oracle Jre u > 51 and offer advice to down grade jre + + if (glVendor.equalsIgnoreCase("Microsoft Corporation") && // + glRenderer.equalsIgnoreCase("GDI Generic") && // + glVersion.equalsIgnoreCase("1.1.0")) + { + System.err.println("Java3D - GDI Generic Driver use detected."); + System.err.println("This may be caused by any of the following issues."); + + if (System.getProperty("sun.java2d.noddraw", "false").equals("true") || System.getProperty("sun.java2d.d3d", "true").equals("false")) + { + System.err.println("Issue: Use of System.setProperty(\"sun.java2d.noddraw\", \"true\");"); + System.err.println("or System.setProperty(\"sun.java2d.d3d\", \"false\");"); + System.err.println("If either of these are being used please try either reversing or removing them,"); + System.err.println("or if they are required else where try adding System.setProperty(\"sun.awt.nopixfmt\", \"true\");"); + } + + if (Platform.getOSName().equalsIgnoreCase("Windows 10") && //win10 + (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version19) >= 0) || // 1.9 or 1.8 > 51 + (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version18) >= 0 && Platform.JAVA_VERSION_UPDATE > 51) && // + Platform.getJavaVMName().toLowerCase().startsWith("java hotspot(tm)"))// e.g. Java HotSpot(TM) 64-Bit Server VM ; OpenJDK would give OpenJDK 64-Bit Server VM + { + System.err.println("Issue: The use of an Intel HD2000/3000 driver in combination with Windows 10 and"); + System.err.println("a JRE greater than 1.8 update 51. Please downgrade the JRE in use to JRE 1.8u51 or lower."); + System.err.println("For more information please see https://jogamp.org/bugzilla/show_bug.cgi?id=1278."); + } + System.err.println("If this software has been supplied to you and you are unable to modify it's configuration"); + System.err.println("please contact the suppler of this software with this entire message."); + } + throw new IllegalRenderingStateException( "Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=" + major + "." + minor + ")"); @@ -8302,6 +8350,10 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) GraphicsConfiguration[] gc) { if (VERBOSE) System.err.println("JoglPipeline.getBestConfiguration()"); + //PJ this bug turns up in web start from 7u25 onwards, this fix should have been called from here from the beginning + // as getBestConfiguration calls new Component eventually where the bug surfaces + checkAppContext(); + // Create a GLCapabilities based on the GraphicsConfigTemplate3D final GLCapabilities caps = new GLCapabilities(profile); @@ -8313,8 +8365,7 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) if (gct.getSceneAntialiasing() != GraphicsConfigTemplate.UNNECESSARY && gct.getDoubleBuffer() != GraphicsConfigTemplate.UNNECESSARY) { caps.setSampleBuffers(true); - int numSamples = MasterControl.getIntegerProperty("j3d.numSamples", 2); - caps.setNumSamples(numSamples); + caps.setNumSamples(2); } else { caps.setSampleBuffers(false); caps.setNumSamples(0); @@ -8366,16 +8417,17 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) CapabilitiesCapturer capturer = null; AWTGraphicsConfiguration awtConfig = null; while (tryAgain) { - Frame f = new Frame(device.getDefaultConfiguration()); - f.setUndecorated(true); - f.setLayout(new BorderLayout()); + Frame f = new Frame(); + Dialog d = new Dialog(f, null, false, device.getDefaultConfiguration()); + d.setUndecorated(true); + d.setLayout(new BorderLayout()); capturer = new CapabilitiesCapturer(); try { awtConfig = createAwtGraphicsConfiguration(caps, capturer, screen); QueryCanvas canvas = new QueryCanvas(awtConfig, capturer); - f.add(canvas, BorderLayout.CENTER); - f.setSize(MIN_FRAME_SIZE, MIN_FRAME_SIZE); - f.setVisible(true); + d.add(canvas, BorderLayout.CENTER); + d.setSize(MIN_FRAME_SIZE, MIN_FRAME_SIZE); + d.setVisible(true); canvas.doQuery(); if (DEBUG_CONFIG) { System.err.println("Waiting for CapabilitiesCapturer"); @@ -8391,6 +8443,7 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) } } } + disposeOnEDT(d); disposeOnEDT(f); tryAgain = false; } catch (GLException e) { @@ -8728,7 +8781,7 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) } } - private void disposeOnEDT(final Frame f) { + private static void disposeOnEDT(final Window f) { Runnable r = new Runnable() { @Override public void run() { diff --git a/src/javax/media/j3d/JoglShaderObject.java b/src/main/java/org/jogamp/java3d/JoglShaderObject.java index 8f40834..f08bfee 100644 --- a/src/javax/media/j3d/JoglShaderObject.java +++ b/src/main/java/org/jogamp/java3d/JoglShaderObject.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class JoglShaderObject implements ShaderProgramId, ShaderId, ShaderAttrLoc { private int val; diff --git a/src/javax/media/j3d/LOD.java b/src/main/java/org/jogamp/java3d/LOD.java index 22b7cca..af97f7c 100644 --- a/src/javax/media/j3d/LOD.java +++ b/src/main/java/org/jogamp/java3d/LOD.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; /** @@ -101,11 +101,11 @@ public Switch getSwitch(int index) { } /** - * Returns the enumeration object of all switches. - * @return the enumeration object of all switches + * Returns the iterator object of all switches. + * @return the iterator object of all switches */ - public Enumeration getAllSwitches() { - return switches.elements(); + public Iterator<Switch> getAllSwitches() { + return switches.iterator(); } /** diff --git a/src/javax/media/j3d/Leaf.java b/src/main/java/org/jogamp/java3d/Leaf.java index f0ae9b3..4eb4605 100644 --- a/src/javax/media/j3d/Leaf.java +++ b/src/main/java/org/jogamp/java3d/Leaf.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The Leaf node is an abstract class for all scene graph nodes that diff --git a/src/javax/media/j3d/LeafRetained.java b/src/main/java/org/jogamp/java3d/LeafRetained.java index 720bf5b..4ae2297 100644 --- a/src/javax/media/j3d/LeafRetained.java +++ b/src/main/java/org/jogamp/java3d/LeafRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; /** diff --git a/src/javax/media/j3d/Light.java b/src/main/java/org/jogamp/java3d/Light.java index 7e99843..05c643c 100644 --- a/src/javax/media/j3d/Light.java +++ b/src/main/java/org/jogamp/java3d/Light.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The Light leaf node is an abstract class that defines a set of @@ -137,7 +137,7 @@ import javax.vecmath.Color3f; * nodes, defined by a Group object. This is known as "scoping." * All nodes attached to a Group node define a <i>list of scopes</i>. * Methods in the Light class permit the setting, addition, insertion, - * removal, and enumeration of nodes in the list of scopes. + * removal, and iterator of nodes in the list of scopes. * <p> * <b>Two-sided Lighting of Polygons</b> * <p> @@ -437,13 +437,13 @@ public abstract class Light extends Leaf { /** - * Returns an enumeration of this Light node's list of scopes. - * @return an Enumeration object containing all nodes in this Light node's + * Returns an iterator of this Light node's list of scopes. + * @return an Iterator object containing all nodes in this Light node's * list of scopes. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ -public Enumeration<Group> getAllScopes() { +public Iterator<Group> getAllScopes() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_SCOPE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Light8")); @@ -669,10 +669,10 @@ return ((LightRetained)this.retained).getAllScopes(); rt.initColor(c); rt.initInfluencingBounds(attr.getInfluencingBounds()); - Enumeration<Group> elm = attr.getAllScopes(); - while (elm.hasMoreElements()) { + Iterator<Group> elm = attr.getAllScopes(); + while (elm.hasNext()) { // this reference will set correctly in updateNodeReferences() callback - rt.initAddScope(elm.nextElement()); + rt.initAddScope(elm.next()); } // this reference will set correctly in updateNodeReferences() callback diff --git a/src/javax/media/j3d/LightBin.java b/src/main/java/org/jogamp/java3d/LightBin.java index 420d942..14bf38d 100644 --- a/src/javax/media/j3d/LightBin.java +++ b/src/main/java/org/jogamp/java3d/LightBin.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/LightRetained.java b/src/main/java/org/jogamp/java3d/LightRetained.java index 7780713..8001f59 100644 --- a/src/javax/media/j3d/LightRetained.java +++ b/src/main/java/org/jogamp/java3d/LightRetained.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * LightRetained is an abstract class that contains instance variable common to @@ -343,16 +343,16 @@ ArrayList<LightRetained> newlyAddedMirrorLights = new ArrayList<LightRetained>() } /** - * Returns an enumeration object of the scope - * @return an enumeration object of the scope + * Returns an iterator object of the scope + * @return an iterator object of the scope */ -Enumeration<Group> getAllScopes() { - Enumeration<GroupRetained> elm = scopes.elements(); +Iterator<Group> getAllScopes() { + Iterator<GroupRetained> elm = scopes.iterator(); Vector<Group> v = new Vector<Group>(scopes.size()); - while (elm.hasMoreElements()) { - v.add((Group)elm.nextElement().source); + while (elm.hasNext()) { + v.add((Group)elm.next().source); } - return v.elements(); + return v.iterator(); } /** diff --git a/src/javax/media/j3d/LightSet.java b/src/main/java/org/jogamp/java3d/LightSet.java index db4f065..6eb4efd 100644 --- a/src/javax/media/j3d/LightSet.java +++ b/src/main/java/org/jogamp/java3d/LightSet.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class LightSet extends Object { diff --git a/src/javax/media/j3d/LineArray.java b/src/main/java/org/jogamp/java3d/LineArray.java index 469f51a..3874794 100644 --- a/src/javax/media/j3d/LineArray.java +++ b/src/main/java/org/jogamp/java3d/LineArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/LineArrayRetained.java b/src/main/java/org/jogamp/java3d/LineArrayRetained.java index a970d96..7281d67 100644 --- a/src/javax/media/j3d/LineArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/LineArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The LineArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/LineAttributes.java b/src/main/java/org/jogamp/java3d/LineAttributes.java index d27938a..d2a5283 100644 --- a/src/javax/media/j3d/LineAttributes.java +++ b/src/main/java/org/jogamp/java3d/LineAttributes.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The LineAttributes object defines all rendering state that can be set diff --git a/src/javax/media/j3d/LineAttributesRetained.java b/src/main/java/org/jogamp/java3d/LineAttributesRetained.java index 616a2ab..c76c842 100644 --- a/src/javax/media/j3d/LineAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/LineAttributesRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/LineStripArray.java b/src/main/java/org/jogamp/java3d/LineStripArray.java index f97574e..f3086de 100644 --- a/src/javax/media/j3d/LineStripArray.java +++ b/src/main/java/org/jogamp/java3d/LineStripArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The LineStripArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/LineStripArrayRetained.java b/src/main/java/org/jogamp/java3d/LineStripArrayRetained.java index 861c306..b0911ab 100644 --- a/src/javax/media/j3d/LineStripArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/LineStripArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The LineStripArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/LinearFog.java b/src/main/java/org/jogamp/java3d/LinearFog.java index a3f6b0a..dc12fab 100644 --- a/src/javax/media/j3d/LinearFog.java +++ b/src/main/java/org/jogamp/java3d/LinearFog.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The LinearFog leaf node defines fog distance parameters for diff --git a/src/javax/media/j3d/LinearFogRetained.java b/src/main/java/org/jogamp/java3d/LinearFogRetained.java index 293c592..228e46e 100644 --- a/src/javax/media/j3d/LinearFogRetained.java +++ b/src/main/java/org/jogamp/java3d/LinearFogRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The LinearFog leaf node defines distance parameters for diff --git a/src/javax/media/j3d/Link.java b/src/main/java/org/jogamp/java3d/Link.java index e8c0237..ed06cf8 100644 --- a/src/javax/media/j3d/Link.java +++ b/src/main/java/org/jogamp/java3d/Link.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A Link leaf node allows an application to reference a shared graph, diff --git a/src/javax/media/j3d/LinkRetained.java b/src/main/java/org/jogamp/java3d/LinkRetained.java index 4ad5ddf..d788ca3 100644 --- a/src/javax/media/j3d/LinkRetained.java +++ b/src/main/java/org/jogamp/java3d/LinkRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; /** diff --git a/src/javax/media/j3d/Locale.java b/src/main/java/org/jogamp/java3d/Locale.java index 4da6c4a..5075413 100644 --- a/src/javax/media/j3d/Locale.java +++ b/src/main/java/org/jogamp/java3d/Locale.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; /** @@ -565,17 +565,17 @@ Vector<BranchGroup> branchGroups = new Vector<BranchGroup>(); } /** - * Gets an Enumeration object of all branch graphs in this Locale. - * @return an Enumeration object of all branch graphs. + * Gets an Iterator object of all branch graphs in this Locale. + * @return an Iterator object of all branch graphs. * @exception IllegalStateException if this Locale has been * removed from its VirtualUniverse. */ - public Enumeration getAllBranchGraphs(){ + public Iterator<BranchGroup> getAllBranchGraphs(){ if (universe == null) { throw new IllegalStateException(J3dI18N.getString("Locale4")); } - return branchGroups.elements(); + return branchGroups.iterator(); } @@ -714,7 +714,7 @@ Vector<BranchGroup> branchGroups = new Vector<BranchGroup>(); * (in addition to one of the above)</li> * </ul> * - * @see BranchGroup#pickAll(int,int,javax.media.j3d.PickShape) + * @see BranchGroup#pickAll(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 @@ -831,7 +831,7 @@ Vector<BranchGroup> branchGroups = new Vector<BranchGroup>(); * (in addition to one of the above)</li> * </ul> * - * @see BranchGroup#pickAllSorted(int,int,javax.media.j3d.PickShape) + * @see BranchGroup#pickAllSorted(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 @@ -955,7 +955,7 @@ Vector<BranchGroup> branchGroups = new Vector<BranchGroup>(); * (in addition to one of the above)</li> * </ul> * - * @see BranchGroup#pickClosest(int,int,javax.media.j3d.PickShape) + * @see BranchGroup#pickClosest(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 @@ -1064,7 +1064,7 @@ Vector<BranchGroup> branchGroups = new Vector<BranchGroup>(); * (in addition to one of the above)</li> * </ul> * - * @see BranchGroup#pickAny(int,int,javax.media.j3d.PickShape) + * @see BranchGroup#pickAny(int,int,org.jogamp.java3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 diff --git a/src/javax/media/j3d/MRSWLock.java b/src/main/java/org/jogamp/java3d/MRSWLock.java index a010360..6de79c3 100644 --- a/src/javax/media/j3d/MRSWLock.java +++ b/src/main/java/org/jogamp/java3d/MRSWLock.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Use this lock to allow multiple reads/single write synchronization. diff --git a/src/javax/media/j3d/MasterControl.java b/src/main/java/org/jogamp/java3d/MasterControl.java index 0bf27ab..a7495cf 100644 --- a/src/javax/media/j3d/MasterControl.java +++ b/src/main/java/org/jogamp/java3d/MasterControl.java @@ -30,12 +30,12 @@ * of the Java 3D API. */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Hashtable; import java.util.logging.Level; import java.util.logging.Logger; @@ -398,6 +398,18 @@ class MasterControl { // True to disable all underlying multisampling API so it uses // the setting in the driver. boolean implicitAntialiasing = false; + + // If set to false default capabilities will not be set, potentially allowing + // much more compilation of scene graphs + boolean defaultReadCapability = true; + + // If set to false nodes will not be pickable by default, potentially allowing + // much more compilation of scene graphs + boolean defaultNodePickable = true; + + // If set to false nodes will not be collidable by default, potentially allowing + // much more compilation of scene graphs + boolean defaultNodeCollidable = true; // False to disable compiled vertex array extensions if support boolean isCompiledVertexArray = true; @@ -529,6 +541,21 @@ class MasterControl { getBooleanProperty("j3d.implicitAntialiasing", implicitAntialiasing, "implicit antialiasing"); + + defaultReadCapability = + getBooleanProperty("j3d.defaultReadCapability", + defaultReadCapability, + "default read capability"); + + defaultNodePickable = + getBooleanProperty("j3d.defaultNodePickable", + defaultNodePickable, + "default node pickable"); + + defaultNodeCollidable = + getBooleanProperty("j3d.defaultNodeCollidable", + defaultNodeCollidable, + "default node collidable"); isCompiledVertexArray = getBooleanProperty("j3d.compiledVertexArray", @@ -779,15 +806,20 @@ private static String getProperty(final String prop) { }); } - static int getIntegerProperty(String prop, int defaultValue) { + static int getIntegerProperty(String prop, int defaultValue) + { int value = defaultValue; String propValue = getProperty(prop); - if (propValue != null) { - try { + if (propValue != null) + { + try + { value = Integer.parseInt(propValue); } - catch (NumberFormatException e) {} + catch (NumberFormatException e) + { + } } if (J3dDebug.debug) System.err.println("Java 3D: " + prop + "=" + value); @@ -795,6 +827,7 @@ private static String getProperty(final String prop) { return value; } + static boolean getBooleanProperty(String prop, boolean defaultValue, String trueMsg, @@ -842,6 +875,8 @@ private static String getProperty(final String prop) { // Use default pipeline } else if (rendStr.equals("jogl")) { pipelineType = Pipeline.Type.JOGL; + } else if (rendStr.equals("jogl2es2")) { + pipelineType = Pipeline.Type.JOGL2ES2; } else if (rendStr.equals("noop")) { pipelineType = Pipeline.Type.NOOP; } else { @@ -849,11 +884,11 @@ private static String getProperty(final String prop) { // Use default pipeline } - // Java 3D cannot run in headless mode unless using the noop renderer - if (java.awt.GraphicsEnvironment.isHeadless() && pipelineType != Pipeline.Type.NOOP) { - throw new java.awt.HeadlessException(); - } - + // Java 3D cannot run in headless mode unless using the noop renderer + if (java.awt.GraphicsEnvironment.isHeadless() && pipelineType != Pipeline.Type.NOOP) { + throw new java.awt.HeadlessException(); + } + // Construct the singleton Pipeline instance Pipeline.createPipeline(pipelineType); @@ -1669,6 +1704,7 @@ private static String getProperty(final String prop) { synchronized (rootThreadGroup) { s.updateThread = new StructureUpdateThread( rootThreadGroup, s, s.threadType); + s.updateThread.setDaemon(true); s.updateThread.setPriority(threadPriority); } return null; @@ -1881,8 +1917,8 @@ private static String getProperty(final String prop) { // remove all InputDeviceScheduler if this is the last View ArrayList<PhysicalEnvironment> list = new ArrayList<PhysicalEnvironment>(); - for (Enumeration<PhysicalEnvironment> e = PhysicalEnvironment.physicalEnvMap.keys(); e.hasMoreElements();) { - PhysicalEnvironment phyEnv = e.nextElement(); + for (Iterator<PhysicalEnvironment> e = PhysicalEnvironment.physicalEnvMap.keySet().iterator(); e.hasNext();) { + PhysicalEnvironment phyEnv = e.next(); InputDeviceScheduler sched = PhysicalEnvironment.physicalEnvMap.get(phyEnv); boolean phyEnvHasUser = false; for (int i = 0; i < phyEnv.users.size(); i++) { @@ -1916,9 +1952,9 @@ private static String getProperty(final String prop) { "MC: Destroy all Renderers"); } // remove all Renderers if this is the last View - for (Enumeration<Renderer> e = Screen3D.deviceRendererMap.elements(); - e.hasMoreElements(); ) { - Renderer rdr = e.nextElement(); + for (Iterator<Renderer> e = Screen3D.deviceRendererMap.values().iterator(); + e.hasNext(); ) { + Renderer rdr = e.next(); Screen3D scr; rendererCleanupArgs[2] = REMOVEALLCTXS_CLEANUP; @@ -1947,9 +1983,9 @@ private static String getProperty(final String prop) { } // cleanup ThreadData corresponds to the view in renderer - for (Enumeration<Renderer> e = Screen3D.deviceRendererMap.elements(); - e.hasMoreElements(); ) { - e.nextElement().cleanup(); + for (Iterator<Renderer> e = Screen3D.deviceRendererMap.values().iterator(); + e.hasNext(); ) { + e.next().cleanup(); } // We have to reuse renderer even though MC exit // see bug 4363279 @@ -1957,9 +1993,9 @@ private static String getProperty(final String prop) { } else { // cleanup ThreadData corresponds to the view in renderer - for (Enumeration<Renderer> e = Screen3D.deviceRendererMap.elements(); - e.hasMoreElements(); ) { - e.nextElement().cleanupView(); + for (Iterator<Renderer> e = Screen3D.deviceRendererMap.values().iterator(); + e.hasNext(); ) { + e.next().cleanupView(); } } @@ -1993,6 +2029,7 @@ private static String getProperty(final String prop) { public Object run() { synchronized (rootThreadGroup) { timerThread = new TimerThread(rootThreadGroup); + timerThread.setDaemon(true); timerThread.setPriority(threadPriority); } return null; @@ -2007,6 +2044,7 @@ private static String getProperty(final String prop) { public Object run() { synchronized (rootThreadGroup) { notificationThread = new NotificationThread(rootThreadGroup); + notificationThread.setDaemon(true); notificationThread.setPriority(threadPriority); } return null; @@ -2694,9 +2732,9 @@ private static String getProperty(final String prop) { thread = null; - for (Enumeration<Renderer> e = Screen3D.deviceRendererMap.elements(); - e.hasMoreElements(); ) { - Renderer rdr = e.nextElement(); + for (Iterator<Renderer> e = Screen3D.deviceRendererMap.values().iterator(); + e.hasNext(); ) { + Renderer rdr = e.next(); thread = rdr.getThreadData(null, null); requestRenderWorkThreads.add(thread); thread.threadOpts = J3dThreadData.CONT_THREAD; diff --git a/src/javax/media/j3d/MasterControlThread.java b/src/main/java/org/jogamp/java3d/MasterControlThread.java index f1c67b0..914e506 100644 --- a/src/javax/media/j3d/MasterControlThread.java +++ b/src/main/java/org/jogamp/java3d/MasterControlThread.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Master control thread. The MasterControlThread object and thread @@ -50,6 +50,7 @@ class MasterControlThread extends Thread { MasterControlThread(ThreadGroup threadGroup) { super(threadGroup, ""); + setDaemon(true); setName("J3D-MasterControl-" + getInstanceNum()); VirtualUniverse.mc.createMCThreads(); this.start(); diff --git a/src/javax/media/j3d/Material.java b/src/main/java/org/jogamp/java3d/Material.java index 528aa0e..6854c0c 100644 --- a/src/javax/media/j3d/Material.java +++ b/src/main/java/org/jogamp/java3d/Material.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The Material object defines the appearance of an object under @@ -628,7 +628,7 @@ public class Material extends NodeComponent { @Override public String toString() { StringBuffer str = new StringBuffer(getNamePrefix()); - str.append("javax.media.j3d.Material: "); + str.append("org.jogamp.java3d.Material: "); Color3f color=new Color3f(); try { getAmbientColor(color); diff --git a/src/javax/media/j3d/MaterialRetained.java b/src/main/java/org/jogamp/java3d/MaterialRetained.java index f900eee..31255da 100644 --- a/src/javax/media/j3d/MaterialRetained.java +++ b/src/main/java/org/jogamp/java3d/MaterialRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; /** * The MaterialRetained object defines the appearance of an object under diff --git a/src/javax/media/j3d/MediaContainer.java b/src/main/java/org/jogamp/java3d/MediaContainer.java index 3a76b07..944328a 100644 --- a/src/javax/media/j3d/MediaContainer.java +++ b/src/main/java/org/jogamp/java3d/MediaContainer.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.io.InputStream; import java.net.URL; diff --git a/src/javax/media/j3d/MediaContainerRetained.java b/src/main/java/org/jogamp/java3d/MediaContainerRetained.java index 4b89609..2f3e661 100644 --- a/src/javax/media/j3d/MediaContainerRetained.java +++ b/src/main/java/org/jogamp/java3d/MediaContainerRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.io.InputStream; import java.net.URL; @@ -90,7 +90,7 @@ class MediaContainerRetained extends NodeComponentRetained { stream.close(); } catch (Exception e) { - throw new SoundException(javax.media.j3d.J3dI18N.getString("MediaContainer0")); + throw new SoundException(org.jogamp.java3d.J3dI18N.getString("MediaContainer0")); } } this.url = url; @@ -127,7 +127,7 @@ class MediaContainerRetained extends NodeComponentRetained { stream.close(); } catch (Exception e) { - throw new SoundException(javax.media.j3d.J3dI18N.getString("MediaContainer0")); + throw new SoundException(org.jogamp.java3d.J3dI18N.getString("MediaContainer0")); } } this.urlString = path; diff --git a/src/javax/media/j3d/MemoryFreeList.java b/src/main/java/org/jogamp/java3d/MemoryFreeList.java index 95de4d4..5a40355 100644 --- a/src/javax/media/j3d/MemoryFreeList.java +++ b/src/main/java/org/jogamp/java3d/MemoryFreeList.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; @@ -33,6 +33,7 @@ import java.util.Arrays; * Class for storing various free lists. This class must be * synchronized because different threads may try to access the lists. */ +@Deprecated class MemoryFreeList { // never go smaller than the initial capacity diff --git a/src/javax/media/j3d/ModelClip.java b/src/main/java/org/jogamp/java3d/ModelClip.java index e03c8a0..db99cfb 100644 --- a/src/javax/media/j3d/ModelClip.java +++ b/src/main/java/org/jogamp/java3d/ModelClip.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Vector4d; /** * The ModelClip leaf node defines a set of 6 arbitrary clipping @@ -348,13 +348,13 @@ public class ModelClip extends Leaf { /** - * Returns an enumeration of this ModelClip node's list of scopes. - * @return an Enumeration object containing all nodes in this ModelClip node's + * Returns an iterator of this ModelClip node's list of scopes. + * @return an Iterator object containing all nodes in this ModelClip node's * list of scopes. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ -public Enumeration<Group> getAllScopes() { +public Iterator<Group> getAllScopes() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_SCOPE_READ)) throw new CapabilityNotSetException( @@ -725,10 +725,10 @@ public Enumeration<Group> getAllScopes() { } rt.initInfluencingBounds(attr.getInfluencingBounds()); - Enumeration<Group> elm = attr.getAllScopes(); - while (elm.hasMoreElements()) { + Iterator<Group> elm = attr.getAllScopes(); + while (elm.hasNext()) { // this reference will set correctly in updateNodeReferences() callback - rt.initAddScope(elm.nextElement()); + rt.initAddScope(elm.next()); } // correct value will set in updateNodeReferences diff --git a/src/javax/media/j3d/ModelClipRetained.java b/src/main/java/org/jogamp/java3d/ModelClipRetained.java index 04b248d..88b5be3 100644 --- a/src/javax/media/j3d/ModelClipRetained.java +++ b/src/main/java/org/jogamp/java3d/ModelClipRetained.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Vector4d; /** * The ModelClip retained object. @@ -510,16 +510,16 @@ Vector<GroupRetained> scopes = new Vector<GroupRetained>(); } /** - * Returns an enumeration object of the scoperen. - * @return an enumeration object of the scoperen + * Returns an iterator object of the scoperen. + * @return an iterator object of the scoperen */ -Enumeration<Group> getAllScopes() { - Enumeration<GroupRetained> elm = scopes.elements(); +Iterator<Group> getAllScopes() { + Iterator<GroupRetained> elm = scopes.iterator(); Vector<Group> v = new Vector<Group>(scopes.size()); - while (elm.hasMoreElements()) { - v.add((Group)elm.nextElement().source); + while (elm.hasNext()) { + v.add((Group)elm.next().source); } - return v.elements(); + return v.iterator(); } /** diff --git a/src/javax/media/j3d/Morph.java b/src/main/java/org/jogamp/java3d/Morph.java index 9fc7d9e..fb321aa 100644 --- a/src/javax/media/j3d/Morph.java +++ b/src/main/java/org/jogamp/java3d/Morph.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; diff --git a/src/javax/media/j3d/MorphRetained.java b/src/main/java/org/jogamp/java3d/MorphRetained.java index 9ba5d71..5ce4b53 100644 --- a/src/javax/media/j3d/MorphRetained.java +++ b/src/main/java/org/jogamp/java3d/MorphRetained.java @@ -24,24 +24,24 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color3b; -import javax.vecmath.Color3f; -import javax.vecmath.Color4b; -import javax.vecmath.Color4f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.TexCoord2f; -import javax.vecmath.TexCoord3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Color3b; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Color4b; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.TexCoord3f; +import org.jogamp.vecmath.Vector3f; /** * A morph leaf node consisting of geometery and appearance properties. */ - +@Deprecated class MorphRetained extends LeafRetained implements GeometryUpdater { // These bits should match the Shape3D bits ...(Since the mirrors for diff --git a/src/javax/media/j3d/MultipleParentException.java b/src/main/java/org/jogamp/java3d/MultipleParentException.java index 481fa16..617d399 100644 --- a/src/javax/media/j3d/MultipleParentException.java +++ b/src/main/java/org/jogamp/java3d/MultipleParentException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates diff --git a/src/javax/media/j3d/NioImageBuffer.java b/src/main/java/org/jogamp/java3d/NioImageBuffer.java index 899b45a..ad62e21 100644 --- a/src/javax/media/j3d/NioImageBuffer.java +++ b/src/main/java/org/jogamp/java3d/NioImageBuffer.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.nio.Buffer; import java.nio.ByteBuffer; diff --git a/src/javax/media/j3d/NnuId.java b/src/main/java/org/jogamp/java3d/NnuId.java index cb959e1..0aceb2d 100644 --- a/src/javax/media/j3d/NnuId.java +++ b/src/main/java/org/jogamp/java3d/NnuId.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Defines a "not necessarily unique ID" diff --git a/src/javax/media/j3d/NnuIdManager.java b/src/main/java/org/jogamp/java3d/NnuIdManager.java index 16fa62d..d436179 100644 --- a/src/javax/media/j3d/NnuIdManager.java +++ b/src/main/java/org/jogamp/java3d/NnuIdManager.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class NnuIdManager { static int nnuId = 0; diff --git a/src/javax/media/j3d/Node.java b/src/main/java/org/jogamp/java3d/Node.java index 70bfe02..24cf575 100644 --- a/src/javax/media/j3d/Node.java +++ b/src/main/java/org/jogamp/java3d/Node.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Hashtable; /** @@ -582,10 +582,10 @@ public abstract class Node extends SceneGraphObject { // go through hash table looking for Leaf nodes. // call updateNodeReferences for each. - Enumeration e = referenceTable.objectHashtable.elements(); + Iterator e = referenceTable.objectHashtable.values().iterator(); - while (e.hasMoreElements()) { - SceneGraphObject o = (SceneGraphObject) e.nextElement(); + while (e.hasNext()) { + SceneGraphObject o = (SceneGraphObject) e.next(); o.updateNodeReferences(referenceTable); } return n; diff --git a/src/javax/media/j3d/NodeComponent.java b/src/main/java/org/jogamp/java3d/NodeComponent.java index fb0d0b5..62b3e61 100644 --- a/src/javax/media/j3d/NodeComponent.java +++ b/src/main/java/org/jogamp/java3d/NodeComponent.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; /** diff --git a/src/javax/media/j3d/NodeComponentRetained.java b/src/main/java/org/jogamp/java3d/NodeComponentRetained.java index c424257..a75e70b 100644 --- a/src/javax/media/j3d/NodeComponentRetained.java +++ b/src/main/java/org/jogamp/java3d/NodeComponentRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.ArrayList; +import java.util.LinkedHashSet; /** * Retained version of NodeComponent @@ -48,7 +48,7 @@ class NodeComponentRetained extends SceneGraphObjectRetained { // A list of NodeRetained Objects that refer, directly or indirectly, to this // NodeComponentRetained - ArrayList users = new ArrayList(1); + LinkedHashSet<NodeRetained> users = new LinkedHashSet<NodeRetained>(); // Mirror object of this node compoenent object NodeComponentRetained mirror = null; @@ -115,27 +115,22 @@ class NodeComponentRetained extends SceneGraphObjectRetained { } } - // Copy the list of useres passed in into this + // Copy the list of users passed in into this void copyMirrorUsers(NodeComponentRetained node) { synchronized(mirror.users) { synchronized(node.mirror.users) { - int size = node.mirror.users.size(); - for (int i=0; i<size ; i++) { - mirror.users.add(node.mirror.users.get(i)); - } + mirror.users.addAll(node.mirror.users); } } } - // Remove the users of "node" from "this" node compoenent + // Remove the users of "node" from "this" node component void removeMirrorUsers(NodeComponentRetained node) { synchronized(mirror.users) { synchronized(node.mirror.users) { - for (int i=node.mirror.users.size()-1; i>=0; i--) { - mirror.users.remove(mirror.users.indexOf(node.mirror.users.get(i))); - } + mirror.users.removeAll(node.mirror.users); } } } @@ -143,13 +138,13 @@ class NodeComponentRetained extends SceneGraphObjectRetained { // Add a user to the list of users synchronized void removeUser(NodeRetained node) { if (node.source.isLive()) - users.remove(users.indexOf(node)); + users.remove(node); } // Add a user to the list of users synchronized void addUser(NodeRetained node) { if (node.source.isLive()) - users.add(node); + users.add(node); } @@ -160,9 +155,13 @@ class NodeComponentRetained extends SceneGraphObjectRetained { return; } - for (int i=users.size()-1; i >=0; i--) { - ((NodeRetained)users.get(i)).notifySceneGraphChanged(false); - } + // the reverse order does not appear to be compulsory + // change from ArrayList to LinkedHashMap prevents ordered traversal + for (NodeRetained nr : users) + nr.notifySceneGraphChanged(false); + //for (int i=users.size()-1; i >=0; i--) { + // ((NodeRetained)users.get(i)).notifySceneGraphChanged(false); + //} } /** diff --git a/src/javax/media/j3d/NodeComponentUpdate.java b/src/main/java/org/jogamp/java3d/NodeComponentUpdate.java index 677e36f..870e8de 100644 --- a/src/javax/media/j3d/NodeComponentUpdate.java +++ b/src/main/java/org/jogamp/java3d/NodeComponentUpdate.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A Node Component Update interface. Any object that can be put in the diff --git a/src/javax/media/j3d/NodeData.java b/src/main/java/org/jogamp/java3d/NodeData.java index ad822fd..f2511bd 100644 --- a/src/javax/media/j3d/NodeData.java +++ b/src/main/java/org/jogamp/java3d/NodeData.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class NodeData { diff --git a/src/javax/media/j3d/NodeReferenceTable.java b/src/main/java/org/jogamp/java3d/NodeReferenceTable.java index 1bab869..2e13c06 100644 --- a/src/javax/media/j3d/NodeReferenceTable.java +++ b/src/main/java/org/jogamp/java3d/NodeReferenceTable.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; diff --git a/src/javax/media/j3d/NodeRetained.java b/src/main/java/org/jogamp/java3d/NodeRetained.java index 662a730..f683ac8 100644 --- a/src/javax/media/j3d/NodeRetained.java +++ b/src/main/java/org/jogamp/java3d/NodeRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; @@ -119,12 +119,12 @@ abstract class NodeRetained extends SceneGraphObjectRetained implements NnuId { * This indicates if the node is pickable. If this node is not * pickable then neither are any children */ - boolean pickable = true; + boolean pickable = VirtualUniverse.mc.defaultNodePickable; /** * The collidable setting; see getCollidable and setCollidable. */ - boolean collidable = true; + boolean collidable = VirtualUniverse.mc.defaultNodeCollidable; // A list of localToVworld transforms. If inSharedGroup is false, // then only localToVworld[0][] is valid. @@ -624,6 +624,9 @@ NodeRetained getParent() { void recombineAbove() {} + synchronized void updateLocalToVworld() {} + + @Override void setLive(SetLiveState s) { int oldrefCount = refCount; diff --git a/src/javax/media/j3d/NoopDrawingSurfaceObject.java b/src/main/java/org/jogamp/java3d/NoopDrawingSurfaceObject.java index 0c41322..385657a 100644 --- a/src/javax/media/j3d/NoopDrawingSurfaceObject.java +++ b/src/main/java/org/jogamp/java3d/NoopDrawingSurfaceObject.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The DrawingSurfaceObject class is used to manage native drawing surface diff --git a/src/javax/media/j3d/NoopPipeline.java b/src/main/java/org/jogamp/java3d/NoopPipeline.java index 64c0ccd..bb2e900 100644 --- a/src/javax/media/j3d/NoopPipeline.java +++ b/src/main/java/org/jogamp/java3d/NoopPipeline.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; diff --git a/src/javax/media/j3d/NotificationThread.java b/src/main/java/org/jogamp/java3d/NotificationThread.java index c76c26d..48c7814 100644 --- a/src/javax/media/j3d/NotificationThread.java +++ b/src/main/java/org/jogamp/java3d/NotificationThread.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/ObjectUpdate.java b/src/main/java/org/jogamp/java3d/ObjectUpdate.java index 8a4e096..f00b037 100644 --- a/src/javax/media/j3d/ObjectUpdate.java +++ b/src/main/java/org/jogamp/java3d/ObjectUpdate.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /* * A Object Update interface. Any object that can be put in the ObjectUpdate list diff --git a/src/javax/media/j3d/OrderedBin.java b/src/main/java/org/jogamp/java3d/OrderedBin.java index 545a56d..5e2da32 100644 --- a/src/javax/media/j3d/OrderedBin.java +++ b/src/main/java/org/jogamp/java3d/OrderedBin.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/OrderedChildInfo.java b/src/main/java/org/jogamp/java3d/OrderedChildInfo.java index 54f1f39..f6d54ec 100644 --- a/src/javax/media/j3d/OrderedChildInfo.java +++ b/src/main/java/org/jogamp/java3d/OrderedChildInfo.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * List of orderedGroup children that needs to be added/removed for diff --git a/src/javax/media/j3d/OrderedCollection.java b/src/main/java/org/jogamp/java3d/OrderedCollection.java index 0b28118..00ec071 100644 --- a/src/javax/media/j3d/OrderedCollection.java +++ b/src/main/java/org/jogamp/java3d/OrderedCollection.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/OrderedGroup.java b/src/main/java/org/jogamp/java3d/OrderedGroup.java index 4b50077..ddb6827 100644 --- a/src/javax/media/j3d/OrderedGroup.java +++ b/src/main/java/org/jogamp/java3d/OrderedGroup.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Arrays; diff --git a/src/javax/media/j3d/OrderedGroupRetained.java b/src/main/java/org/jogamp/java3d/OrderedGroupRetained.java index bcf4e36..48363e5 100644 --- a/src/javax/media/j3d/OrderedGroupRetained.java +++ b/src/main/java/org/jogamp/java3d/OrderedGroupRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/OrderedPath.java b/src/main/java/org/jogamp/java3d/OrderedPath.java index 0b34d5f..11994a1 100644 --- a/src/javax/media/j3d/OrderedPath.java +++ b/src/main/java/org/jogamp/java3d/OrderedPath.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/OrderedPathElement.java b/src/main/java/org/jogamp/java3d/OrderedPathElement.java index b4df84b..71ae7ee 100644 --- a/src/javax/media/j3d/OrderedPathElement.java +++ b/src/main/java/org/jogamp/java3d/OrderedPathElement.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class OrderedPathElement extends Object { diff --git a/src/javax/media/j3d/OrientedShape3D.java b/src/main/java/org/jogamp/java3d/OrientedShape3D.java index 0dd1418..4e38af6 100644 --- a/src/javax/media/j3d/OrientedShape3D.java +++ b/src/main/java/org/jogamp/java3d/OrientedShape3D.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * The OrientedShape3D leaf node is a Shape3D node that is oriented diff --git a/src/javax/media/j3d/OrientedShape3DRenderMethod.java b/src/main/java/org/jogamp/java3d/OrientedShape3DRenderMethod.java index afa7ad8..e547ffa 100644 --- a/src/javax/media/j3d/OrientedShape3DRenderMethod.java +++ b/src/main/java/org/jogamp/java3d/OrientedShape3DRenderMethod.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The OrientedShape3DRenderMethod provides a render method to render diff --git a/src/javax/media/j3d/OrientedShape3DRetained.java b/src/main/java/org/jogamp/java3d/OrientedShape3DRetained.java index 4fe4026..ba0d0ff 100644 --- a/src/javax/media/j3d/OrientedShape3DRetained.java +++ b/src/main/java/org/jogamp/java3d/OrientedShape3DRetained.java @@ -24,14 +24,14 @@ * */ -package javax.media.j3d; - -import javax.vecmath.AxisAngle4d; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector3f; -import javax.vecmath.Vector4d; +package org.jogamp.java3d; + +import org.jogamp.vecmath.AxisAngle4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; +import org.jogamp.vecmath.Vector4d; class OrientedShape3DRetained extends Shape3DRetained { diff --git a/src/javax/media/j3d/PathInterpolator.java b/src/main/java/org/jogamp/java3d/PathInterpolator.java index 0d67bbe..4839190 100644 --- a/src/javax/media/j3d/PathInterpolator.java +++ b/src/main/java/org/jogamp/java3d/PathInterpolator.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/PhysicalBody.java b/src/main/java/org/jogamp/java3d/PhysicalBody.java index 7b1153c..0bd91bb 100644 --- a/src/javax/media/j3d/PhysicalBody.java +++ b/src/main/java/org/jogamp/java3d/PhysicalBody.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * This object contains a specification of the user's head. diff --git a/src/javax/media/j3d/PhysicalEnvironment.java b/src/main/java/org/jogamp/java3d/PhysicalEnvironment.java index e3d6b90..caea512 100644 --- a/src/javax/media/j3d/PhysicalEnvironment.java +++ b/src/main/java/org/jogamp/java3d/PhysicalEnvironment.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Hashtable; import java.util.Vector; @@ -237,8 +237,8 @@ synchronized void notifyUsers() { * Create an enumerator that produces all input devices. * @return an enumerator of all available devices */ -public Enumeration<InputDevice> getAllInputDevices() { - return devices.elements(); +public Iterator<InputDevice> getAllInputDevices() { + return devices.iterator(); } /** diff --git a/src/javax/media/j3d/PickBounds.java b/src/main/java/org/jogamp/java3d/PickBounds.java index 60d1ec1..9fd7eb1 100644 --- a/src/javax/media/j3d/PickBounds.java +++ b/src/main/java/org/jogamp/java3d/PickBounds.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; /** * PickBounds is a finite pick shape defined with a Bounds object. It can diff --git a/src/javax/media/j3d/PickCone.java b/src/main/java/org/jogamp/java3d/PickCone.java index 6dd3893..586a089 100644 --- a/src/javax/media/j3d/PickCone.java +++ b/src/main/java/org/jogamp/java3d/PickCone.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; /** * PickCone is the abstract base class of all cone pick shapes. diff --git a/src/javax/media/j3d/PickConeRay.java b/src/main/java/org/jogamp/java3d/PickConeRay.java index d853508..1a6ff74 100644 --- a/src/javax/media/j3d/PickConeRay.java +++ b/src/main/java/org/jogamp/java3d/PickConeRay.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; /** * PickConeRay is an infinite cone ray pick shape. It can diff --git a/src/javax/media/j3d/PickConeSegment.java b/src/main/java/org/jogamp/java3d/PickConeSegment.java index b7b7f62..631e0fe 100644 --- a/src/javax/media/j3d/PickConeSegment.java +++ b/src/main/java/org/jogamp/java3d/PickConeSegment.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; /** * PickConeSegment is a finite cone segment pick shape. It can diff --git a/src/javax/media/j3d/PickCylinder.java b/src/main/java/org/jogamp/java3d/PickCylinder.java index ff590a1..ee1a0b9 100644 --- a/src/javax/media/j3d/PickCylinder.java +++ b/src/main/java/org/jogamp/java3d/PickCylinder.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector4d; /** * PickCylinder is the abstract base class of all cylindrical pick shapes. diff --git a/src/javax/media/j3d/PickCylinderRay.java b/src/main/java/org/jogamp/java3d/PickCylinderRay.java index 62195dd..579c7ff 100644 --- a/src/javax/media/j3d/PickCylinderRay.java +++ b/src/main/java/org/jogamp/java3d/PickCylinderRay.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; /** * PickCylinderRay is an infinite cylindrical ray pick shape. It can diff --git a/src/javax/media/j3d/PickCylinderSegment.java b/src/main/java/org/jogamp/java3d/PickCylinderSegment.java index 9d33626..66ca634 100644 --- a/src/javax/media/j3d/PickCylinderSegment.java +++ b/src/main/java/org/jogamp/java3d/PickCylinderSegment.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; /** * PickCylinderSegment is a finite cylindrical segment pick shape. It can diff --git a/src/javax/media/j3d/PickInfo.java b/src/main/java/org/jogamp/java3d/PickInfo.java index 7bf381c..7badb39 100644 --- a/src/javax/media/j3d/PickInfo.java +++ b/src/main/java/org/jogamp/java3d/PickInfo.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Vector; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; /** * The PickInfo object contains the computed information about a pick hit. diff --git a/src/javax/media/j3d/PickPoint.java b/src/main/java/org/jogamp/java3d/PickPoint.java index a794d22..75336dc 100644 --- a/src/javax/media/j3d/PickPoint.java +++ b/src/main/java/org/jogamp/java3d/PickPoint.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; /** * PickPoint is a pick shape defined as a single point. It can diff --git a/src/javax/media/j3d/PickRay.java b/src/main/java/org/jogamp/java3d/PickRay.java index ed88da2..69d3a4e 100644 --- a/src/javax/media/j3d/PickRay.java +++ b/src/main/java/org/jogamp/java3d/PickRay.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Vector3d; /** * PickRay is an infinite ray pick shape. It can diff --git a/src/javax/media/j3d/PickSegment.java b/src/main/java/org/jogamp/java3d/PickSegment.java index 2f86358..5205e96 100644 --- a/src/javax/media/j3d/PickSegment.java +++ b/src/main/java/org/jogamp/java3d/PickSegment.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; /** * PickSegment is a line segment pick shape. It can diff --git a/src/javax/media/j3d/PickShape.java b/src/main/java/org/jogamp/java3d/PickShape.java index 65cb130..3437884 100644 --- a/src/javax/media/j3d/PickShape.java +++ b/src/main/java/org/jogamp/java3d/PickShape.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; +package org.jogamp.java3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; /** * An abstract class for describing a pick shape that can be used with diff --git a/src/javax/media/j3d/Pipeline.java b/src/main/java/org/jogamp/java3d/Pipeline.java index 4804156..e13d0cb 100644 --- a/src/javax/media/j3d/Pipeline.java +++ b/src/main/java/org/jogamp/java3d/Pipeline.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; @@ -36,10 +36,17 @@ import java.nio.FloatBuffer; * pipeline methods are defined here. */ abstract class Pipeline { - // Supported rendering pipelines + // Supported rendering pipelines enum Type { // Java rendering pipeline using Java Bindings for OpenGL + // This pipeline will use the newest GL profile that support the fixed function pipeline + // https://www.opengl.org/wiki/Fixed_Function_Pipeline JOGL, + + // Java rendering pipeline using Java Bindings for OpenGL + // This pipeline will use the newest GL profile that supports the intersection of GL2 and ES2 + // This will not use any fixed function pipeline features (e.g. you must attach shaders) + JOGL2ES2, // No-op rendering pipeline NOOP, @@ -71,9 +78,11 @@ public Pipeline run() { try { switch (pipeType) { case JOGL: - return (Pipeline)Class.forName("javax.media.j3d.JoglPipeline").newInstance(); + return (Pipeline)Class.forName("org.jogamp.java3d.JoglPipeline").newInstance(); + case JOGL2ES2: + return (Pipeline)Class.forName("org.jogamp.java3d.Jogl2es2Pipeline").newInstance(); case NOOP: - return (Pipeline)Class.forName("javax.media.j3d.NoopPipeline").newInstance(); + return (Pipeline)Class.forName("org.jogamp.java3d.NoopPipeline").newInstance(); } } catch (Exception e) { throw new RuntimeException(e); @@ -129,6 +138,8 @@ public Pipeline run() { switch (pipelineType) { case JOGL: return "JOGL"; + case JOGL2ES2: + return "JOGL2ES2"; case NOOP: return "NOOP"; default: @@ -144,6 +155,8 @@ public Pipeline run() { switch (pipelineType) { case JOGL: return "OpenGL"; + case JOGL2ES2: + return "OpenGLES2"; case NOOP: return "None"; default: diff --git a/src/javax/media/j3d/PointArray.java b/src/main/java/org/jogamp/java3d/PointArray.java index bfe6fae..f45d84a 100644 --- a/src/javax/media/j3d/PointArray.java +++ b/src/main/java/org/jogamp/java3d/PointArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/PointArrayRetained.java b/src/main/java/org/jogamp/java3d/PointArrayRetained.java index 77e2433..b9915d1 100644 --- a/src/javax/media/j3d/PointArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/PointArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The PointArray object draws the array of vertices as individual points. diff --git a/src/javax/media/j3d/PointAttributes.java b/src/main/java/org/jogamp/java3d/PointAttributes.java index 2c5135a..8392a71 100644 --- a/src/javax/media/j3d/PointAttributes.java +++ b/src/main/java/org/jogamp/java3d/PointAttributes.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The PointAttributes object defines all attributes that apply to diff --git a/src/javax/media/j3d/PointAttributesRetained.java b/src/main/java/org/jogamp/java3d/PointAttributesRetained.java index 3025fa9..26a467c 100644 --- a/src/javax/media/j3d/PointAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/PointAttributesRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/PointLight.java b/src/main/java/org/jogamp/java3d/PointLight.java index 67ee2a9..ca53acd 100644 --- a/src/javax/media/j3d/PointLight.java +++ b/src/main/java/org/jogamp/java3d/PointLight.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; /** diff --git a/src/javax/media/j3d/PointLightRetained.java b/src/main/java/org/jogamp/java3d/PointLightRetained.java index 4ea69d7..4946fc0 100644 --- a/src/javax/media/j3d/PointLightRetained.java +++ b/src/main/java/org/jogamp/java3d/PointLightRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point3f; /** * A Retained PointLight source. diff --git a/src/javax/media/j3d/PointSound.java b/src/main/java/org/jogamp/java3d/PointSound.java index 907bf5c..5d6eb7c 100644 --- a/src/javax/media/j3d/PointSound.java +++ b/src/main/java/org/jogamp/java3d/PointSound.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3f; /** diff --git a/src/javax/media/j3d/PointSoundRetained.java b/src/main/java/org/jogamp/java3d/PointSoundRetained.java index 14117a9..e14c25c 100644 --- a/src/javax/media/j3d/PointSoundRetained.java +++ b/src/main/java/org/jogamp/java3d/PointSoundRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3f; /** * The PointSoundRetained node (a sub-class of the SoundRetained node) defines diff --git a/src/javax/media/j3d/PolygonAttributes.java b/src/main/java/org/jogamp/java3d/PolygonAttributes.java index 4713806..84995ae 100644 --- a/src/javax/media/j3d/PolygonAttributes.java +++ b/src/main/java/org/jogamp/java3d/PolygonAttributes.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/PolygonAttributesRetained.java b/src/main/java/org/jogamp/java3d/PolygonAttributesRetained.java index 53f25e1..edd376c 100644 --- a/src/javax/media/j3d/PolygonAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/PolygonAttributesRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/PositionInterpolator.java b/src/main/java/org/jogamp/java3d/PositionInterpolator.java index 83ad045..2a398a2 100644 --- a/src/javax/media/j3d/PositionInterpolator.java +++ b/src/main/java/org/jogamp/java3d/PositionInterpolator.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3d; /** diff --git a/src/javax/media/j3d/PositionPathInterpolator.java b/src/main/java/org/jogamp/java3d/PositionPathInterpolator.java index f303b10..22715d4 100644 --- a/src/javax/media/j3d/PositionPathInterpolator.java +++ b/src/main/java/org/jogamp/java3d/PositionPathInterpolator.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** diff --git a/src/javax/media/j3d/QuadArray.java b/src/main/java/org/jogamp/java3d/QuadArray.java index 8f5ce57..0af609b 100644 --- a/src/javax/media/j3d/QuadArray.java +++ b/src/main/java/org/jogamp/java3d/QuadArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/QuadArrayRetained.java b/src/main/java/org/jogamp/java3d/QuadArrayRetained.java index b4d728d..f049b4f 100644 --- a/src/javax/media/j3d/QuadArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/QuadArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The QuadArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/Raster.java b/src/main/java/org/jogamp/java3d/Raster.java index 9b2cb3c..b1b6bca 100644 --- a/src/javax/media/j3d/Raster.java +++ b/src/main/java/org/jogamp/java3d/Raster.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Dimension; import java.awt.Point; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point3f; /** diff --git a/src/javax/media/j3d/RasterRetained.java b/src/main/java/org/jogamp/java3d/RasterRetained.java index dd8245e..c7cef9e 100644 --- a/src/javax/media/j3d/RasterRetained.java +++ b/src/main/java/org/jogamp/java3d/RasterRetained.java @@ -24,17 +24,17 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Dimension; import java.awt.Point; import java.util.ArrayList; -import javax.vecmath.Point2d; -import javax.vecmath.Point2i; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point2d; +import org.jogamp.vecmath.Point2i; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Point4d; /** * A Retained Raster. diff --git a/src/javax/media/j3d/RenderAtom.java b/src/main/java/org/jogamp/java3d/RenderAtom.java index 1d1bb8d..64d780b 100644 --- a/src/javax/media/j3d/RenderAtom.java +++ b/src/main/java/org/jogamp/java3d/RenderAtom.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A RenderAtom is a wrapper for a GeometryAtom in a given RenderBin. diff --git a/src/javax/media/j3d/RenderAtomListInfo.java b/src/main/java/org/jogamp/java3d/RenderAtomListInfo.java index aaddcd3..76f0fdb 100644 --- a/src/javax/media/j3d/RenderAtomListInfo.java +++ b/src/main/java/org/jogamp/java3d/RenderAtomListInfo.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Information per geometry in the renderAtom, there are several * of these per RenderAtom, one per geometry in GeometryAtom diff --git a/src/javax/media/j3d/RenderBin.java b/src/main/java/org/jogamp/java3d/RenderBin.java index aacef06..99def73 100644 --- a/src/javax/media/j3d/RenderBin.java +++ b/src/main/java/org/jogamp/java3d/RenderBin.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; @@ -33,11 +33,12 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The RenderBin is a structure that optimizes rendering by doing efficient @@ -263,7 +264,7 @@ ArrayList<ArrayList<OrderedBin>> toBeAddedBinList = new ArrayList<ArrayList<Orde * that the same snapshot of the geometry is rendered * across all canvases */ -ArrayList<GeometryRetained> lockGeometryList = new ArrayList<GeometryRetained>(5); +LinkedHashSet<GeometryRetained> lockGeometryList = new LinkedHashSet<GeometryRetained>(5); /** @@ -296,7 +297,7 @@ ArrayList<OrderedBin> bgOrderedBins = new ArrayList<OrderedBin>(5); // List of node components that need special processing, due to // extensions - ArrayList nodeComponentList = new ArrayList(5); + LinkedHashSet<ImageComponentRetained> nodeComponentList = new LinkedHashSet<ImageComponentRetained>(); // List of node components ***for this frame*** that need special @@ -5665,8 +5666,8 @@ void reEvaluateEnv(ArrayList<LightRetained> mLts, ArrayList<FogRetained> fogs, // Vertex array is locked for every time renderer is run size = lockGeometryList.size(); - for (int i = 0; i < size; i++) { - GeometryRetained geo = lockGeometryList.get(i); + for (GeometryRetained geo : lockGeometryList) + { geo.geomLock.getLock(); } @@ -5680,9 +5681,9 @@ void reEvaluateEnv(ArrayList<LightRetained> mLts, ArrayList<FogRetained> fogs, // Lock all the by reference image components size = nodeComponentList.size(); - for (int i = 0; i < size; i++) { - ImageComponentRetained nc = (ImageComponentRetained)nodeComponentList.get(i); - nc.geomLock.getLock(); + for (ImageComponentRetained nc : nodeComponentList) + { + nc.geomLock.getLock(); } } @@ -5691,8 +5692,8 @@ void reEvaluateEnv(ArrayList<LightRetained> mLts, ArrayList<FogRetained> fogs, int size; size = lockGeometryList.size(); - for (int i = 0; i < size; i++) { - GeometryRetained geo = lockGeometryList.get(i); + for (GeometryRetained geo : lockGeometryList) + { geo.geomLock.unLock(); } @@ -5704,9 +5705,7 @@ void reEvaluateEnv(ArrayList<LightRetained> mLts, ArrayList<FogRetained> fogs, // Clear the display list clear list dlistLockList.clear(); // Lock all the by reference image components - size = nodeComponentList.size(); - for (int i = 0; i < size; i++) { - ImageComponentRetained nc = (ImageComponentRetained)nodeComponentList.get(i); + for(ImageComponentRetained nc : nodeComponentList){ nc.geomLock.unLock(); } } diff --git a/src/javax/media/j3d/RenderMethod.java b/src/main/java/org/jogamp/java3d/RenderMethod.java index 2e603c0..be64e4e 100644 --- a/src/javax/media/j3d/RenderMethod.java +++ b/src/main/java/org/jogamp/java3d/RenderMethod.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The RenderMethod interface is used to create various ways to render diff --git a/src/javax/media/j3d/RenderMolecule.java b/src/main/java/org/jogamp/java3d/RenderMolecule.java index 269c1a0..9ea0ed2 100644 --- a/src/javax/media/j3d/RenderMolecule.java +++ b/src/main/java/org/jogamp/java3d/RenderMolecule.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3d; /** * The RenderMolecule manages a collection of RenderAtoms. diff --git a/src/javax/media/j3d/Renderer.java b/src/main/java/org/jogamp/java3d/Renderer.java index 7116842..2899318 100644 --- a/src/javax/media/j3d/Renderer.java +++ b/src/main/java/org/jogamp/java3d/Renderer.java @@ -30,7 +30,7 @@ * of the Java 3D API. */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.GraphicsConfiguration; import java.awt.Point; @@ -620,63 +620,6 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine if (canvas.isFatalError()) { continue; } - - if (canvas.ctx == null) { - synchronized (VirtualUniverse.mc.contextCreationLock) { - canvas.ctx = canvas.createNewContext(null, false); - - if (canvas.ctx == null) { - canvas.drawingSurfaceObject.unLock(); - // Issue 260 : indicate fatal error and notify error listeners - canvas.setFatalError(); - RenderingError err = - new RenderingError(RenderingError.CONTEXT_CREATION_ERROR, - J3dI18N.getString("Renderer7")); - err.setCanvas3D(canvas); - err.setGraphicsDevice(canvas.graphicsConfiguration.getDevice()); - notifyErrorListeners(err); - - break doneRender; - } - // createNewContext finishes with a release, re-make current so the init calls below work - canvas.makeCtxCurrent(); - - if (canvas.graphics2D != null) { - canvas.graphics2D.init(); - } - - canvas.ctxTimeStamp = VirtualUniverse.mc.getContextTimeStamp(); - canvas.screen.renderer.listOfCtxs.add(canvas.ctx); - canvas.screen.renderer.listOfCanvases.add(canvas); - - // enable separate specular color - canvas.enableSeparateSpecularColor(); - } - - // create the cache texture state in canvas - // for state download checking purpose - if (canvas.texUnitState == null) { - canvas.createTexUnitState(); - } - - canvas.drawingSurfaceObject.contextValidated(); - canvas.screen.renderer.currentCtx = canvas.ctx; - canvas.screen.renderer.currentDrawable = canvas.drawable; - canvas.graphicsContext3D.initializeState(); - canvas.ctxChanged = true; - canvas.canvasDirty = 0xffff; - // Update Appearance - canvas.graphicsContext3D.updateState(canvas.view.renderBin, RenderMolecule.SURFACE); - - - canvas.currentLights = new LightRetained[canvas.getNumCtxLights(canvas.ctx)]; - - for (j=0; j<canvas.currentLights.length; j++) { - canvas.currentLights[j] = null; - } - } - - canvas.makeCtxCurrent(); try { @@ -814,7 +757,6 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine } m[nmesg++].decRefcount(); - canvas.releaseCtx(); } else { // retained mode rendering long startRenderTime = 0L; if (MasterControl.isStatsLoggable(Level.INFO)) { @@ -970,14 +912,10 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine listOfCtxs.add(canvas.ctx); listOfCanvases.add(canvas); - if (renderBin.nodeComponentList.size() > 0) { - for (i = 0; i < renderBin.nodeComponentList.size(); i++) { - NodeComponentRetained nc = (NodeComponentRetained)renderBin.nodeComponentList.get(i); - if(nc instanceof ImageComponentRetained) { - ((ImageComponentRetained)nc).evaluateExtensions(canvas); - } + for (ImageComponentRetained nc : renderBin.nodeComponentList) + { + nc.evaluateExtensions(canvas); } - } // enable separate specular color canvas.enableSeparateSpecularColor(); @@ -1509,19 +1447,18 @@ ArrayList<TextureRetained> textureIDResourceTable = new ArrayList<TextureRetaine } catch (RuntimeException ex) { ex.printStackTrace(); - if (canvas != null) { + RenderingError err = new RenderingError(RenderingError.UNEXPECTED_RENDERING_ERROR, J3dI18N.getString("Renderer8")); + err.setCanvas3D(canvas); +if (canvas != null) { // drawingSurfaceObject will safely ignore // this request if this is not lock before canvas.drawingSurfaceObject.unLock(); - } + // Issue 260 : indicate fatal error and notify error listeners + canvas.setFatalError(); + err.setGraphicsDevice(canvas.graphicsConfiguration.getDevice()); +} - // Issue 260 : indicate fatal error and notify error listeners - canvas.setFatalError(); - RenderingError err = - new RenderingError(RenderingError.UNEXPECTED_RENDERING_ERROR, - J3dI18N.getString("Renderer8")); - err.setCanvas3D(canvas); - err.setGraphicsDevice(canvas.graphicsConfiguration.getDevice()); + notifyErrorListeners(err); } } diff --git a/src/javax/media/j3d/RendererStructure.java b/src/main/java/org/jogamp/java3d/RendererStructure.java index b8dbc6c..447d41e 100644 --- a/src/javax/media/j3d/RendererStructure.java +++ b/src/main/java/org/jogamp/java3d/RendererStructure.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/RenderingAttributes.java b/src/main/java/org/jogamp/java3d/RenderingAttributes.java index 0b545c7..ab006ff 100644 --- a/src/javax/media/j3d/RenderingAttributes.java +++ b/src/main/java/org/jogamp/java3d/RenderingAttributes.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The RenderingAttributes object defines common rendering attributes diff --git a/src/javax/media/j3d/RenderingAttributesRetained.java b/src/main/java/org/jogamp/java3d/RenderingAttributesRetained.java index 5f67c54..d35ebbe 100644 --- a/src/javax/media/j3d/RenderingAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/RenderingAttributesRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/RenderingAttributesStructure.java b/src/main/java/org/jogamp/java3d/RenderingAttributesStructure.java index 67ba1ef..02feec9 100644 --- a/src/javax/media/j3d/RenderingAttributesStructure.java +++ b/src/main/java/org/jogamp/java3d/RenderingAttributesStructure.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/javax/media/j3d/RenderingEnvironmentStructure.java b/src/main/java/org/jogamp/java3d/RenderingEnvironmentStructure.java index a7e55f2..b5e7de8 100644 --- a/src/javax/media/j3d/RenderingEnvironmentStructure.java +++ b/src/main/java/org/jogamp/java3d/RenderingEnvironmentStructure.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3d; /** * A rendering environment structure is an object that organizes lights, diff --git a/src/javax/media/j3d/RenderingError.java b/src/main/java/org/jogamp/java3d/RenderingError.java index da68dd9..9738e29 100644 --- a/src/javax/media/j3d/RenderingError.java +++ b/src/main/java/org/jogamp/java3d/RenderingError.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.GraphicsDevice; import java.io.PrintStream; diff --git a/src/javax/media/j3d/RenderingErrorListener.java b/src/main/java/org/jogamp/java3d/RenderingErrorListener.java index 3269e0d..669c6aa 100644 --- a/src/javax/media/j3d/RenderingErrorListener.java +++ b/src/main/java/org/jogamp/java3d/RenderingErrorListener.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Listener interface for monitoring Java 3D rendering errors. diff --git a/src/javax/media/j3d/RestrictedAccessException.java b/src/main/java/org/jogamp/java3d/RestrictedAccessException.java index 3b992f5..cc7e92a 100644 --- a/src/javax/media/j3d/RestrictedAccessException.java +++ b/src/main/java/org/jogamp/java3d/RestrictedAccessException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates an attempt to access or modify a state variable diff --git a/src/javax/media/j3d/RotPosPathInterpolator.java b/src/main/java/org/jogamp/java3d/RotPosPathInterpolator.java index 4e91d69..be43b3d 100644 --- a/src/javax/media/j3d/RotPosPathInterpolator.java +++ b/src/main/java/org/jogamp/java3d/RotPosPathInterpolator.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Matrix4d; -import javax.vecmath.Point3f; -import javax.vecmath.Quat4f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Matrix4d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Quat4f; +import org.jogamp.vecmath.Vector3f; /** diff --git a/src/javax/media/j3d/RotPosScalePathInterpolator.java b/src/main/java/org/jogamp/java3d/RotPosScalePathInterpolator.java index 3114f66..c82f573 100644 --- a/src/javax/media/j3d/RotPosScalePathInterpolator.java +++ b/src/main/java/org/jogamp/java3d/RotPosScalePathInterpolator.java @@ -24,12 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Matrix4d; -import javax.vecmath.Point3f; -import javax.vecmath.Quat4f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Matrix4d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Quat4f; +import org.jogamp.vecmath.Vector3f; /** diff --git a/src/javax/media/j3d/RotationInterpolator.java b/src/main/java/org/jogamp/java3d/RotationInterpolator.java index f536685..9ad48a7 100644 --- a/src/javax/media/j3d/RotationInterpolator.java +++ b/src/main/java/org/jogamp/java3d/RotationInterpolator.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/RotationPathInterpolator.java b/src/main/java/org/jogamp/java3d/RotationPathInterpolator.java index 6f49627..b8a280d 100644 --- a/src/javax/media/j3d/RotationPathInterpolator.java +++ b/src/main/java/org/jogamp/java3d/RotationPathInterpolator.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Quat4f; +import org.jogamp.vecmath.Quat4f; /** diff --git a/src/javax/media/j3d/ScaleInterpolator.java b/src/main/java/org/jogamp/java3d/ScaleInterpolator.java index 858967c..ed6eb55 100644 --- a/src/javax/media/j3d/ScaleInterpolator.java +++ b/src/main/java/org/jogamp/java3d/ScaleInterpolator.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Scale interpolation behavior. This class defines a behavior diff --git a/src/javax/media/j3d/SceneGraphCycleException.java b/src/main/java/org/jogamp/java3d/SceneGraphCycleException.java index baf8b9a..ada25f3 100644 --- a/src/javax/media/j3d/SceneGraphCycleException.java +++ b/src/main/java/org/jogamp/java3d/SceneGraphCycleException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates a graph that contains a cycle. diff --git a/src/javax/media/j3d/SceneGraphObject.java b/src/main/java/org/jogamp/java3d/SceneGraphObject.java index db0eb53..230d6a1 100644 --- a/src/javax/media/j3d/SceneGraphObject.java +++ b/src/main/java/org/jogamp/java3d/SceneGraphObject.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; @@ -133,7 +133,7 @@ public abstract class SceneGraphObject extends Object { * Method to set default read capability bits to true */ void setDefaultReadCapabilities(int[] bits) { - if (true /*VirtualUniverse.mc.defaultReadCapability*/) { + if (VirtualUniverse.mc.defaultReadCapability) { for (int i=0; i < bits.length; i++) { setCapability(bits[i]); } diff --git a/src/javax/media/j3d/SceneGraphObjectRetained.java b/src/main/java/org/jogamp/java3d/SceneGraphObjectRetained.java index 09000a7..f94b2a9 100644 --- a/src/javax/media/j3d/SceneGraphObjectRetained.java +++ b/src/main/java/org/jogamp/java3d/SceneGraphObjectRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** @@ -151,10 +151,12 @@ abstract class SceneGraphObjectRetained extends IndexedObject void traverse(boolean sameLevel, int level) { System.err.println(); - for (int i = 0; i < level; i++) { + for (int i = 0; i < level; i++) + { System.err.print("."); } - System.err.print(this); + System.err.print( + this.source.getName() + " ret:" + this.getClass().getSimpleName() + " source:" + this.source.getClass().getSimpleName()); } /** diff --git a/src/javax/media/j3d/SceneGraphPath.java b/src/main/java/org/jogamp/java3d/SceneGraphPath.java index aac2f9d..0246aca 100644 --- a/src/javax/media/j3d/SceneGraphPath.java +++ b/src/main/java/org/jogamp/java3d/SceneGraphPath.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Point4d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point4d; /** * A SceneGraphPath object represents the path from a Locale to a @@ -448,7 +448,7 @@ public class SceneGraphPath { str.append(", " + obj); try { - if (item.getClass().getName().equals("javax.media.j3d.Shape3D")) + if (item.getClass().getName().equals("org.jogamp.java3d.Shape3D")) str.append( ((Shape3D)item).getGeometry() ); } catch( CapabilityNotSetException e) {} diff --git a/src/javax/media/j3d/Screen3D.java b/src/main/java/org/jogamp/java3d/Screen3D.java index 988dc97..effc38a 100644 --- a/src/javax/media/j3d/Screen3D.java +++ b/src/main/java/org/jogamp/java3d/Screen3D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.Dimension; import java.awt.GraphicsConfiguration; diff --git a/src/javax/media/j3d/ScreenViewCache.java b/src/main/java/org/jogamp/java3d/ScreenViewCache.java index bc4cdd1..818a8ce 100644 --- a/src/javax/media/j3d/ScreenViewCache.java +++ b/src/main/java/org/jogamp/java3d/ScreenViewCache.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/Sensor.java b/src/main/java/org/jogamp/java3d/Sensor.java index dea9fbf..f440644 100644 --- a/src/javax/media/j3d/Sensor.java +++ b/src/main/java/org/jogamp/java3d/Sensor.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Matrix3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Matrix3d; +import org.jogamp.vecmath.Point3d; /** * The Sensor Class encapsulates an object that provides real-time diff --git a/src/javax/media/j3d/SensorRead.java b/src/main/java/org/jogamp/java3d/SensorRead.java index e64c9c5..d8475ce 100644 --- a/src/javax/media/j3d/SensorRead.java +++ b/src/main/java/org/jogamp/java3d/SensorRead.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/SetLiveState.java b/src/main/java/org/jogamp/java3d/SetLiveState.java index 42ee62a..dda33fb 100644 --- a/src/javax/media/j3d/SetLiveState.java +++ b/src/main/java/org/jogamp/java3d/SetLiveState.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/Shader.java b/src/main/java/org/jogamp/java3d/Shader.java index 8aa700c..1df6d28 100644 --- a/src/javax/media/j3d/Shader.java +++ b/src/main/java/org/jogamp/java3d/Shader.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The Shader object is the abstract base class for programmable @@ -114,7 +114,7 @@ public abstract class Shader extends NodeComponent { /** * Package scope constructor so it can't be subclassed by classes - * outside the javax.media.j3d package. + * outside the org.jogamp.java3d package. */ Shader(int shadingLanguage, int shaderType) { ((ShaderRetained)this.retained).initializeShader(shadingLanguage, shaderType); diff --git a/src/javax/media/j3d/ShaderAppearance.java b/src/main/java/org/jogamp/java3d/ShaderAppearance.java index 62da973..b09f2ee 100644 --- a/src/javax/media/j3d/ShaderAppearance.java +++ b/src/main/java/org/jogamp/java3d/ShaderAppearance.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; diff --git a/src/javax/media/j3d/ShaderAppearanceRetained.java b/src/main/java/org/jogamp/java3d/ShaderAppearanceRetained.java index da41886..a34d524 100644 --- a/src/javax/media/j3d/ShaderAppearanceRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderAppearanceRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/ShaderAttrLoc.java b/src/main/java/org/jogamp/java3d/ShaderAttrLoc.java index 5e36adc..684d6a3 100644 --- a/src/javax/media/j3d/ShaderAttrLoc.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttrLoc.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Tagging interface for shader attribute location objects. The rendering diff --git a/src/javax/media/j3d/ShaderAttribute.java b/src/main/java/org/jogamp/java3d/ShaderAttribute.java index 2dae7fe..fb523f0 100644 --- a/src/javax/media/j3d/ShaderAttribute.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttribute.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ShaderAttributeArray.java b/src/main/java/org/jogamp/java3d/ShaderAttributeArray.java index 13be68a..430d8bb 100644 --- a/src/javax/media/j3d/ShaderAttributeArray.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** @@ -160,4 +160,36 @@ public class ShaderAttributeArray extends ShaderAttributeObject { this.retained = new ShaderAttributeArrayRetained(); this.retained.setSource(this); } + + + @Override + public boolean equals(Object anObject) + { + if (this == anObject) + { + return true; + } + if (anObject instanceof ShaderAttributeArray) + { + ShaderAttributeArray anotherShaderAttributeArray = (ShaderAttributeArray) anObject; + if (this.getAttributeName().equals(anotherShaderAttributeArray.getAttributeName())) + { + Object[] values = (Object[]) getValue(); + Object[] otherValues = (Object[]) anotherShaderAttributeArray.getValue(); + int n = values.length; + if (n == otherValues.length) + { + int i = 0; + while (n-- != 0) + { + if (!values[i].equals(otherValues[i])) + return false; + i++; + } + return true; + } + } + } + return false; + } } diff --git a/src/javax/media/j3d/ShaderAttributeArrayRetained.java b/src/main/java/org/jogamp/java3d/ShaderAttributeArrayRetained.java index 48111bf..c8904be 100644 --- a/src/javax/media/j3d/ShaderAttributeArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeArrayRetained.java @@ -24,22 +24,22 @@ * */ -package javax.media.j3d; - -import javax.vecmath.Matrix3f; -import javax.vecmath.Matrix4f; -import javax.vecmath.Point2f; -import javax.vecmath.Point2i; -import javax.vecmath.Point3f; -import javax.vecmath.Point3i; -import javax.vecmath.Point4f; -import javax.vecmath.Point4i; -import javax.vecmath.Tuple2f; -import javax.vecmath.Tuple2i; -import javax.vecmath.Tuple3f; -import javax.vecmath.Tuple3i; -import javax.vecmath.Tuple4f; -import javax.vecmath.Tuple4i; +package org.jogamp.java3d; + +import org.jogamp.vecmath.Matrix3f; +import org.jogamp.vecmath.Matrix4f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point2i; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Point3i; +import org.jogamp.vecmath.Point4f; +import org.jogamp.vecmath.Point4i; +import org.jogamp.vecmath.Tuple2f; +import org.jogamp.vecmath.Tuple2i; +import org.jogamp.vecmath.Tuple3f; +import org.jogamp.vecmath.Tuple3i; +import org.jogamp.vecmath.Tuple4f; +import org.jogamp.vecmath.Tuple4i; /** * The ShaderAttributeArray object encapsulates a uniform shader diff --git a/src/javax/media/j3d/ShaderAttributeBinding.java b/src/main/java/org/jogamp/java3d/ShaderAttributeBinding.java index f0359af..28d3742 100644 --- a/src/javax/media/j3d/ShaderAttributeBinding.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeBinding.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ShaderAttributeBindingRetained.java b/src/main/java/org/jogamp/java3d/ShaderAttributeBindingRetained.java index d11d5cc..4050ea3 100644 --- a/src/javax/media/j3d/ShaderAttributeBindingRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeBindingRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ShaderAttributeObject.java b/src/main/java/org/jogamp/java3d/ShaderAttributeObject.java index 8dc7125..b45526e 100644 --- a/src/javax/media/j3d/ShaderAttributeObject.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeObject.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ShaderAttributeObjectRetained.java b/src/main/java/org/jogamp/java3d/ShaderAttributeObjectRetained.java index eb5d8f7..c8fbe79 100644 --- a/src/javax/media/j3d/ShaderAttributeObjectRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeObjectRetained.java @@ -24,18 +24,18 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Matrix3f; -import javax.vecmath.Matrix4f; -import javax.vecmath.Tuple2f; -import javax.vecmath.Tuple2i; -import javax.vecmath.Tuple3f; -import javax.vecmath.Tuple3i; -import javax.vecmath.Tuple4f; -import javax.vecmath.Tuple4i; +import org.jogamp.vecmath.Matrix3f; +import org.jogamp.vecmath.Matrix4f; +import org.jogamp.vecmath.Tuple2f; +import org.jogamp.vecmath.Tuple2i; +import org.jogamp.vecmath.Tuple3f; +import org.jogamp.vecmath.Tuple3i; +import org.jogamp.vecmath.Tuple4f; +import org.jogamp.vecmath.Tuple4i; /** * The ShaderAttributeObjectRetained class is an abstract class that diff --git a/src/javax/media/j3d/ShaderAttributeRetained.java b/src/main/java/org/jogamp/java3d/ShaderAttributeRetained.java index 3e65fec..03e290e 100644 --- a/src/javax/media/j3d/ShaderAttributeRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ShaderAttributeSet.java b/src/main/java/org/jogamp/java3d/ShaderAttributeSet.java index 2503626..40a7b54 100644 --- a/src/javax/media/j3d/ShaderAttributeSet.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeSet.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ShaderAttributeSetRetained.java b/src/main/java/org/jogamp/java3d/ShaderAttributeSetRetained.java index 2ad4432..e3325fb 100644 --- a/src/javax/media/j3d/ShaderAttributeSetRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeSetRetained.java @@ -24,11 +24,12 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @@ -40,6 +41,8 @@ import java.util.Map; class ShaderAttributeSetRetained extends NodeComponentRetained { private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderAttributeRetained>(); + // to avoid new Iterator calls when iterating + private ArrayList<ShaderAttributeRetained> attrsValues = new ArrayList<ShaderAttributeRetained>(); // Lock used for synchronization of live state Object liveStateLock = new Object(); @@ -66,12 +69,10 @@ private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderA */ void put(ShaderAttribute attr) { synchronized(liveStateLock) { - // System.err.println("ShaderAttributeSetRetained : put()"); ShaderAttributeRetained sAttr = (ShaderAttributeRetained)attr.retained; - // System.err.println("attr is " + attr ); - // System.err.println("attrName is " + sAttr.attrName + " attr.Retained is "+ sAttr ); assert(sAttr != null); attrs.put(sAttr.attrName, sAttr); + attrsValues.add(sAttr); if (source.isLive()) { sAttr.setLive(inBackgroundGroup, refCount); @@ -93,7 +94,11 @@ private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderA * not set and this object is part of live or compiled scene graph */ ShaderAttribute get(String attrName) { - return (ShaderAttribute)attrs.get(attrName).source; + ShaderAttributeRetained sAttr = attrs.get(attrName); + if(sAttr!=null) + return (ShaderAttribute)attrs.get(attrName).source; + else + return null; } /** @@ -107,6 +112,7 @@ private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderA synchronized(liveStateLock) { ShaderAttributeRetained sAttr = attrs.get(attrName); attrs.remove(attrName); + attrsValues.remove(sAttr); if (source.isLive()) { sAttr.clearLive(refCount); sAttr.removeMirrorUsers(this); @@ -131,7 +137,7 @@ private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderA synchronized(liveStateLock) { String attrName = attr.getAttributeName(); if (attrs.get(attrName) == attr.retained) { - attrs.remove(attrName); + attrsValues.remove(attrs.remove(attrName)); if (source.isLive()) { ((ShaderAttributeRetained)attr.retained).clearLive(refCount); ((ShaderAttributeRetained)attr.retained).removeMirrorUsers(this); @@ -149,7 +155,7 @@ private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderA */ void clear() { synchronized(liveStateLock) { - attrs.clear(); + if(source.isLive()) { ShaderAttributeRetained[] sAttrs = new ShaderAttributeRetained[attrs.size()]; sAttrs = attrs.values().toArray(sAttrs); @@ -159,6 +165,8 @@ private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderA } sendMessage(ShaderConstants.ATTRIBUTE_SET_CLEAR, null); } + attrs.clear(); + attrsValues.clear(); } } @@ -199,10 +207,14 @@ Map<String, ShaderAttributeRetained> getAttrs() { return attrs; } +List< ShaderAttributeRetained> getAttrValues() { + return attrsValues; +} + + @Override void setLive(boolean backgroundGroup, int refCount) { - // System.err.println("ShaderAttributeSetRetained.setLive()"); ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { @@ -261,7 +273,6 @@ Map<String, ShaderAttributeRetained> getAttrs() { @Override void clearLive(int refCount) { - // System.err.println("ShaderAttributeSetRetained.clearLive()"); super.clearLive(refCount); @@ -274,7 +285,6 @@ Map<String, ShaderAttributeRetained> getAttrs() { @Override synchronized void createMirrorObject() { - // System.err.println("ShaderAttributeSetRetained : createMirrorObject"); // This method should only call by setLive(). if (mirror == null) { ShaderAttributeSetRetained mirrorSAS = new ShaderAttributeSetRetained(); @@ -295,6 +305,7 @@ Map<String, ShaderAttributeRetained> getAttrs() { ShaderAttributeRetained mirrorSA = (ShaderAttributeRetained) sAttrs[i].mirror; assert(mirrorSA != null); ((ShaderAttributeSetRetained)mirror).attrs.put(mirrorSA.attrName, mirrorSA); + ((ShaderAttributeSetRetained)mirror).attrsValues.add(mirrorSA); } } @@ -304,23 +315,21 @@ Map<String, ShaderAttributeRetained> getAttrs() { @Override synchronized void updateMirrorObject(int component, Object value) { - // System.err.println("ShaderAttributeSetRetained : updateMirrorObject"); - ShaderAttributeSetRetained mirrorSAS = (ShaderAttributeSetRetained)mirror; if ((component & ShaderConstants.ATTRIBUTE_SET_PUT) != 0) { - // System.err.println(" -- ATTRIBUTE_SET_PUT"); ShaderAttributeRetained mirrorSA = (ShaderAttributeRetained)value; assert(mirrorSA != null); ((ShaderAttributeSetRetained)mirror).attrs.put(mirrorSA.attrName, mirrorSA); + ((ShaderAttributeSetRetained)mirror).attrsValues.add(mirrorSA); } else if((component & ShaderConstants.ATTRIBUTE_SET_REMOVE) != 0) { - // System.err.println(" -- ATTRIBUTE_SET_REMOVE"); - ((ShaderAttributeSetRetained)mirror).attrs.remove((String)value); + ((ShaderAttributeSetRetained)mirror).attrsValues.remove(((ShaderAttributeSetRetained)mirror).attrs.remove((String)value)); + } else if((component & ShaderConstants.ATTRIBUTE_SET_CLEAR) != 0) { - // System.err.println(" -- ATTRIBUTE_SET_CLEAR"); ((ShaderAttributeSetRetained)mirror).attrs.clear(); + ((ShaderAttributeSetRetained)mirror).attrsValues.clear(); } else { assert(false); @@ -341,11 +350,9 @@ Map<String, ShaderAttributeRetained> getAttrs() { createMessage.args[0] = this; createMessage.args[1]= new Integer(attrMask); createMessage.args[2] = attr; - // System.err.println("changedFreqent1 = "+changedFrequent); createMessage.args[3] = new Integer(changedFrequent); VirtualUniverse.mc.processMessage(createMessage); - // System.err.println("univList.size is " + univList.size()); for(int i=0; i<univList.size(); i++) { createMessage = new J3dMessage(); createMessage.threads = J3dThread.UPDATE_RENDER; diff --git a/src/javax/media/j3d/ShaderAttributeValue.java b/src/main/java/org/jogamp/java3d/ShaderAttributeValue.java index 2d2e085..9a29a99 100644 --- a/src/javax/media/j3d/ShaderAttributeValue.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeValue.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** @@ -112,5 +112,25 @@ public class ShaderAttributeValue extends ShaderAttributeObject { this.retained = new ShaderAttributeValueRetained(); this.retained.setSource(this); } + + @Override + public boolean equals(Object anObject) + { + if (this == anObject) + { + return true; + } + if (anObject instanceof ShaderAttributeValue) + { + ShaderAttributeValue anotherShaderAttributeValue = (ShaderAttributeValue) anObject; + if (this.getAttributeName().equals(anotherShaderAttributeValue.getAttributeName())) + { + Object value = ((ShaderAttributeValueRetained) this.retained).getValue(); + Object otherValue = ((ShaderAttributeValueRetained) anotherShaderAttributeValue.retained).getValue(); + return value.equals(otherValue); + } + } + return false; + } } diff --git a/src/javax/media/j3d/ShaderAttributeValueRetained.java b/src/main/java/org/jogamp/java3d/ShaderAttributeValueRetained.java index 9555355..1d5d338 100644 --- a/src/javax/media/j3d/ShaderAttributeValueRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderAttributeValueRetained.java @@ -24,22 +24,22 @@ * */ -package javax.media.j3d; - -import javax.vecmath.Matrix3f; -import javax.vecmath.Matrix4f; -import javax.vecmath.Point2f; -import javax.vecmath.Point2i; -import javax.vecmath.Point3f; -import javax.vecmath.Point3i; -import javax.vecmath.Point4f; -import javax.vecmath.Point4i; -import javax.vecmath.Tuple2f; -import javax.vecmath.Tuple2i; -import javax.vecmath.Tuple3f; -import javax.vecmath.Tuple3i; -import javax.vecmath.Tuple4f; -import javax.vecmath.Tuple4i; +package org.jogamp.java3d; + +import org.jogamp.vecmath.Matrix3f; +import org.jogamp.vecmath.Matrix4f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point2i; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Point3i; +import org.jogamp.vecmath.Point4f; +import org.jogamp.vecmath.Point4i; +import org.jogamp.vecmath.Tuple2f; +import org.jogamp.vecmath.Tuple2i; +import org.jogamp.vecmath.Tuple3f; +import org.jogamp.vecmath.Tuple3i; +import org.jogamp.vecmath.Tuple4f; +import org.jogamp.vecmath.Tuple4i; /** * The ShaderAttributeValueRetained object encapsulates a uniform shader diff --git a/src/javax/media/j3d/ShaderBin.java b/src/main/java/org/jogamp/java3d/ShaderBin.java index 520e64c..bd3e825 100644 --- a/src/javax/media/j3d/ShaderBin.java +++ b/src/main/java/org/jogamp/java3d/ShaderBin.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Map; diff --git a/src/javax/media/j3d/ShaderConstants.java b/src/main/java/org/jogamp/java3d/ShaderConstants.java index 4a090c7..516094c 100644 --- a/src/javax/media/j3d/ShaderConstants.java +++ b/src/main/java/org/jogamp/java3d/ShaderConstants.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The ShaderConstants class contains internal constants used by other diff --git a/src/javax/media/j3d/ShaderError.java b/src/main/java/org/jogamp/java3d/ShaderError.java index 705aacc..7554bb0 100644 --- a/src/javax/media/j3d/ShaderError.java +++ b/src/main/java/org/jogamp/java3d/ShaderError.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.io.PrintStream; diff --git a/src/javax/media/j3d/ShaderErrorListener.java b/src/main/java/org/jogamp/java3d/ShaderErrorListener.java index 0e02e8f..261db4c 100644 --- a/src/javax/media/j3d/ShaderErrorListener.java +++ b/src/main/java/org/jogamp/java3d/ShaderErrorListener.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Listener interface for monitoring errors in Shader Programs. diff --git a/src/javax/media/j3d/ShaderId.java b/src/main/java/org/jogamp/java3d/ShaderId.java index eb50c35..60d927e 100644 --- a/src/javax/media/j3d/ShaderId.java +++ b/src/main/java/org/jogamp/java3d/ShaderId.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Tagging interface for shader objects. The rendering pipelines diff --git a/src/javax/media/j3d/ShaderProgram.java b/src/main/java/org/jogamp/java3d/ShaderProgram.java index 46499a1..fc87cd4 100644 --- a/src/javax/media/j3d/ShaderProgram.java +++ b/src/main/java/org/jogamp/java3d/ShaderProgram.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The ShaderProgram node component object is the abstract base class @@ -75,7 +75,7 @@ public abstract class ShaderProgram extends NodeComponent { /** * Package scope constructor so it can't be subclassed by classes - * outside the javax.media.j3d package. + * outside the org.jogamp.java3d package. */ ShaderProgram() { // set default read capabilities diff --git a/src/javax/media/j3d/ShaderProgramId.java b/src/main/java/org/jogamp/java3d/ShaderProgramId.java index 3f22fb3..51e0ac7 100644 --- a/src/javax/media/j3d/ShaderProgramId.java +++ b/src/main/java/org/jogamp/java3d/ShaderProgramId.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Tagging interface for shader program objects. The rendering pipelines diff --git a/src/main/java/org/jogamp/java3d/ShaderProgramRetained.java b/src/main/java/org/jogamp/java3d/ShaderProgramRetained.java new file mode 100644 index 0000000..250cb40 --- /dev/null +++ b/src/main/java/org/jogamp/java3d/ShaderProgramRetained.java @@ -0,0 +1,1316 @@ +/* + * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +package org.jogamp.java3d; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +/** + * The ShaderProgramRetained object is a component object of an AppearanceRetained + * object that defines the shader properties used when programmable shader is + * enabled. ShaderProgramRetained object is an abstract class. All shader program + * objects must be created as either a GLSLShaderProgramRetained object or a + * CgShaderProgramRetained object. + */ +abstract class ShaderProgramRetained extends NodeComponentRetained +{ + + // Each element in the array corresponds to a unique renderer if shared + // context or a unique canvas otherwise. + protected ShaderProgramData shaderProgramData[]; + + // Flag indicating whether an UNSUPPORTED_LANGUAGE_ERROR has + // already been reported for this shader program object. It is + // set in verifyShaderProgram and cleared in setLive or clearLive. + // TODO KCR: Add code to clear this in setLive or clearLive + private boolean unsupportedErrorReported = false; + + // Flag indicating whether a LINK_ERROR has occurred for this shader program + // object. It is set in updateNative to indicate that the linkShaderProgram + // operation failed. It is cleared in setLive or clearLive. + // TODO KCR: Add code to clear this in setLive or clearLive + private boolean linkErrorOccurred = false; + + // an array of shaders used by this shader program + protected ShaderRetained[] shaders; + + // an array of vertex attribute names + protected String[] vertexAttrNames; + + // an array of (uniform) shader attribute names + protected String[] shaderAttrNames; + + // Set of ShaderAttribute objects for which we have already reported an error + private HashSet<ShaderAttribute> shaderAttrErrorSet = null; + + // need to synchronize access from multiple rendering threads + Object resourceLock = new Object(); + + // Package-scope default constructor + ShaderProgramRetained() + { + } + + /** + * Sets the vertex attribute names array for this ShaderProgram + * object. Each element in the array specifies the shader + * attribute name that is bound to the corresponding numbered + * vertex attribute within a GeometryArray object that uses this + * shader program. Array element 0 specifies the name of + * GeometryArray vertex attribute 0, array element 1 specifies the + * name of GeometryArray vertex attribute 1, and so forth. + * The array of names may be null or empty (0 length), but the + * elements of the array must be non-null. + * + * @param vertexAttrNames array of vertex attribute names for this + * shader program. A copy of this array is made. + */ + void setVertexAttrNames(String[] vertexAttrNames) + { + if (vertexAttrNames == null) + { + this.vertexAttrNames = null; + } + else + { + this.vertexAttrNames = vertexAttrNames.clone(); + } + } + + /** + * Retrieves the vertex attribute names array from this + * ShaderProgram object. + * + * @return a copy of this ShaderProgram's array of vertex attribute names. + */ + String[] getVertexAttrNames() + { + + if (vertexAttrNames == null) + { + return null; + } + + return vertexAttrNames.clone(); + + } + + /** + * Sets the shader attribute names array for this ShaderProgram + * object. Each element in the array specifies a shader + * attribute name that may be set via a ShaderAttribute object. + * Only those attributes whose names that appear in the shader + * attribute names array can be set for a given shader program. + * The array of names may be null or empty (0 length), but the + * elements of the array must be non-null. + * + * @param shaderAttrNames array of shader attribute names for this + * shader program. A copy of this array is made. + */ + void setShaderAttrNames(String[] shaderAttrNames) + { + if (shaderAttrNames == null) + { + this.shaderAttrNames = null; + } + else + { + this.shaderAttrNames = shaderAttrNames.clone(); + } + } + + /** + * Retrieves the shader attribute names array from this + * ShaderProgram object. + * + * @return a copy of this ShaderProgram's array of shader attribute names. + */ + + String[] getShaderAttrNames() + { + + if (shaderAttrNames == null) + { + return null; + } + + return shaderAttrNames.clone(); + + } + + /** + * Copies the specified array of shaders into this shader + * program. This method makes a shallow copy of the array. The + * array of shaders may be null or empty (0 length), but the + * elements of the array must be non-null. The shading + * language of each shader in the array must match the + * subclass. Subclasses may impose additional restrictions. + * + * @param shaders array of Shader objects to be copied into this + * ShaderProgram + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception IllegalArgumentException if the shading language of + * any shader in the shaders array doesn't match the type of the + * subclass. + */ + void setShaders(Shader[] shaders) + { + + if (shaders == null) + { + this.shaders = null; + return; + } + + this.shaders = new ShaderRetained[shaders.length]; + + // Copy vertex and fragment shader + for (int i = 0; i < shaders.length; i++) + { + this.shaders[i] = (ShaderRetained) shaders[i].retained; + } + + } + + /** + * Retrieves the array of shaders from this shader program. A + * shallow copy of the array is returned. The return value may + * be null. + * + * @return a copy of this ShaderProgram's array of Shader objects + * + */ + Shader[] getShaders() + { + + if (shaders == null) + { + return null; + } + else + { + Shader shads[] = new Shader[shaders.length]; + for (int i = 0; i < shaders.length; i++) + { + if (shaders[i] != null) + { + shads[i] = (Shader) shaders[i].source; + } + else + { + shads[i] = null; + } + } + return shads; + } + } + + /** + * Method to create the native shader. + */ + abstract ShaderError createShader(Context ctx, ShaderRetained shader, ShaderId[] shaderIdArr); + + /** + * Method to destroy the native shader. + */ + abstract ShaderError destroyShader(Context ctx, ShaderId shaderId); + + /** + * Method to compile the native shader. + */ + abstract ShaderError compileShader(Context ctx, ShaderId shaderId, String source); + + /** + * Method to create the native shader program. + */ + abstract ShaderError createShaderProgram(Context ctx, ShaderProgramId[] shaderProgramIdArr); + + /** + * Method to destroy the native shader program. + */ + abstract ShaderError destroyShaderProgram(Context ctx, ShaderProgramId shaderProgramId); + + /** + * Method to link the native shader program. + */ + abstract ShaderError linkShaderProgram(Context ctx, ShaderProgramId shaderProgramId, ShaderId[] shaderIds); + + /** + * Method to bind a vertex attribute name to the specified index. + */ + abstract ShaderError bindVertexAttrName(Context ctx, ShaderProgramId shaderProgramId, String attrName, int attrIndex); + + /** + * Method to lookup a list of (uniform) shader attribute names and return + * information about the attributes. + */ + abstract void lookupShaderAttrNames(Context ctx, ShaderProgramId shaderProgramId, String[] attrNames, AttrNameInfo[] attrNameInfoArr); + + /* + * Method to lookup a list of vertex attribute names. + */ + abstract void lookupVertexAttrNames(Context ctx, ShaderProgramId shaderProgramId, String[] attrNames, boolean[] errArr); + + /** + * Method to use the native shader program. + */ + abstract ShaderError enableShaderProgram(Context ctx, ShaderProgramId shaderProgramId); + + /** + * Method to disable the native shader program. + */ + abstract ShaderError disableShaderProgram(Context ctx); + + // ShaderAttributeValue methods + + abstract ShaderError setUniform1i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int value); + + abstract ShaderError setUniform1f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float value); + + abstract ShaderError setUniform2i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value); + + abstract ShaderError setUniform2f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value); + + abstract ShaderError setUniform3i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value); + + abstract ShaderError setUniform3f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value); + + abstract ShaderError setUniform4i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value); + + abstract ShaderError setUniform4f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value); + + abstract ShaderError setUniformMatrix3f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value); + + abstract ShaderError setUniformMatrix4f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value); + + // ShaderAttributeArray methods + + abstract ShaderError setUniform1iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value); + + abstract ShaderError setUniform1fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value); + + abstract ShaderError setUniform2iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value); + + abstract ShaderError setUniform2fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value); + + abstract ShaderError setUniform3iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value); + + abstract ShaderError setUniform3fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value); + + abstract ShaderError setUniform4iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + int[] value); + + abstract ShaderError setUniform4fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements, + float[] value); + + abstract ShaderError setUniformMatrix3fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, + int numElements, float[] value); + + abstract ShaderError setUniformMatrix4fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, + int numElements, float[] value); + + /** + * Method to return a flag indicating whether this + * ShaderProgram is supported on the specified Canvas. + */ + abstract boolean isSupported(Canvas3D cv); + + @Override + void setLive(boolean backgroundGroup, int refCount) + { + + // System.err.println("ShaderProgramRetained.setLive()"); + + if (shaders != null) + { + for (int i = 0; i < shaders.length; i++) + { + shaders[i].setLive(backgroundGroup, refCount); + } + } + + super.doSetLive(backgroundGroup, refCount); + super.markAsLive(); + + } + + @Override + void clearLive(int refCount) + { + + // System.err.println("ShaderProgramRetained.clearLive()"); + + super.clearLive(refCount); + + if (shaders != null) + { + for (int i = 0; i < shaders.length; i++) + { + shaders[i].clearLive(refCount); + } + } + } + + /** + * Method to enable the native shader program. + */ + private ShaderError enableShaderProgram(Canvas3D cv, int cvRdrIndex) + { + assert (cvRdrIndex >= 0); + synchronized (resourceLock) + { + return enableShaderProgram(cv.ctx, shaderProgramData[cvRdrIndex].getShaderProgramId()); + } + + } + + /** + * Method to disable the native shader program. + */ + private ShaderError disableShaderProgram(Canvas3D cv) + { + return disableShaderProgram(cv.ctx); + } + + /** + * Initializes a mirror object. + */ + @Override + synchronized void initMirrorObject() + { + + // Create mirror copy of shaders + if (this.shaders == null) + { + ((ShaderProgramRetained) mirror).shaders = null; + } + else + { + ((ShaderProgramRetained) mirror).shaders = new ShaderRetained[this.shaders.length]; + // Copy vertex and fragment shader + for (int i = 0; i < this.shaders.length; i++) + { + ((ShaderProgramRetained) mirror).shaders[i] = (ShaderRetained) this.shaders[i].mirror; + } + } + ((ShaderProgramRetained) mirror).shaderProgramData = null; + + // Create mirror copy of vertex attribute names + if (this.vertexAttrNames == null) + { + ((ShaderProgramRetained) mirror).vertexAttrNames = null; + } + else + { + ((ShaderProgramRetained) mirror).vertexAttrNames = this.vertexAttrNames.clone(); + } + + // Create mirror copy of shader attribute names + if (this.shaderAttrNames == null) + { + ((ShaderProgramRetained) mirror).shaderAttrNames = null; + } + else + { + ((ShaderProgramRetained) mirror).shaderAttrNames = this.shaderAttrNames.clone(); + } + + // Clear shader attribute error set + ((ShaderProgramRetained) mirror).shaderAttrErrorSet = null; + } + + /** + * Update the "component" field of the mirror object with the given "value" + */ + @Override + synchronized void updateMirrorObject(int component, Object value) + { + + // ShaderProgram can't be modified once it is live. + assert (false); + System.err.println("ShaderProgramRetained : updateMirrorObject NOT IMPLEMENTED YET"); + } + + /** + * Method to create a ShaderProgramData object for the specified + * canvas/renderer if it doesn't already exist. + * + * Issue 378 : reset the ShaderProgramData object if the context + * has been recreated for the particular canvas / renderer. + */ + private void createShaderProgramData(int cvRdrIndex, long ctxTimeStamp) + { + // Create shaderProgram resources if it has not been done. + synchronized (resourceLock) + { + if (shaderProgramData == null) + { + // We rely on Java to initial the array elements to null. + shaderProgramData = new ShaderProgramData[cvRdrIndex + 1]; + } + else if (shaderProgramData.length <= cvRdrIndex) + { + // We rely on Java to initial the array elements to null. + ShaderProgramData[] tempSPData = new ShaderProgramData[cvRdrIndex + 1]; + System.arraycopy(shaderProgramData, 0, tempSPData, 0, shaderProgramData.length); + shaderProgramData = tempSPData; + } + + if (shaderProgramData[cvRdrIndex] == null) + { + shaderProgramData[cvRdrIndex] = new ShaderProgramData(); + } + else if (shaderProgramData[cvRdrIndex].getCtxTimeStamp() != ctxTimeStamp) + { + // Issue 378 - reset the shader program data for this canvas / renderer + // if the context has been recreated + shaderProgramData[cvRdrIndex].reset(); + } + shaderProgramData[cvRdrIndex].setCtxTimeStamp(ctxTimeStamp); + } + } + + /** + * Method to create the native shader program. We must already have + * called createShaderProgramData for this cvRdrIndex. + */ + private ShaderError createShaderProgram(Canvas3D cv, int cvRdrIndex) + { + // Create shaderProgram resources if it has not been done. + synchronized (resourceLock) + { + assert shaderProgramData[cvRdrIndex].getShaderProgramId() == null; + + ShaderProgramId[] spIdArr = new ShaderProgramId[1]; + ShaderError err = createShaderProgram(cv.ctx, spIdArr); + if (err != null) + { + return err; + } + shaderProgramData[cvRdrIndex].setShaderProgramId(spIdArr[0]); + } + + return null; + } + + /** + * Method to link the native shader program. + */ + private ShaderError linkShaderProgram(Canvas3D cv, int cvRdrIndex, ShaderRetained[] shaders) + { + synchronized (resourceLock) + { + ShaderId[] shaderIds = new ShaderId[shaders.length]; + for (int i = 0; i < shaders.length; i++) + { + synchronized (shaders[i]) + { + shaderIds[i] = shaders[i].shaderData[cvRdrIndex].getShaderId(); + } + } + ShaderError err = linkShaderProgram(cv.ctx, shaderProgramData[cvRdrIndex].getShaderProgramId(), shaderIds); + if (err != null) + { + return err; + } + shaderProgramData[cvRdrIndex].setLinked(true); + } + + return null; + } + + private ShaderError bindVertexAttrName(Canvas3D cv, int cvRdrIndex, String attrName, int attrIndex) + { + assert (attrName != null); + synchronized (resourceLock) + { + ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); + // System.err.println("attrName = " + attrName); + ShaderError err = bindVertexAttrName(cv.ctx, shaderProgramId, attrName, attrIndex); + if (err != null) + { + return err; + } + } + return null; + } + + private void lookupVertexAttrNames(Canvas3D cv, int cvRdrIndex, String[] attrNames) + { + synchronized (resourceLock) + { + ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); + + boolean[] errArr = new boolean[attrNames.length]; + lookupVertexAttrNames(cv.ctx, shaderProgramId, attrNames, errArr); + + for (int i = 0; i < attrNames.length; i++) + { + // Report non-fatal error if detected + if (errArr[i]) + { + String errMsg = "Vertex Attribute name lookup failed: " + attrNames[i]; + ShaderError err = new ShaderError(ShaderError.VERTEX_ATTRIBUTE_LOOKUP_ERROR, errMsg); + err.setShaderProgram((ShaderProgram) this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + private void lookupShaderAttrNames(Canvas3D cv, int cvRdrIndex, String[] attrNames) + { + synchronized (resourceLock) + { + ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); + + AttrNameInfo[] attrNameInfoArr = new AttrNameInfo[attrNames.length]; + lookupShaderAttrNames(cv.ctx, shaderProgramId, attrNames, attrNameInfoArr); + + for (int i = 0; i < attrNames.length; i++) + { + shaderProgramData[cvRdrIndex].setAttrNameInfo(attrNames[i], attrNameInfoArr[i]); + + // Report non-fatal error if location is invalid + if (attrNameInfoArr[i].getLocation() == null) + { + String errMsg = "Attribute name lookup failed: " + attrNames[i]; + ShaderError err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_LOOKUP_ERROR, errMsg); + err.setShaderProgram((ShaderProgram) this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + /** + * Method to return the shaderProgram data for the specified canvas or renderer + */ + private ShaderProgramData getShaderProgramData(int cvRdrIndex) + { + synchronized (resourceLock) + { + return shaderProgramData[cvRdrIndex]; + } + } + + /** + * Method to create the native shader. We must already have + * called createShaderData for this cvRdrIndex. + */ + private ShaderError createShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) + { + + // Create shaderProgram resources if it has not been done. + synchronized (shader.resourceLock) + { + if (shader.shaderData[cvRdrIndex].getShaderId() != null) + { + // We have already created the shaderId for this Canvas. + return null; + } + + ShaderId[] shaderIdArr = new ShaderId[1]; + ShaderError err = createShader(cv.ctx, shader, shaderIdArr); + if (err != null) + { + return err; + } + shader.shaderData[cvRdrIndex].setShaderId(shaderIdArr[0]); + } + return null; + } + + /** + * Method to compile the native shader. + */ + private ShaderError compileShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) + { + + synchronized (shader.resourceLock) + { + + if (shader.shaderData[cvRdrIndex].isCompiled()) + { + // We have already compiled the shaderId for this Canvas. + return null; + } + + String source = ((SourceCodeShaderRetained) shader).getShaderSource(); + ShaderError err = compileShader(cv.ctx, shader.shaderData[cvRdrIndex].getShaderId(), source); + if (err != null) + { + return err; + } + shader.shaderData[cvRdrIndex].setCompiled(true); + } + + return null; + } + + /** + * Send a message to the notification thread, which will call the + * shader error listeners. + */ + void notifyErrorListeners(Canvas3D cv, ShaderError err) + { + J3dNotification notification = new J3dNotification(); + notification.type = J3dNotification.SHADER_ERROR; + notification.universe = cv.view.universe; + notification.args[0] = err; + VirtualUniverse.mc.sendNotification(notification); + } + + /** + * This method checks whether this ShaderProgram is supported on + * the specified Canvas. If it isn't supported, it will report a + * ShaderError unless an error has already been reported for this + * shader program. + */ + private boolean verifyShaderProgramSupported(Canvas3D cv) + { + boolean supported = isSupported(cv); + if (!supported && !unsupportedErrorReported) + { + String errorMsg = J3dI18N.getString("ShaderProgramRetained0"); + ShaderError err = new ShaderError(ShaderError.UNSUPPORTED_LANGUAGE_ERROR, errorMsg); + err.setShaderProgram((ShaderProgram) this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + unsupportedErrorReported = true; + } + return supported; + } + + /** + * Method to destroy the native shader. + */ + void destroyShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) + { + if (!verifyShaderProgramSupported(cv)) + { + return; + } + + // Destroy shader resource if it exists + synchronized (shader.resourceLock) + { + // Check whether an entry in the shaderData array has been allocated + if (shader.shaderData == null || shader.shaderData.length <= cvRdrIndex || shader.shaderData[cvRdrIndex] == null) + { + return; + } + + // Nothing to do if the shaderId is null + if (shader.shaderData[cvRdrIndex].getShaderId() == null) + { + return; + } + + // Destroy the native resource and set the ID to null for this canvas/renderer + // Ignore any possible shader error, because there is no meaningful way to report it + destroyShader(cv.ctx, shader.shaderData[cvRdrIndex].getShaderId()); + shader.shaderData[cvRdrIndex].reset(); + } + } + + /** + * Method to destroy the native shader program. + */ + void destroyShaderProgram(Canvas3D cv, int cvRdrIndex) + { + if (!verifyShaderProgramSupported(cv)) + { + return; + } + + // Destroy shaderProgram resource if it exists + synchronized (resourceLock) + { + assert (shaderProgramData != null && shaderProgramData.length > cvRdrIndex && shaderProgramData[cvRdrIndex] != null); + + // // Check whether an entry in the shaderProgramData array has been allocated + // if (shaderProgramData == null || + // shaderProgramData.length <= cvRdrIndex || + // shaderProgramData[cvRdrIndex] == null) { + // return; + // } + + ShaderProgramId shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); + // Nothing to do if the shaderProgramId is null + if (shaderProgramId == null) + { + return; + } + + // Destroy the native resource, set the ID to null for this canvas/renderer, + // and clear the bit in the resourceCreationMask + // Ignore any possible shader error, because there is no meaningful way to report it + destroyShaderProgram(cv.ctx, shaderProgramId); + // Reset this ShaderProgramData object. + shaderProgramData[cvRdrIndex].reset(); + } + } + + /** + * updateNative is called while traversing the RenderBin to + * update the shader program state + */ + void updateNative(Canvas3D cv, boolean enable) + { + // System.err.println("ShaderProgramRetained.updateNative : "); + + final boolean useSharedCtx = cv.useSharedCtx && cv.screen.renderer.sharedCtx != null; + int cvRdrIndex; + long ctxTimeStamp; + + if (useSharedCtx) + { + cvRdrIndex = cv.screen.renderer.rendererId; + ctxTimeStamp = cv.screen.renderer.sharedCtxTimeStamp; + } + else + { + cvRdrIndex = cv.canvasId; + ctxTimeStamp = cv.ctxTimeStamp; + } + + // Create ShaderProgramData object for this canvas/renderer if it doesn't already exist + createShaderProgramData(cvRdrIndex, ctxTimeStamp); + + // Check whether this shader program type is supported for this canvas + if (!verifyShaderProgramSupported(cv)) + { + return; + } + + // Just disable shader program and return if enable parameter is set to false + if (!enable) + { + // Given the current design, disableShaderProgram cannot return a non-null value, + // so no need to check it + disableShaderProgram(cv); + return; + } + + // Just disable shader program and return if array of shaders is empty, + // or if a previous attempt to link resulted in an error + if (shaders == null || shaders.length == 0 || linkErrorOccurred) + { + disableShaderProgram(cv); + return; + } + + boolean loadShaderProgram = false; // flag indicating whether to reload all shaderProgram states + if (getShaderProgramData(cvRdrIndex).getShaderProgramId() == null) + { + loadShaderProgram = true; + } + + //System.err.println(".... loadShaderProgram = " + loadShaderProgram); + //System.err.println(".... resourceCreationMask= " + resourceCreationMask); + + ShaderError err = null; + boolean errorOccurred = false; + if (loadShaderProgram) + { + if (useSharedCtx) + { + // TODO : Need to test useSharedCtx case. ** Untested case ** + cv.makeCtxCurrent(cv.screen.renderer.sharedCtx); + } + + // Create shader resources if not already done + for (int i = 0; i < shaders.length; i++) + { + // Create ShaderProgramData object for this canvas/renderer if it doesn't already exist + shaders[i].createShaderData(cvRdrIndex, ctxTimeStamp); + + if (shaders[i].compileErrorOccurred) + { + errorOccurred = true; + } + else + { + err = createShader(cv, cvRdrIndex, shaders[i]); + if (err != null) + { + err.setShaderProgram((ShaderProgram) this.source); + err.setShader((Shader) shaders[i].source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + errorOccurred = true; + } + else + { + err = compileShader(cv, cvRdrIndex, shaders[i]); + if (err != null) + { + err.setShaderProgram((ShaderProgram) this.source); + err.setShader((Shader) shaders[i].source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + destroyShader(cv, cvRdrIndex, shaders[i]); + shaders[i].compileErrorOccurred = true; + errorOccurred = true; + } + } + } + } + + // Create shader program + if (!errorOccurred) + { + err = createShaderProgram(cv, cvRdrIndex); + if (err != null) + { + err.setShaderProgram((ShaderProgram) this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + errorOccurred = true; + } + } + + boolean linked = getShaderProgramData(cvRdrIndex).isLinked(); + if (!linked) + { + // Bind vertex attribute names + if (!errorOccurred) + { + if (vertexAttrNames != null) + { + // System.err.println("vertexAttrNames.length = " + vertexAttrNames.length); + for (int i = 0; i < vertexAttrNames.length; i++) + { + err = bindVertexAttrName(cv, cvRdrIndex, vertexAttrNames[i], i); + // Report non-fatal error, if one was detected + if (err != null) + { + err.setShaderProgram((ShaderProgram) this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + // Link shader program + if (!errorOccurred) + { + err = linkShaderProgram(cv, cvRdrIndex, shaders); + if (err != null) + { + err.setShaderProgram((ShaderProgram) this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + destroyShaderProgram(cv, cvRdrIndex); + linkErrorOccurred = true; + errorOccurred = true; + } + } + + // lookup vertex attribute names + if (!errorOccurred) + { + if (vertexAttrNames != null) + { + lookupVertexAttrNames(cv, cvRdrIndex, vertexAttrNames); + } + } + + // Lookup shader attribute names + if (!errorOccurred) + { + if (shaderAttrNames != null) + { + // System.err.println("shaderAttrNames.length = " + shaderAttrNames.length); + lookupShaderAttrNames(cv, cvRdrIndex, shaderAttrNames); + } + } + } + + // Restore current context if we changed it to the shareCtx + if (useSharedCtx) + { + cv.makeCtxCurrent(cv.ctx); + } + + // If compilation or link error occured, disable shader program and return + if (errorOccurred) + { + disableShaderProgram(cv); + return; + } + } + + // Now we can enable the shader program + enableShaderProgram(cv, cvRdrIndex); + } + + /** + * Update native value for ShaderAttributeValue class + */ + ShaderError setUniformAttrValue(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc loc, ShaderAttributeValueRetained sav) + { + + switch (sav.getClassType()) + { + case ShaderAttributeObjectRetained.TYPE_INTEGER: + return setUniform1i(ctx, shaderProgramId, loc, ((int[]) sav.attrWrapper.getRef())[0]); + + case ShaderAttributeObjectRetained.TYPE_FLOAT: + return setUniform1f(ctx, shaderProgramId, loc, ((float[]) sav.attrWrapper.getRef())[0]); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2I: + return setUniform2i(ctx, shaderProgramId, loc, (int[]) sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2F: + return setUniform2f(ctx, shaderProgramId, loc, (float[]) sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3I: + return setUniform3i(ctx, shaderProgramId, loc, (int[]) sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3F: + return setUniform3f(ctx, shaderProgramId, loc, (float[]) sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4I: + return setUniform4i(ctx, shaderProgramId, loc, (int[]) sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4F: + return setUniform4f(ctx, shaderProgramId, loc, (float[]) sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX3F: + return setUniformMatrix3f(ctx, shaderProgramId, loc, (float[]) sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX4F: + return setUniformMatrix4f(ctx, shaderProgramId, loc, (float[]) sav.attrWrapper.getRef()); + + default: + // Should never get here + assert false : "Unrecognized ShaderAttributeValue classType"; + return null; + } + } + + /** + * Update native value for ShaderAttributeArray class + */ + ShaderError setUniformAttrArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc loc, ShaderAttributeArrayRetained saa) + { + + switch (saa.getClassType()) + { + case ShaderAttributeObjectRetained.TYPE_INTEGER: + return setUniform1iArray(ctx, shaderProgramId, loc, saa.length(), ((int[]) saa.attrWrapper.getRef())); + + case ShaderAttributeObjectRetained.TYPE_FLOAT: + return setUniform1fArray(ctx, shaderProgramId, loc, saa.length(), ((float[]) saa.attrWrapper.getRef())); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2I: + return setUniform2iArray(ctx, shaderProgramId, loc, saa.length(), (int[]) saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2F: + return setUniform2fArray(ctx, shaderProgramId, loc, saa.length(), (float[]) saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3I: + return setUniform3iArray(ctx, shaderProgramId, loc, saa.length(), (int[]) saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3F: + return setUniform3fArray(ctx, shaderProgramId, loc, saa.length(), (float[]) saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4I: + return setUniform4iArray(ctx, shaderProgramId, loc, saa.length(), (int[]) saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4F: + return setUniform4fArray(ctx, shaderProgramId, loc, saa.length(), (float[]) saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX3F: + return setUniformMatrix3fArray(ctx, shaderProgramId, loc, saa.length(), (float[]) saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX4F: + return setUniformMatrix4fArray(ctx, shaderProgramId, loc, saa.length(), (float[]) saa.attrWrapper.getRef()); + + default: + // Should never get here + assert false : "Unrecognized ShaderAttributeArray classType"; + return null; + } + + } + + void setShaderAttributes(Canvas3D cv, ShaderAttributeSetRetained attributeSet) + { + final boolean useSharedCtx = cv.useSharedCtx && cv.screen.renderer.sharedCtx != null; + final int cvRdrIndex = useSharedCtx ? cv.screen.renderer.rendererId : cv.canvasId; + ShaderProgramData spData = getShaderProgramData(cvRdrIndex); + + // Just return if shader program wasn't linked successfully + if (!spData.isLinked()) + { + return; + } + + ShaderProgramId shaderProgramId = spData.getShaderProgramId(); + + List<ShaderAttributeRetained> attributes = attributeSet.getAttrValues(); + for (int i = 0; i < attributes.size(); i++) + { + ShaderAttributeRetained saRetained = attributes.get(i); + ShaderError err = null; + + // Lookup attribute info for the specified attrName; null means + // that the name does not appear in the ShaderProgram, so we will + // report an error. + AttrNameInfo attrNameInfo = spData.getAttrNameInfo(saRetained.getAttributeName()); + if (attrNameInfo == null) + { + // System.err.println("ShaderProgramRetained : attrLocation (" + saRetained.getAttributeName() + ") is null."); + String errMsg = "Attribute name not set in ShaderProgram: " + saRetained.getAttributeName(); // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_NAME_NOT_SET_ERROR, errMsg); + } + else + { + ShaderAttrLoc loc = attrNameInfo.getLocation(); + if (loc != null) + { + if (saRetained instanceof ShaderAttributeValueRetained) + { + ShaderAttributeValueRetained savRetained = (ShaderAttributeValueRetained) saRetained; + //-1 indicates compiled away + if (attrNameInfo.getType() != -1) + { + if (attrNameInfo.isArray() || (savRetained.getClassType() != attrNameInfo.getType())) + { + //PJPJPJJPJ + String errMsg = "Attribute type mismatch: " + savRetained.getAttributeName() + " attrNameInfo.isArray() " + + attrNameInfo.isArray() + " " + savRetained.getClassType() + " != " + attrNameInfo.getType(); + // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); + } + else + { + err = setUniformAttrValue(cv.ctx, shaderProgramId, loc, savRetained); + } + } + else + { + if (attrNameInfo.compiledAwayWarningGiven == false) + { + System.out.println("" + this.source + " Attr: " + savRetained.getAttributeName() + " compiled away"); + attrNameInfo.compiledAwayWarningGiven = true; + } + } + } + else if (saRetained instanceof ShaderAttributeArrayRetained) + { + ShaderAttributeArrayRetained saaRetained = (ShaderAttributeArrayRetained) saRetained; + //-1 indicates compiled away + if (attrNameInfo.getType() != -1) + { + if (!attrNameInfo.isArray() || (saaRetained.getClassType() != attrNameInfo.getType())) + { + String errMsg = "Attribute type mismatch: " + saaRetained.getAttributeName() + " attrNameInfo.isArray() " + + attrNameInfo.isArray() + " " + saaRetained.getClassType() + " != " + attrNameInfo.getType(); + // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); + } + else + { + err = setUniformAttrArray(cv.ctx, shaderProgramId, loc, saaRetained); + } + } + else + { + if (attrNameInfo.compiledAwayWarningGiven == false) + { + System.out.println("" + this.source + " Attr: " + saaRetained.getAttributeName() + " compiled away"); + attrNameInfo.compiledAwayWarningGiven = true; + } + } + } + else if (saRetained instanceof ShaderAttributeBindingRetained) + { + assert false; + throw new RuntimeException("not implemented"); + } + else + { + assert false; + } + } + } + + if (err != null) + { + // Before reporting the ShaderAttribute error, check + // whether it has already been reported for this ShaderProgram + if (shaderAttrErrorSet == null) + { + shaderAttrErrorSet = new HashSet<ShaderAttribute>(); + } + if (shaderAttrErrorSet.add((ShaderAttribute) saRetained.source)) + { + err.setShaderProgram((ShaderProgram) this.source); + err.setShaderAttributeSet((ShaderAttributeSet) attributeSet.source); + err.setShaderAttribute((ShaderAttribute) saRetained.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + class ShaderProgramData extends Object + { + + // issue 378 - time stamp of context creation for this Canvas + private long ctxTimeStamp; + + // shaderProgramId use by native code. + private ShaderProgramId shaderProgramId = null; + + // linked flag for native. + private boolean linked = false; + + // A map of locations for ShaderAttributes. + private HashMap<String, AttrNameInfo> attrNameInfoMap = new HashMap<String, AttrNameInfo>(); + + /** ShaderProgramData Constructor */ + ShaderProgramData() + { + } + + void reset() + { + ctxTimeStamp = 0L; + shaderProgramId = null; + linked = false; + attrNameInfoMap.clear(); + } + + long getCtxTimeStamp() + { + return ctxTimeStamp; + } + + void setCtxTimeStamp(long ctxTimeStamp) + { + this.ctxTimeStamp = ctxTimeStamp; + } + + void setShaderProgramId(ShaderProgramId shaderProgramId) + { + this.shaderProgramId = shaderProgramId; + } + + ShaderProgramId getShaderProgramId() + { + return this.shaderProgramId; + } + + void setLinked(boolean linked) + { + this.linked = linked; + } + + boolean isLinked() + { + return linked; + } + + void setAttrNameInfo(String shaderAttribute, AttrNameInfo attrNameInfo) + { + assert (shaderAttribute != null); + attrNameInfoMap.put(shaderAttribute, attrNameInfo); + } + + AttrNameInfo getAttrNameInfo(String shaderAttribute) + { + //TODO: a SparseArray here on location would be faster + return attrNameInfoMap.get(shaderAttribute); + } + + } + + // Data associated with an attribute name + class AttrNameInfo + { + void setLocation(ShaderAttrLoc loc) + { + this.loc = loc; + } + + ShaderAttrLoc getLocation() + { + return loc; + } + + void setType(int type) + { + this.type = type; + } + + int getType() + { + return type; + } + + boolean isArray() + { + return isArray; + } + + void setArray(boolean isArray) + { + this.isArray = isArray; + } + + // Location of attribute name in linked shader program + private ShaderAttrLoc loc; + + // boolean indicating whether the attribute is an array + private boolean isArray; + + // type of shader attribute + private int type; + + // warning given for compiled away + public boolean compiledAwayWarningGiven = false; + } +} diff --git a/src/javax/media/j3d/ShaderRetained.java b/src/main/java/org/jogamp/java3d/ShaderRetained.java index e946939..2cba479 100644 --- a/src/javax/media/j3d/ShaderRetained.java +++ b/src/main/java/org/jogamp/java3d/ShaderRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/Shape3D.java b/src/main/java/org/jogamp/java3d/Shape3D.java index 9d9cd7e..c9c2fda 100644 --- a/src/javax/media/j3d/Shape3D.java +++ b/src/main/java/org/jogamp/java3d/Shape3D.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** @@ -367,16 +367,16 @@ public class Shape3D extends Leaf { /** - * Returns an enumeration of this Shape3D node's list of geometry + * Returns an iterator of this Shape3D node's list of geometry * components. - * @return an Enumeration object containing all geometry components in + * @return an iterator object containing all geometry components in * this Shape3D node's list of geometry components. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.2 */ - public Enumeration getAllGeometries() { + public Iterator<Geometry> getAllGeometries() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_GEOMETRY_READ)) diff --git a/src/javax/media/j3d/Shape3DCompileRetained.java b/src/main/java/org/jogamp/java3d/Shape3DCompileRetained.java index 599632a..8c06a5b 100644 --- a/src/javax/media/j3d/Shape3DCompileRetained.java +++ b/src/main/java/org/jogamp/java3d/Shape3DCompileRetained.java @@ -24,13 +24,13 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * A leaf node that holds a merged shapes in compile mode @@ -238,7 +238,7 @@ Geometry getGeometry(int i, int childIndex) { } @Override -Enumeration<Geometry> getAllGeometries(int childIndex) { +Iterator<Geometry> getAllGeometries(int childIndex) { ArrayList<Geometry> geoInfo = geometryInfo.get(childIndex); Vector<Geometry> geomList = new Vector<Geometry>(); @@ -246,7 +246,7 @@ Enumeration<Geometry> getAllGeometries(int childIndex) { geomList.add(geoInfo.get(i)); } - return geomList.elements(); + return geomList.iterator(); } Bounds getBounds(int childIndex) { diff --git a/src/javax/media/j3d/Shape3DRetained.java b/src/main/java/org/jogamp/java3d/Shape3DRetained.java index 7af82a7..b337be7 100644 --- a/src/javax/media/j3d/Shape3DRetained.java +++ b/src/main/java/org/jogamp/java3d/Shape3DRetained.java @@ -24,13 +24,14 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Vector; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * A shape leaf node consisting of geometry and appearance properties. @@ -467,14 +468,14 @@ Geometry getGeometry(int index, int id) { } /** - * Returns an enumeration of this Shape3D node's list of geometry + * Returns an iterator of this Shape3D node's list of geometry * components. - * @return an Enumeration object containing all geometry components in + * @return an Iterator object containing all geometry components in * this Shape3D node's list of geometry components. * * @since Java 3D 1.2 */ -Enumeration getAllGeometries(int id) { +Iterator<Geometry> getAllGeometries(int id) { Vector<Geometry> geomList = new Vector<Geometry>(geometryList.size()); for (int i = 0; i < geometryList.size(); i++) { @@ -485,7 +486,7 @@ Enumeration getAllGeometries(int id) { geomList.add(null); } - return geomList.elements(); + return geomList.iterator(); } /** @@ -1406,7 +1407,7 @@ Enumeration getAllGeometries(int id) { // currentLocalToVworld in the intersect test, it will then // be more costly and really beat the purpose of eliminating // the static transform group - if (isPickable || isCollidable || + if (pickable || collidable || source.getCapability(Shape3D.ALLOW_PICKABLE_WRITE) || source.getCapability(Shape3D.ALLOW_COLLIDABLE_WRITE)) { return false; @@ -2365,7 +2366,7 @@ Enumeration getAllGeometries(int id) { * This is used to send a message of the snapshot of the * geometry atoms that are affected by this change. */ -final static ArrayList<ArrayList<GeometryAtom>> getGeomAtomsList(ArrayList userList, ArrayList<VirtualUniverse> univList) { +final static ArrayList<ArrayList<GeometryAtom>> getGeomAtomsList(LinkedHashSet<NodeRetained> userList, ArrayList<VirtualUniverse> univList) { ArrayList<ArrayList<GeometryAtom>> listPerUniverse = new ArrayList<ArrayList<GeometryAtom>>(); int index; ArrayList<GeometryAtom> gaList = null; @@ -2374,9 +2375,8 @@ final static ArrayList<ArrayList<GeometryAtom>> getGeomAtomsList(ArrayList userL VirtualUniverse firstFndUniv = null; synchronized(userList) { - for (int i = userList.size()-1; i >=0; i--) { - ms = (Shape3DRetained) userList.get(i); - + for(NodeRetained nr : userList){ + ms = (Shape3DRetained)nr; if(moreThanOneUniv == false) { if(firstFndUniv == null) { firstFndUniv = ms.universe; @@ -2482,8 +2482,7 @@ final static ArrayList<ArrayList<GeometryAtom>> getGeomAtomsList(ArrayList userL alphaEditable = true; } else if (geo instanceof RasterRetained) { - if ((((RasterRetained)geo).type & Raster.RASTER_COLOR) != -0 + if ((((RasterRetained)geo).type & Raster.RASTER_COLOR) != 0 && ((RasterRetained)geo).source.getCapability( Raster.ALLOW_IMAGE_WRITE)) { @@ -2558,7 +2557,7 @@ final static ArrayList<ArrayList<GeometryAtom>> getGeomAtomsList(ArrayList userL boolean isEquivalent(Shape3DRetained shape) { - if (this.appearance != shape.appearance || + if (!this.appearance.equals(shape.appearance) || // Scoping info should be same since they are under same group this.appearanceOverrideEnable != shape.appearanceOverrideEnable || this.isPickable != shape.isPickable || diff --git a/src/javax/media/j3d/SharedGroup.java b/src/main/java/org/jogamp/java3d/SharedGroup.java index 8d0fd7c..db97dcc 100644 --- a/src/javax/media/j3d/SharedGroup.java +++ b/src/main/java/org/jogamp/java3d/SharedGroup.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The SharedGroup provides the ability to manipulate an diff --git a/src/javax/media/j3d/SharedGroupRetained.java b/src/main/java/org/jogamp/java3d/SharedGroupRetained.java index 1d5b3d3..1aac1e4 100644 --- a/src/javax/media/j3d/SharedGroupRetained.java +++ b/src/main/java/org/jogamp/java3d/SharedGroupRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; /** @@ -918,9 +918,9 @@ public ArrayList<SwitchState> getTargetsData(int type, int index) { // Issue 514 : NPE in Wonderland : triggered in cached bounds computation validCachedBounds = false; synchronized(parents) { - Enumeration e = parents.elements(); - while(e.hasMoreElements()) { - LinkRetained parent = (LinkRetained) e.nextElement(); + Iterator e = parents.iterator(); + while(e.hasNext()) { + LinkRetained parent = (LinkRetained) e.next(); if (parent!=null) { parent.dirtyBoundsCache(); } diff --git a/src/javax/media/j3d/Sound.java b/src/main/java/org/jogamp/java3d/Sound.java index 612206c..8a349aa 100644 --- a/src/javax/media/j3d/Sound.java +++ b/src/main/java/org/jogamp/java3d/Sound.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/SoundException.java b/src/main/java/org/jogamp/java3d/SoundException.java index 44241ea..68e196d 100644 --- a/src/javax/media/j3d/SoundException.java +++ b/src/main/java/org/jogamp/java3d/SoundException.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Indicates a problem in loading or playing a sound sample. diff --git a/src/javax/media/j3d/SoundRetained.java b/src/main/java/org/jogamp/java3d/SoundRetained.java index 246e9dc..bdf0b7a 100644 --- a/src/javax/media/j3d/SoundRetained.java +++ b/src/main/java/org/jogamp/java3d/SoundRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/SoundScheduler.java b/src/main/java/org/jogamp/java3d/SoundScheduler.java index 9e71a0c..86429dd 100644 --- a/src/javax/media/j3d/SoundScheduler.java +++ b/src/main/java/org/jogamp/java3d/SoundScheduler.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.AWTEvent; import java.awt.event.WindowEvent; @@ -32,13 +32,14 @@ import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; -import java.util.Enumeration; +import java.util.Iterator; +import java.util.LinkedHashSet; -import javax.vecmath.Point2f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** * This structure parallels the RenderBin structure and @@ -525,9 +526,10 @@ class SoundScheduler extends J3dStructure { } else if (node instanceof MediaContainerRetained) { int listSize = ((Integer)m.args[2]).intValue(); - ArrayList userList = (ArrayList)m.args[3]; - for (int i = 0; i < listSize; i++) { - SoundRetained sound = (SoundRetained)userList.get(i); + LinkedHashSet<SoundRetained> userList = (LinkedHashSet<SoundRetained>)m.args[3]; + for (SoundRetained sound : userList) { + //for (int i = 0; i < listSize; i++) { + //SoundRetained sound = userList.get(i); if (sound != null) { loadSound(sound, true); if (debugFlag) @@ -1048,15 +1050,15 @@ class SoundScheduler extends J3dStructure { nRetainedSounds++; } // XXXX: sync canvases - Enumeration<Canvas3D> canvases = view.getAllCanvas3Ds(); - while (canvases.hasMoreElements()) { - Canvas3D canvas = canvases.nextElement(); + Iterator<Canvas3D> canvases = view.getAllCanvas3Ds(); + while (canvases.hasNext()) { + Canvas3D canvas = canvases.next(); GraphicsContext3D graphicsContext = canvas.getGraphicsContext3D(); - Enumeration nonretainedSounds = graphicsContext.getAllSounds(); - while (nonretainedSounds.hasMoreElements()) { + Iterator<Sound> nonretainedSounds = graphicsContext.getAllSounds(); + while (nonretainedSounds.hasNext()) { if (debugFlag) debugPrint(" prioritizeSound , get non-retained sound"); - Sound sound = (Sound)nonretainedSounds.nextElement(); + Sound sound = (Sound)nonretainedSounds.next(); if (sound == null) { if (debugFlag) debugPrint(" prioritizeSound , sound element is null"); diff --git a/src/javax/media/j3d/SoundSchedulerAtom.java b/src/main/java/org/jogamp/java3d/SoundSchedulerAtom.java index 3be6637..9f9c554 100644 --- a/src/javax/media/j3d/SoundSchedulerAtom.java +++ b/src/main/java/org/jogamp/java3d/SoundSchedulerAtom.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/SoundStructure.java b/src/main/java/org/jogamp/java3d/SoundStructure.java index 05df38f..34ed923 100644 --- a/src/javax/media/j3d/SoundStructure.java +++ b/src/main/java/org/jogamp/java3d/SoundStructure.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/javax/media/j3d/Soundscape.java b/src/main/java/org/jogamp/java3d/Soundscape.java index 8470636..d1c9595 100644 --- a/src/javax/media/j3d/Soundscape.java +++ b/src/main/java/org/jogamp/java3d/Soundscape.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The Soundscape Leaf Node defines the attributes that characterize the diff --git a/src/javax/media/j3d/SoundscapeRetained.java b/src/main/java/org/jogamp/java3d/SoundscapeRetained.java index dc74bf0..bd563aa 100644 --- a/src/javax/media/j3d/SoundscapeRetained.java +++ b/src/main/java/org/jogamp/java3d/SoundscapeRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; /** diff --git a/src/javax/media/j3d/SourceCodeShader.java b/src/main/java/org/jogamp/java3d/SourceCodeShader.java index afc243b..4dccab8 100644 --- a/src/javax/media/j3d/SourceCodeShader.java +++ b/src/main/java/org/jogamp/java3d/SourceCodeShader.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The SourceCodeShader object is a shader that is defined using diff --git a/src/javax/media/j3d/SourceCodeShaderRetained.java b/src/main/java/org/jogamp/java3d/SourceCodeShaderRetained.java index 2e20b8e..7a3422c 100644 --- a/src/javax/media/j3d/SourceCodeShaderRetained.java +++ b/src/main/java/org/jogamp/java3d/SourceCodeShaderRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The SourceCodeShaderRetained object is a shader that is defined using diff --git a/src/main/java/org/jogamp/java3d/SparseArray.java b/src/main/java/org/jogamp/java3d/SparseArray.java new file mode 100644 index 0000000..70c725e --- /dev/null +++ b/src/main/java/org/jogamp/java3d/SparseArray.java @@ -0,0 +1,584 @@ +package org.jogamp.java3d;
+
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * SparseArrays map integers to Objects. Unlike a normal array of Objects,
+ * there can be gaps in the indices. It is intended to be more memory efficient
+ * than using a HashMap to map Integers to Objects, both because it avoids
+ * auto-boxing keys and its data structure doesn't rely on an extra entry object
+ * for each mapping.
+ *
+ * <p>Note that this container keeps its mappings in an array data structure,
+ * using a binary search to find keys. The implementation is not intended to be appropriate for
+ * data structures
+ * that may contain large numbers of items. It is generally slower than a traditional
+ * HashMap, since lookups require a binary search and adds and removes require inserting
+ * and deleting entries in the array. For containers holding up to hundreds of items,
+ * the performance difference is not significant, less than 50%.</p>
+ *
+ * <p>To help with performance, the container includes an optimization when removing
+ * keys: instead of compacting its array immediately, it leaves the removed entry marked
+ * as deleted. The entry can then be re-used for the same key, or compacted later in
+ * a single garbage collection step of all removed entries. This garbage collection will
+ * need to be performed at any time the array needs to be grown or the the map size or
+ * entry values are retrieved.</p>
+ *
+ * <p>It is possible to iterate over the items in this container using
+ * {@link #keyAt(int)} and {@link #valueAt(int)}. Iterating over the keys using
+ * <code>keyAt(int)</code> with ascending values of the index will return the
+ * keys in ascending order, or the values corresponding to the keys in ascending
+ * order in the case of <code>valueAt(int)</code>.</p>
+ */
+public class SparseArray<E> implements Cloneable
+{
+ private static final Object DELETED = new Object();
+ private boolean mGarbage = false;
+
+ private int[] mKeys;
+ private Object[] mValues;
+ private int mSize;
+
+ static final boolean[] EMPTY_BOOLEANS = new boolean[0];
+ static final int[] EMPTY_INTS = new int[0];
+ static final long[] EMPTY_LONGS = new long[0];
+ static final Object[] EMPTY_OBJECTS = new Object[0];
+
+ /**
+ * Creates a new SparseArray containing no mappings.
+ */
+ public SparseArray()
+ {
+ this(10);
+ }
+
+ /**
+ * Creates a new SparseArray containing no mappings that will not
+ * require any additional memory allocation to store the specified
+ * number of mappings. If you supply an initial capacity of 0, the
+ * sparse array will be initialized with a light-weight representation
+ * not requiring any additional array allocations.
+ */
+ public SparseArray(int initialCapacity)
+ {
+ if (initialCapacity == 0)
+ {
+ mKeys = EMPTY_INTS;
+ mValues = EMPTY_OBJECTS;
+ }
+ else
+ {
+ initialCapacity = idealIntArraySize(initialCapacity);
+ mKeys = new int[initialCapacity];
+ mValues = new Object[initialCapacity];
+ }
+ mSize = 0;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public SparseArray<E> clone()
+ {
+ SparseArray<E> clone = null;
+ try
+ {
+ clone = (SparseArray<E>) super.clone();
+ clone.mKeys = mKeys.clone();
+ clone.mValues = mValues.clone();
+ }
+ catch (CloneNotSupportedException cnse)
+ {
+ /* ignore */
+ }
+ return clone;
+ }
+
+ /**
+ * Gets the Object mapped from the specified key, or <code>null</code>
+ * if no such mapping has been made.
+ */
+ public E get(int key)
+ {
+ return get(key, null);
+ }
+
+ /**
+ * Gets the Object mapped from the specified key, or the specified Object
+ * if no such mapping has been made.
+ */
+ @SuppressWarnings("unchecked")
+ public E get(int key, E valueIfKeyNotFound)
+ {
+ int i = binarySearch(mKeys, mSize, key);
+
+ if (i < 0 || mValues[i] == DELETED)
+ {
+ return valueIfKeyNotFound;
+ }
+ else
+ {
+ return (E) mValues[i];
+ }
+ }
+
+ /**
+ * Removes the mapping from the specified key, if there was any.
+ */
+ public void delete(int key)
+ {
+ int i = binarySearch(mKeys, mSize, key);
+
+ if (i >= 0)
+ {
+ if (mValues[i] != DELETED)
+ {
+ mValues[i] = DELETED;
+ mGarbage = true;
+ }
+ }
+ }
+
+ /**
+ * Alias for {@link #delete(int)}.
+ */
+ public void remove(int key)
+ {
+ delete(key);
+ }
+
+ /**
+ * Removes the mapping at the specified index.
+ */
+ public void removeAt(int index)
+ {
+ if (mValues[index] != DELETED)
+ {
+ mValues[index] = DELETED;
+ mGarbage = true;
+ }
+ }
+
+ /**
+ * Remove a range of mappings as a batch.
+ *
+ * @param index Index to begin at
+ * @param size Number of mappings to remove
+ */
+ public void removeAtRange(int index, int size)
+ {
+ final int end = Math.min(mSize, index + size);
+ for (int i = index; i < end; i++)
+ {
+ removeAt(i);
+ }
+ }
+
+ private void gc()
+ {
+ // Log.e("SparseArray", "gc start with " + mSize);
+
+ int n = mSize;
+ int o = 0;
+ int[] keys = mKeys;
+ Object[] values = mValues;
+
+ for (int i = 0; i < n; i++)
+ {
+ Object val = values[i];
+
+ if (val != DELETED)
+ {
+ if (i != o)
+ {
+ keys[o] = keys[i];
+ values[o] = val;
+ values[i] = null;
+ }
+
+ o++;
+ }
+ }
+
+ mGarbage = false;
+ mSize = o;
+
+ // Log.e("SparseArray", "gc end with " + mSize);
+ }
+
+ /**
+ * Adds a mapping from the specified key to the specified value,
+ * replacing the previous mapping from the specified key if there
+ * was one.
+ */
+ public void put(int key, E value)
+ {
+ int i = binarySearch(mKeys, mSize, key);
+
+ if (i >= 0)
+ {
+ mValues[i] = value;
+ }
+ else
+ {
+ i = ~i;
+
+ if (i < mSize && mValues[i] == DELETED)
+ {
+ mKeys[i] = key;
+ mValues[i] = value;
+ return;
+ }
+
+ if (mGarbage && mSize >= mKeys.length)
+ {
+ gc();
+
+ // Search again because indices may have changed.
+ i = ~binarySearch(mKeys, mSize, key);
+ }
+
+ if (mSize >= mKeys.length)
+ {
+ int n = idealIntArraySize(mSize + 1);
+
+ int[] nkeys = new int[n];
+ Object[] nvalues = new Object[n];
+
+ // Log.e("SparseArray", "grow " + mKeys.length + " to " + n);
+ System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
+ System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
+
+ mKeys = nkeys;
+ mValues = nvalues;
+ }
+
+ if (mSize - i != 0)
+ {
+ // Log.e("SparseArray", "move " + (mSize - i));
+ System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i);
+ System.arraycopy(mValues, i, mValues, i + 1, mSize - i);
+ }
+
+ mKeys[i] = key;
+ mValues[i] = value;
+ mSize++;
+ }
+ }
+
+ /**
+ * Returns the number of key-value mappings that this SparseArray
+ * currently stores.
+ */
+ public int size()
+ {
+ if (mGarbage)
+ {
+ gc();
+ }
+
+ return mSize;
+ }
+
+ /**
+ * Given an index in the range <code>0...size()-1</code>, returns
+ * the key from the <code>index</code>th key-value mapping that this
+ * SparseArray stores.
+ *
+ * <p>The keys corresponding to indices in ascending order are guaranteed to
+ * be in ascending order, e.g., <code>keyAt(0)</code> will return the
+ * smallest key and <code>keyAt(size()-1)</code> will return the largest
+ * key.</p>
+ */
+ public int keyAt(int index)
+ {
+ if (mGarbage)
+ {
+ gc();
+ }
+
+ return mKeys[index];
+ }
+
+ /**
+ * Given an index in the range <code>0...size()-1</code>, returns
+ * the value from the <code>index</code>th key-value mapping that this
+ * SparseArray stores.
+ *
+ * <p>The values corresponding to indices in ascending order are guaranteed
+ * to be associated with keys in ascending order, e.g.,
+ * <code>valueAt(0)</code> will return the value associated with the
+ * smallest key and <code>valueAt(size()-1)</code> will return the value
+ * associated with the largest key.</p>
+ */
+ @SuppressWarnings("unchecked")
+ public E valueAt(int index)
+ {
+ if (mGarbage)
+ {
+ gc();
+ }
+
+ return (E) mValues[index];
+ }
+
+ /**
+ * Given an index in the range <code>0...size()-1</code>, sets a new
+ * value for the <code>index</code>th key-value mapping that this
+ * SparseArray stores.
+ */
+ public void setValueAt(int index, E value)
+ {
+ if (mGarbage)
+ {
+ gc();
+ }
+
+ mValues[index] = value;
+ }
+
+ /**
+ * Returns the index for which {@link #keyAt} would return the
+ * specified key, or a negative number if the specified
+ * key is not mapped.
+ */
+ public int indexOfKey(int key)
+ {
+ if (mGarbage)
+ {
+ gc();
+ }
+
+ return binarySearch(mKeys, mSize, key);
+ }
+
+ /**
+ * Returns an index for which {@link #valueAt} would return the
+ * specified key, or a negative number if no keys map to the
+ * specified value.
+ * <p>Beware that this is a linear search, unlike lookups by key,
+ * and that multiple keys can map to the same value and this will
+ * find only one of them.
+ * <p>Note also that unlike most collections' {@code indexOf} methods,
+ * this method compares values using {@code ==} rather than {@code equals}.
+ */
+ public int indexOfValue(E value)
+ {
+ if (mGarbage)
+ {
+ gc();
+ }
+
+ for (int i = 0; i < mSize; i++)
+ if (mValues[i] == value)
+ return i;
+
+ return -1;
+ }
+
+ /**
+ * Removes all key-value mappings from this SparseArray.
+ */
+ public void clear()
+ {
+ int n = mSize;
+ Object[] values = mValues;
+
+ for (int i = 0; i < n; i++)
+ {
+ values[i] = null;
+ }
+
+ mSize = 0;
+ mGarbage = false;
+ }
+
+ /**
+ * Puts a key/value pair into the array, optimizing for the case where
+ * the key is greater than all existing keys in the array.
+ */
+ public void append(int key, E value)
+ {
+ if (mSize != 0 && key <= mKeys[mSize - 1])
+ {
+ put(key, value);
+ return;
+ }
+
+ if (mGarbage && mSize >= mKeys.length)
+ {
+ gc();
+ }
+
+ int pos = mSize;
+ if (pos >= mKeys.length)
+ {
+ int n = idealIntArraySize(pos + 1);
+
+ int[] nkeys = new int[n];
+ Object[] nvalues = new Object[n];
+
+ // Log.e("SparseArray", "grow " + mKeys.length + " to " + n);
+ System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
+ System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
+
+ mKeys = nkeys;
+ mValues = nvalues;
+ }
+
+ mKeys[pos] = key;
+ mValues[pos] = value;
+ mSize = pos + 1;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This implementation composes a string by iterating over its mappings. If
+ * this map contains itself as a value, the string "(this Map)"
+ * will appear in its place.
+ */
+ @Override
+ public String toString()
+ {
+ if (size() <= 0)
+ {
+ return "{}";
+ }
+
+ StringBuilder buffer = new StringBuilder(mSize * 28);
+ buffer.append('{');
+ for (int i = 0; i < mSize; i++)
+ {
+ if (i > 0)
+ {
+ buffer.append(", ");
+ }
+ int key = keyAt(i);
+ buffer.append(key);
+ buffer.append('=');
+ Object value = valueAt(i);
+ if (value != this)
+ {
+ buffer.append(value);
+ }
+ else
+ {
+ buffer.append("(this Map)");
+ }
+ }
+ buffer.append('}');
+ return buffer.toString();
+ }
+
+ public static int idealByteArraySize(int need)
+ {
+ for (int i = 4; i < 32; i++)
+ if (need <= (1 << i) - 12)
+ return (1 << i) - 12;
+
+ return need;
+ }
+
+ public static int idealIntArraySize(int need)
+ {
+ return idealByteArraySize(need * 8) / 8;
+ }
+
+ // This is Arrays.binarySearch(), but doesn't do any argument validation.
+ static int binarySearch(int[] array, int size, int value)
+ {
+ int lo = 0;
+ int hi = size - 1;
+
+ while (lo <= hi)
+ {
+ final int mid = (lo + hi) >>> 1;
+ final int midVal = array[mid];
+
+ if (midVal < value)
+ {
+ lo = mid + 1;
+ }
+ else if (midVal > value)
+ {
+ hi = mid - 1;
+ }
+ else
+ {
+ return mid; // value found
+ }
+ }
+ return ~lo; // value not present
+ }
+
+ static int binarySearch(long[] array, int size, long value)
+ {
+ int lo = 0;
+ int hi = size - 1;
+
+ while (lo <= hi)
+ {
+ final int mid = (lo + hi) >>> 1;
+ final long midVal = array[mid];
+
+ if (midVal < value)
+ {
+ lo = mid + 1;
+ }
+ else if (midVal > value)
+ {
+ hi = mid - 1;
+ }
+ else
+ {
+ return mid; // value found
+ }
+ }
+ return ~lo; // value not present
+ }
+
+ //////////////PJ extensions
+ public void putAll(SparseArray<E> sa)
+ {
+ for (int i = 0; i < sa.size(); i++)
+ put(sa.keyAt(i), sa.get(sa.keyAt(i)));
+
+ }
+
+ public int[] keySet()
+ {
+ int[] keys = new int[size()];
+ for (int i = 0; i < size(); i++)
+ keys[i] = keyAt(i);
+ return keys;
+ }
+
+ public void put(Integer key, E value)
+ {
+ throw new UnsupportedOperationException("This is exactly the sort of thing I'm trying to avoid!");
+ }
+
+ public E get(Integer key)
+ {
+ throw new UnsupportedOperationException("This is exactly the sort of thing I'm trying to avoid!");
+ }
+
+ public E remove(Integer key)
+ {
+ throw new UnsupportedOperationException("This is exactly the sort of thing I'm trying to avoid!");
+ }
+}
diff --git a/src/javax/media/j3d/SpotLight.java b/src/main/java/org/jogamp/java3d/SpotLight.java index f9e65e9..1aaeba6 100644 --- a/src/javax/media/j3d/SpotLight.java +++ b/src/main/java/org/jogamp/java3d/SpotLight.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color3f; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * The SpotLight object specifies an attenuated light source at a diff --git a/src/javax/media/j3d/SpotLightRetained.java b/src/main/java/org/jogamp/java3d/SpotLightRetained.java index f7fef46..0a2d145 100644 --- a/src/javax/media/j3d/SpotLightRetained.java +++ b/src/main/java/org/jogamp/java3d/SpotLightRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Vector3f; /** * A local spot light source object. diff --git a/src/javax/media/j3d/StructureUpdateThread.java b/src/main/java/org/jogamp/java3d/StructureUpdateThread.java index 8dbf431..8a9e30b 100644 --- a/src/javax/media/j3d/StructureUpdateThread.java +++ b/src/main/java/org/jogamp/java3d/StructureUpdateThread.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The StructureUpdateThread is thread that passes messages to its structure diff --git a/src/javax/media/j3d/Switch.java b/src/main/java/org/jogamp/java3d/Switch.java index 6a3f760..f722765 100644 --- a/src/javax/media/j3d/Switch.java +++ b/src/main/java/org/jogamp/java3d/Switch.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.BitSet; diff --git a/src/javax/media/j3d/SwitchRetained.java b/src/main/java/org/jogamp/java3d/SwitchRetained.java index eac2cb6..fd77ad4 100644 --- a/src/javax/media/j3d/SwitchRetained.java +++ b/src/main/java/org/jogamp/java3d/SwitchRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/javax/media/j3d/SwitchState.java b/src/main/java/org/jogamp/java3d/SwitchState.java index 291a4bd..8838f1d 100644 --- a/src/javax/media/j3d/SwitchState.java +++ b/src/main/java/org/jogamp/java3d/SwitchState.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class SwitchState { // a bitmask to track the composite switchOn state in a nested switch diff --git a/src/javax/media/j3d/SwitchValueInterpolator.java b/src/main/java/org/jogamp/java3d/SwitchValueInterpolator.java index b85e648..07d1dc9 100644 --- a/src/javax/media/j3d/SwitchValueInterpolator.java +++ b/src/main/java/org/jogamp/java3d/SwitchValueInterpolator.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** * SwitchValueInterpolator behavior. This class defines a @@ -155,11 +155,11 @@ public class SwitchValueInterpolator extends Interpolator { * It maps the alpha value that corresponds to the current time * into a child index value and updates the specified Switch node * with this new child index value. - * @param criteria an enumeration of the criteria that triggered + * @param criteria an iterator of the criteria that triggered * this stimulus */ @Override - public void processStimulus(Enumeration criteria) { + public void processStimulus(Iterator<WakeupCriterion> criteria) { // Handle stimulus WakeupCriterion criterion = passiveWakeupCriterion; diff --git a/src/javax/media/j3d/Targets.java b/src/main/java/org/jogamp/java3d/Targets.java index d151756..c67c42a 100644 --- a/src/javax/media/j3d/Targets.java +++ b/src/main/java/org/jogamp/java3d/Targets.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/TargetsInterface.java b/src/main/java/org/jogamp/java3d/TargetsInterface.java index 9d88f76..683d916 100644 --- a/src/javax/media/j3d/TargetsInterface.java +++ b/src/main/java/org/jogamp/java3d/TargetsInterface.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/TexCoordGeneration.java b/src/main/java/org/jogamp/java3d/TexCoordGeneration.java index fe9679a..7667853 100644 --- a/src/javax/media/j3d/TexCoordGeneration.java +++ b/src/main/java/org/jogamp/java3d/TexCoordGeneration.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Vector4f; +import org.jogamp.vecmath.Vector4f; /** * The TexCoordGeneration object contains all parameters needed for diff --git a/src/javax/media/j3d/TexCoordGenerationRetained.java b/src/main/java/org/jogamp/java3d/TexCoordGenerationRetained.java index aa704f5..cadc1ee 100644 --- a/src/javax/media/j3d/TexCoordGenerationRetained.java +++ b/src/main/java/org/jogamp/java3d/TexCoordGenerationRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Vector4f; +import org.jogamp.vecmath.Vector4f; /** * The TexCoordGeneration object contains all parameters needed for texture diff --git a/src/javax/media/j3d/Text3D.java b/src/main/java/org/jogamp/java3d/Text3D.java index 3791753..29f8fca 100644 --- a/src/javax/media/j3d/Text3D.java +++ b/src/main/java/org/jogamp/java3d/Text3D.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point3f; /** * A Text3D object is a text string that has been converted to 3D diff --git a/src/javax/media/j3d/Text3DRenderMethod.java b/src/main/java/org/jogamp/java3d/Text3DRenderMethod.java index 6b2d2dc..7533135 100644 --- a/src/javax/media/j3d/Text3DRenderMethod.java +++ b/src/main/java/org/jogamp/java3d/Text3DRenderMethod.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The RenderMethod interface is used to create various ways to render diff --git a/src/javax/media/j3d/Text3DRetained.java b/src/main/java/org/jogamp/java3d/Text3DRetained.java index ed21941..6260cfc 100644 --- a/src/javax/media/j3d/Text3DRetained.java +++ b/src/main/java/org/jogamp/java3d/Text3DRetained.java @@ -24,15 +24,15 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.font.GlyphVector; import java.awt.geom.Rectangle2D; import java.util.ArrayList; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * Implements Text3D class. diff --git a/src/javax/media/j3d/Texture.java b/src/main/java/org/jogamp/java3d/Texture.java index 7655ad3..cbf8ca2 100644 --- a/src/javax/media/j3d/Texture.java +++ b/src/main/java/org/jogamp/java3d/Texture.java @@ -24,14 +24,14 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; -import javax.vecmath.Color4f; -import javax.vecmath.Point2f; -import javax.vecmath.Point3f; -import javax.vecmath.Tuple3f; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Tuple3f; /** * The Texture object is a component object of an Appearance object diff --git a/src/javax/media/j3d/Texture2D.java b/src/main/java/org/jogamp/java3d/Texture2D.java index 6f32db6..01faaa0 100644 --- a/src/javax/media/j3d/Texture2D.java +++ b/src/main/java/org/jogamp/java3d/Texture2D.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; +import org.jogamp.vecmath.Point2f; /** diff --git a/src/javax/media/j3d/Texture2DRetained.java b/src/main/java/org/jogamp/java3d/Texture2DRetained.java index ce6803d..97c479a 100644 --- a/src/javax/media/j3d/Texture2DRetained.java +++ b/src/main/java/org/jogamp/java3d/Texture2DRetained.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point2f; +import org.jogamp.vecmath.Point2f; /** * Texture2D is a subclass of Texture class. It extends Texture diff --git a/src/javax/media/j3d/Texture3D.java b/src/main/java/org/jogamp/java3d/Texture3D.java index 6b2f955..616ca6d 100644 --- a/src/javax/media/j3d/Texture3D.java +++ b/src/main/java/org/jogamp/java3d/Texture3D.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Texture3D is a subclass of Texture class. It extends Texture diff --git a/src/javax/media/j3d/Texture3DRetained.java b/src/main/java/org/jogamp/java3d/Texture3DRetained.java index c216c08..dfe9713 100644 --- a/src/javax/media/j3d/Texture3DRetained.java +++ b/src/main/java/org/jogamp/java3d/Texture3DRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Texture3D is a subclass of Texture class. It extends Texture diff --git a/src/javax/media/j3d/TextureAttributes.java b/src/main/java/org/jogamp/java3d/TextureAttributes.java index 28e1bfc..2f57900 100644 --- a/src/javax/media/j3d/TextureAttributes.java +++ b/src/main/java/org/jogamp/java3d/TextureAttributes.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Color4f; +import org.jogamp.vecmath.Color4f; /** * The TextureAttributes object defines attributes that apply to diff --git a/src/javax/media/j3d/TextureAttributesRetained.java b/src/main/java/org/jogamp/java3d/TextureAttributesRetained.java index a31d8fc..d2c4963 100644 --- a/src/javax/media/j3d/TextureAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/TextureAttributesRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Color4f; +import org.jogamp.vecmath.Color4f; /** * The TextureAttributes object defines attributes that apply to diff --git a/src/javax/media/j3d/TextureBin.java b/src/main/java/org/jogamp/java3d/TextureBin.java index 9af0cc1..ade8039 100644 --- a/src/javax/media/j3d/TextureBin.java +++ b/src/main/java/org/jogamp/java3d/TextureBin.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Collection; diff --git a/src/javax/media/j3d/TextureCubeMap.java b/src/main/java/org/jogamp/java3d/TextureCubeMap.java index 10fbdd8..96c80fc 100644 --- a/src/javax/media/j3d/TextureCubeMap.java +++ b/src/main/java/org/jogamp/java3d/TextureCubeMap.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/TextureCubeMapRetained.java b/src/main/java/org/jogamp/java3d/TextureCubeMapRetained.java index 97fa9ff..cfc5c3f 100644 --- a/src/javax/media/j3d/TextureCubeMapRetained.java +++ b/src/main/java/org/jogamp/java3d/TextureCubeMapRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/TextureRetained.java b/src/main/java/org/jogamp/java3d/TextureRetained.java index fdb16ee..25f593c 100644 --- a/src/javax/media/j3d/TextureRetained.java +++ b/src/main/java/org/jogamp/java3d/TextureRetained.java @@ -24,17 +24,17 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.image.DataBufferByte; import java.awt.image.RenderedImage; import java.util.ArrayList; import java.util.HashMap; -import javax.vecmath.Color4f; -import javax.vecmath.Point2f; -import javax.vecmath.Point3f; -import javax.vecmath.Tuple3f; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Tuple3f; /** * The Texture object is a component object of an Appearance object diff --git a/src/javax/media/j3d/TextureUnitState.java b/src/main/java/org/jogamp/java3d/TextureUnitState.java index 93c3b41..c12d386 100644 --- a/src/javax/media/j3d/TextureUnitState.java +++ b/src/main/java/org/jogamp/java3d/TextureUnitState.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Hashtable; diff --git a/src/javax/media/j3d/TextureUnitStateRetained.java b/src/main/java/org/jogamp/java3d/TextureUnitStateRetained.java index c3b40c6..e7cb7f4 100644 --- a/src/javax/media/j3d/TextureUnitStateRetained.java +++ b/src/main/java/org/jogamp/java3d/TextureUnitStateRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; diff --git a/src/javax/media/j3d/TimerThread.java b/src/main/java/org/jogamp/java3d/TimerThread.java index daabac0..6e6f2b1 100644 --- a/src/javax/media/j3d/TimerThread.java +++ b/src/main/java/org/jogamp/java3d/TimerThread.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The TimerThread is thread that handle WakeupOnElapsedTime call. diff --git a/src/javax/media/j3d/Transform3D.java b/src/main/java/org/jogamp/java3d/Transform3D.java index ac584d0..04dde23 100644 --- a/src/javax/media/j3d/Transform3D.java +++ b/src/main/java/org/jogamp/java3d/Transform3D.java @@ -24,25 +24,25 @@ * */ -package javax.media.j3d; - -import javax.vecmath.AxisAngle4d; -import javax.vecmath.AxisAngle4f; -import javax.vecmath.GMatrix; -import javax.vecmath.Matrix3d; -import javax.vecmath.Matrix3f; -import javax.vecmath.Matrix4d; -import javax.vecmath.Matrix4f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Point4d; -import javax.vecmath.Quat4d; -import javax.vecmath.Quat4f; -import javax.vecmath.SingularMatrixException; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector3f; -import javax.vecmath.Vector4d; -import javax.vecmath.Vector4f; +package org.jogamp.java3d; + +import org.jogamp.vecmath.AxisAngle4d; +import org.jogamp.vecmath.AxisAngle4f; +import org.jogamp.vecmath.GMatrix; +import org.jogamp.vecmath.Matrix3d; +import org.jogamp.vecmath.Matrix3f; +import org.jogamp.vecmath.Matrix4d; +import org.jogamp.vecmath.Matrix4f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Point4d; +import org.jogamp.vecmath.Quat4d; +import org.jogamp.vecmath.Quat4f; +import org.jogamp.vecmath.SingularMatrixException; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; +import org.jogamp.vecmath.Vector4d; +import org.jogamp.vecmath.Vector4f; /** * A generalized transform object represented internally as a 4x4 diff --git a/src/javax/media/j3d/TransformGroup.java b/src/main/java/org/jogamp/java3d/TransformGroup.java index fd9d733..8809019 100644 --- a/src/javax/media/j3d/TransformGroup.java +++ b/src/main/java/org/jogamp/java3d/TransformGroup.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Group node that contains a transform. The TransformGroup node diff --git a/src/javax/media/j3d/TransformGroupData.java b/src/main/java/org/jogamp/java3d/TransformGroupData.java index fea8925..14c7e87 100644 --- a/src/javax/media/j3d/TransformGroupData.java +++ b/src/main/java/org/jogamp/java3d/TransformGroupData.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class TransformGroupData extends NodeData { // per path node data diff --git a/src/javax/media/j3d/TransformGroupRetained.java b/src/main/java/org/jogamp/java3d/TransformGroupRetained.java index e7d404d..426acea 100644 --- a/src/javax/media/j3d/TransformGroupRetained.java +++ b/src/main/java/org/jogamp/java3d/TransformGroupRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; @@ -122,22 +122,35 @@ ArrayList<NodeRetained> childTransformLinks = new ArrayList<NodeRetained>(1); * the passed transform. * @param t1 the transform to be copied */ + // re-use previous to avoid object creation, if nothing is still using it + private J3dMessage prevMessage; + private Transform3D trans = new Transform3D(); void setTransform(Transform3D t1) { + + //int i, j; J3dMessage tchangeMessage = null; - int i, j; - Transform3D trans = null; + if (prevMessage != null && prevMessage.getRefcount() == 0) + { + tchangeMessage = prevMessage; + } + else + { + tchangeMessage = new J3dMessage(); + // trans will still be in use as well in prev message re-create + trans = new Transform3D(); + } if (staticTransform != null) { // this writeable transformGroup has a static transform // merged into this node - trans = new Transform3D(staticTransform.transform); + trans.set(staticTransform.transform); trans.mul(t1); transform.setWithLock(trans); } else { - trans = new Transform3D(t1); + trans.set(t1); transform.setWithLock(t1); } @@ -151,7 +164,6 @@ ArrayList<NodeRetained> childTransformLinks = new ArrayList<NodeRetained>(1); throw new BadTransformException(J3dI18N.getString("ViewPlatformRetained0")); } - tchangeMessage = new J3dMessage(); tchangeMessage.type = J3dMessage.TRANSFORM_CHANGED; tchangeMessage.threads = targetThreads; tchangeMessage.args[1] = this; @@ -160,6 +172,7 @@ ArrayList<NodeRetained> childTransformLinks = new ArrayList<NodeRetained>(1); tchangeMessage.universe = universe; //System.err.println("TransformGroupRetained --- TRANSFORM_CHANGED " + this); VirtualUniverse.mc.processMessage(tchangeMessage); + prevMessage = tchangeMessage; } dirtyBoundsCache(); } @@ -415,12 +428,13 @@ ArrayList<NodeRetained> childTransformLinks = new ArrayList<NodeRetained>(1); for (int i = 0; i < level; i++) { System.err.print("."); } - System.err.print(this); + System.err.print( + this.source.getName() + " ret:" + this.getClass().getSimpleName() + " source:" + this.source.getClass().getSimpleName()); if (isStatic()) { System.err.print(" (s)"); } else { - System.err.print(" (w)"); + System.err.print(" (non-s)"); } System.err.println(); System.err.println(transform.toString()); diff --git a/src/javax/media/j3d/TransformInterpolator.java b/src/main/java/org/jogamp/java3d/TransformInterpolator.java index 09b4b95..07ff76a 100644 --- a/src/javax/media/j3d/TransformInterpolator.java +++ b/src/main/java/org/jogamp/java3d/TransformInterpolator.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** * TransformInterpolator is an abstract class that extends * Interpolator to provide common methods used by various transform @@ -155,11 +155,11 @@ public abstract class TransformInterpolator extends Interpolator { * First it gets the alpha value that corresponds to the current time. * Then it calls computeTransform() method to computes the transform based on this * alpha vaule, and updates the specified TransformGroup node with this new transform. - * @param criteria an enumeration of the criteria that caused the + * @param criteria an iterator of the criteria that caused the * stimulus */ @Override - public void processStimulus(Enumeration criteria) { + public void processStimulus(Iterator<WakeupCriterion> criteria) { // Handle stimulus WakeupCriterion criterion = passiveWakeupCriterion; diff --git a/src/javax/media/j3d/TransformStructure.java b/src/main/java/org/jogamp/java3d/TransformStructure.java index 1251540..b056c39 100644 --- a/src/javax/media/j3d/TransformStructure.java +++ b/src/main/java/org/jogamp/java3d/TransformStructure.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/javax/media/j3d/TransparencyAttributes.java b/src/main/java/org/jogamp/java3d/TransparencyAttributes.java index 2779f38..cc8be5a 100644 --- a/src/javax/media/j3d/TransparencyAttributes.java +++ b/src/main/java/org/jogamp/java3d/TransparencyAttributes.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The TransparencyAttributes object defines all attributes affecting diff --git a/src/javax/media/j3d/TransparencyAttributesRetained.java b/src/main/java/org/jogamp/java3d/TransparencyAttributesRetained.java index 5d531a8..f56a941 100644 --- a/src/javax/media/j3d/TransparencyAttributesRetained.java +++ b/src/main/java/org/jogamp/java3d/TransparencyAttributesRetained.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; @@ -92,6 +92,7 @@ class TransparencyAttributesRetained extends NodeComponentRetained { * fully opaque and 1.0 being fully transparent */ final void initTransparency(float transparency) { + transparency = Math.max(0, Math.min(1, transparency)); this.transparency = transparency; } @@ -103,6 +104,7 @@ class TransparencyAttributesRetained extends NodeComponentRetained { * fully opaque and 1.0 being fully transparent */ final void setTransparency(float transparency) { + transparency = Math.max(0, Math.min(1, transparency)); initTransparency(transparency); sendMessage(VALUE_CHANGED, new Float(transparency)); } diff --git a/src/javax/media/j3d/TransparencyInterpolator.java b/src/main/java/org/jogamp/java3d/TransparencyInterpolator.java index 633bb97..53e8ac6 100644 --- a/src/javax/media/j3d/TransparencyInterpolator.java +++ b/src/main/java/org/jogamp/java3d/TransparencyInterpolator.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** * TransparencyInterpolator behavior. This class defines a behavior @@ -165,11 +165,11 @@ public class TransparencyInterpolator extends Interpolator { * maps the alpha value that corresponds to the current time into a * transparency value and updates the specified TransparencyAttributes * object with this new transparency value. - * @param criteria an enumeration of the criteria that caused the + * @param criteria an iterator of the criteria that caused the * stimulus */ @Override - public void processStimulus(Enumeration criteria) { + public void processStimulus(Iterator<WakeupCriterion> criteria) { // Handle stimulus WakeupCriterion criterion = passiveWakeupCriterion; diff --git a/src/javax/media/j3d/TransparencySortGeom.java b/src/main/java/org/jogamp/java3d/TransparencySortGeom.java index f07a947..ea19f39 100644 --- a/src/javax/media/j3d/TransparencySortGeom.java +++ b/src/main/java/org/jogamp/java3d/TransparencySortGeom.java @@ -13,7 +13,7 @@ * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). */ -package javax.media.j3d; +package org.jogamp.java3d; /** * An interface that allows sorting the rendering order of transparent geometry. diff --git a/src/javax/media/j3d/TransparencySortMap.java b/src/main/java/org/jogamp/java3d/TransparencySortMap.java index 7f13d0a..6116c9b 100644 --- a/src/javax/media/j3d/TransparencySortMap.java +++ b/src/main/java/org/jogamp/java3d/TransparencySortMap.java @@ -13,7 +13,7 @@ * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Comparator; import java.util.WeakHashMap; diff --git a/src/javax/media/j3d/TransparentRenderingInfo.java b/src/main/java/org/jogamp/java3d/TransparentRenderingInfo.java index 3901bc9..2c394d3 100644 --- a/src/javax/media/j3d/TransparentRenderingInfo.java +++ b/src/main/java/org/jogamp/java3d/TransparentRenderingInfo.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class TransparentRenderingInfo extends Object implements TransparencySortGeom { diff --git a/src/javax/media/j3d/TriangleArray.java b/src/main/java/org/jogamp/java3d/TriangleArray.java index f1cfb9f..b0a21d5 100644 --- a/src/javax/media/j3d/TriangleArray.java +++ b/src/main/java/org/jogamp/java3d/TriangleArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The TriangleArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/TriangleArrayRetained.java b/src/main/java/org/jogamp/java3d/TriangleArrayRetained.java index 810ea7d..fdbdc06 100644 --- a/src/javax/media/j3d/TriangleArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/TriangleArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The TriangleArray object draws the array of vertices as individual diff --git a/src/javax/media/j3d/TriangleFanArray.java b/src/main/java/org/jogamp/java3d/TriangleFanArray.java index 51c9469..cd3754b 100644 --- a/src/javax/media/j3d/TriangleFanArray.java +++ b/src/main/java/org/jogamp/java3d/TriangleFanArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/TriangleFanArrayRetained.java b/src/main/java/org/jogamp/java3d/TriangleFanArrayRetained.java index 373a62b..2554e7d 100644 --- a/src/javax/media/j3d/TriangleFanArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/TriangleFanArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The TriangleFanArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/TriangleStripArray.java b/src/main/java/org/jogamp/java3d/TriangleStripArray.java index ebe9755..2e3568d 100644 --- a/src/javax/media/j3d/TriangleStripArray.java +++ b/src/main/java/org/jogamp/java3d/TriangleStripArray.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/TriangleStripArrayRetained.java b/src/main/java/org/jogamp/java3d/TriangleStripArrayRetained.java index c1da285..9a4bd79 100644 --- a/src/javax/media/j3d/TriangleStripArrayRetained.java +++ b/src/main/java/org/jogamp/java3d/TriangleStripArrayRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * The TriangleStripArray object draws an array of vertices as a set of diff --git a/src/javax/media/j3d/UnorderList.java b/src/main/java/org/jogamp/java3d/UnorderList.java index 3d8cdd8..265f31c 100644 --- a/src/javax/media/j3d/UnorderList.java +++ b/src/main/java/org/jogamp/java3d/UnorderList.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Arrays; /** diff --git a/src/javax/media/j3d/UpdateTargets.java b/src/main/java/org/jogamp/java3d/UpdateTargets.java index 6257226..e03a347 100644 --- a/src/javax/media/j3d/UpdateTargets.java +++ b/src/main/java/org/jogamp/java3d/UpdateTargets.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; class UpdateTargets { diff --git a/src/javax/media/j3d/Utils.java b/src/main/java/org/jogamp/java3d/Utils.java index dda1dca..d421992 100644 --- a/src/javax/media/j3d/Utils.java +++ b/src/main/java/org/jogamp/java3d/Utils.java @@ -13,10 +13,10 @@ * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * A small utility class for internal use. Mainly contains some distance-calculation diff --git a/src/javax/media/j3d/VertexArrayRenderMethod.java b/src/main/java/org/jogamp/java3d/VertexArrayRenderMethod.java index bdf937b..e0d50c9 100644 --- a/src/javax/media/j3d/VertexArrayRenderMethod.java +++ b/src/main/java/org/jogamp/java3d/VertexArrayRenderMethod.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * The RenderMethod interface is used to create various ways to render diff --git a/src/javax/media/j3d/View.java b/src/main/java/org/jogamp/java3d/View.java index d162ecd..fe0d5d9 100644 --- a/src/javax/media/j3d/View.java +++ b/src/main/java/org/jogamp/java3d/View.java @@ -24,17 +24,16 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.AWTEvent; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Iterator; import java.util.LinkedList; import java.util.Vector; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; /** * The View object contains all parameters needed in rendering a @@ -2162,11 +2161,11 @@ private ArrayList<ArrayList<Canvas3D>> canvasList = new ArrayList<ArrayList<Canv } /** - * Gets the enumeration object of all the Canvas3Ds. - * @return the enumeration object of all the Canvas3Ds. + * Gets the iterator object of all the Canvas3Ds. + * @return the iterator object of all the Canvas3Ds. */ - public Enumeration<Canvas3D> getAllCanvas3Ds(){ - return canvases.elements(); + public Iterator<Canvas3D> getAllCanvas3Ds(){ + return canvases.iterator(); } /** diff --git a/src/javax/media/j3d/ViewCache.java b/src/main/java/org/jogamp/java3d/ViewCache.java index 78ac9f0..e87c8c8 100644 --- a/src/javax/media/j3d/ViewCache.java +++ b/src/main/java/org/jogamp/java3d/ViewCache.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * The ViewCache class is used to cache all data, both API data and derived diff --git a/src/javax/media/j3d/ViewPlatform.java b/src/main/java/org/jogamp/java3d/ViewPlatform.java index d99447b..97aa3b1 100644 --- a/src/javax/media/j3d/ViewPlatform.java +++ b/src/main/java/org/jogamp/java3d/ViewPlatform.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/ViewPlatformRetained.java b/src/main/java/org/jogamp/java3d/ViewPlatformRetained.java index 4d9f069..5ebe76e 100644 --- a/src/javax/media/j3d/ViewPlatformRetained.java +++ b/src/main/java/org/jogamp/java3d/ViewPlatformRetained.java @@ -24,11 +24,11 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import javax.vecmath.Point3d; +import org.jogamp.vecmath.Point3d; /** * ViewPlatform object (retained side) diff --git a/src/javax/media/j3d/ViewSpecificGroup.java b/src/main/java/org/jogamp/java3d/ViewSpecificGroup.java index b8913a9..8c23a62 100644 --- a/src/javax/media/j3d/ViewSpecificGroup.java +++ b/src/main/java/org/jogamp/java3d/ViewSpecificGroup.java @@ -24,9 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** * The ViewSpecificGroup node is a Group whose descendants are @@ -185,14 +185,14 @@ public class ViewSpecificGroup extends Group { /** - * Returns an enumeration of this ViewSpecificGroup node's list + * Returns an iterator of this ViewSpecificGroup node's list * of views. * - * @return an Enumeration object containing all the views. + * @return an Iterator object containing all the views. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ -public Enumeration<View> getAllViews() { +public Iterator<View> getAllViews() { if (isLiveOrCompiled() && !this.getCapability(ALLOW_VIEW_READ)) throw new CapabilityNotSetException(J3dI18N.getString("ViewSpecificGroup2")); @@ -352,8 +352,8 @@ public Enumeration<View> getAllViews() { ViewSpecificGroupRetained attr = (ViewSpecificGroupRetained) originalNode.retained; ViewSpecificGroupRetained rt = (ViewSpecificGroupRetained) retained; - for (Enumeration<View> e = attr.getAllViews(); e.hasMoreElements(); ) { - rt.addView(e.nextElement()); + for (Iterator<View> e = attr.getAllViews(); e.hasNext(); ) { + rt.addView(e.next()); } } diff --git a/src/javax/media/j3d/ViewSpecificGroupRetained.java b/src/main/java/org/jogamp/java3d/ViewSpecificGroupRetained.java index 69fde27..d301c15 100644 --- a/src/javax/media/j3d/ViewSpecificGroupRetained.java +++ b/src/main/java/org/jogamp/java3d/ViewSpecificGroupRetained.java @@ -24,10 +24,10 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; /** @@ -494,12 +494,12 @@ View getView(int index) { } } -Enumeration<View> getAllViews() { +Iterator<View> getAllViews() { Vector<View> viewList = new Vector<View>(apiViewList.size()); for (int i = 0; i < apiViewList.size(); i++) { viewList.add(apiViewList.get(i)); } - return viewList.elements(); + return viewList.iterator(); } int numViews() { diff --git a/src/javax/media/j3d/VirtualUniverse.java b/src/main/java/org/jogamp/java3d/VirtualUniverse.java index 42e3725..89b83bd 100644 --- a/src/javax/media/j3d/VirtualUniverse.java +++ b/src/main/java/org/jogamp/java3d/VirtualUniverse.java @@ -24,10 +24,9 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; import java.util.Map; @@ -358,12 +357,12 @@ ArrayList<Integer> viewIdFreeList = new ArrayList<Integer>(); /** - * Returns the enumeration object of all locales in this virtual universe. + * Returns the iterator object of all locales in this virtual universe. * - * @return the enumeration object + * @return the iterator object */ -public Enumeration<Locale> getAllLocales() { - return this.listOfLocales.elements(); +public Iterator<Locale> getAllLocales() { + return this.listOfLocales.iterator(); } /** @@ -681,9 +680,9 @@ void disableFocusEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.disableFocusEvents(); @@ -699,9 +698,9 @@ void enableFocusEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.enableFocusEvents(); @@ -717,9 +716,9 @@ void disableKeyEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.disableKeyEvents(); @@ -735,9 +734,9 @@ void enableKeyEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.enableKeyEvents(); @@ -753,9 +752,9 @@ void disableMouseEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.disableMouseEvents(); @@ -771,9 +770,9 @@ void enableMouseEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.enableMouseEvents(); @@ -789,9 +788,9 @@ void disableMouseMotionEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.disableMouseMotionEvents(); @@ -807,9 +806,9 @@ void enableMouseMotionEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.enableMouseMotionEvents(); @@ -825,9 +824,9 @@ void disableMouseWheelEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.disableMouseWheelEvents(); @@ -843,9 +842,9 @@ void enableMouseWheelEvents() { for (int i = 0; i < vps.length; i++) { View[] views = vps[i].getViewList(); for (int j = views.length - 1; j >= 0; j--) { - Enumeration<Canvas3D> cvs = views[j].getAllCanvas3Ds(); - while (cvs.hasMoreElements()) { - Canvas3D cv = cvs.nextElement(); + Iterator<Canvas3D> cvs = views[j].getAllCanvas3Ds(); + while (cvs.hasNext()) { + Canvas3D cv = cvs.next(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.enableMouseWheelEvents(); @@ -886,10 +885,10 @@ void enableMouseWheelEvents() { * attach to it. */ boolean isEmpty() { - Enumeration<Locale> elm = listOfLocales.elements(); + Iterator<Locale> elm = listOfLocales.iterator(); - while (elm.hasMoreElements()) { - Locale loc = elm.nextElement(); + while (elm.hasNext()) { + Locale loc = elm.next(); if (!loc.branchGroups.isEmpty()) { return false; } diff --git a/src/javax/media/j3d/WakeupAnd.java b/src/main/java/org/jogamp/java3d/WakeupAnd.java index a00c2fe..cafd162 100644 --- a/src/javax/media/j3d/WakeupAnd.java +++ b/src/main/java/org/jogamp/java3d/WakeupAnd.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/WakeupAndOfOrs.java b/src/main/java/org/jogamp/java3d/WakeupAndOfOrs.java index 54243d3..0d2dbc6 100644 --- a/src/javax/media/j3d/WakeupAndOfOrs.java +++ b/src/main/java/org/jogamp/java3d/WakeupAndOfOrs.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/WakeupCondition.java b/src/main/java/org/jogamp/java3d/WakeupCondition.java index 7145483..52eaa63 100644 --- a/src/javax/media/j3d/WakeupCondition.java +++ b/src/main/java/org/jogamp/java3d/WakeupCondition.java @@ -24,16 +24,16 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; /** * An abstract class specifying a single wakeup Condition. This class * is extended by the WakeupCriterion, WakeupOr, WakeupAnd, * WakeupOrOfAnds, and WakeupAndOfOr classes. A Behavior node hands a * WakeupCondition object to the behavior scheduler and the behavior - * scheduler hands back an enumeration of that WakeupCondition. + * scheduler hands back an iterator of that WakeupCondition. */ public abstract class WakeupCondition extends Object { @@ -75,24 +75,32 @@ public abstract class WakeupCondition extends Object { int listIdx[][]; /** - * Returns an enumeration of all WakeupCriterias in this Condition. + * Returns an iterator of all WakeupCriterias in this Condition. */ - public Enumeration allElements() { - if (allEnum == null) { + public Iterator<WakeupCriterion> allElements() + { + if (allEnum == null) + { allEnum = new WakeupCriteriaEnumerator(this, ALL_ELEMENTS); - } else { + } + else + { allEnum.reset(this, ALL_ELEMENTS); } return allEnum; } /** - * Returns an enumeration of all triggered WakeupCriterias in this Condition. + * Returns an iterator of all triggered WakeupCriterias in this Condition. */ - public Enumeration triggeredElements() { - if (trigEnum == null) { + public Iterator<WakeupCriterion> triggeredElements() + { + if (trigEnum == null) + { trigEnum = new WakeupCriteriaEnumerator(this, TRIGGERED_ELEMENTS); - } else { + } + else + { trigEnum.reset(this, TRIGGERED_ELEMENTS); } return trigEnum; @@ -101,11 +109,22 @@ public abstract class WakeupCondition extends Object { /** * this sets the conditionMet flag. */ - void setConditionMet(int id, Boolean checkSchedulingRegion) { - - if (!conditionMet) { + // re-use previous to avoid object creation, if nothing is stillusing it + private J3dMessage prevMessage; + void setConditionMet(int id, Boolean checkSchedulingRegion) + { + if (!conditionMet) + { conditionMet = true; - J3dMessage message = new J3dMessage(); + J3dMessage message = null; + if (prevMessage != null && prevMessage.getRefcount() == 0) + { + message = prevMessage; + } + else + { + message = new J3dMessage(); + } message.type = J3dMessage.COND_MET; message.threads = J3dThread.UPDATE_BEHAVIOR; message.universe = behav.universe; @@ -113,6 +132,7 @@ public abstract class WakeupCondition extends Object { message.args[1] = checkSchedulingRegion; message.args[2] = this; VirtualUniverse.mc.processMessage(message); + prevMessage = message; } } diff --git a/src/javax/media/j3d/WakeupCriteriaEnumerator.java b/src/main/java/org/jogamp/java3d/WakeupCriteriaEnumerator.java index c3b00e8..e49a4e5 100644 --- a/src/javax/media/j3d/WakeupCriteriaEnumerator.java +++ b/src/main/java/org/jogamp/java3d/WakeupCriteriaEnumerator.java @@ -24,16 +24,16 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; -import java.util.Enumeration; +import java.util.Iterator; import java.util.NoSuchElementException; /** * A class that enumerates all wakeup criteria in a wakeup condition */ -class WakeupCriteriaEnumerator implements Enumeration { +class WakeupCriteriaEnumerator implements Iterator<WakeupCriterion> { // An array used for the current criteria in this object WakeupCriterion[] criterion = null; @@ -131,19 +131,31 @@ class WakeupCriteriaEnumerator implements Enumeration { } @Override - public boolean hasMoreElements() { - if (currentIndex == length) { - return false; - } - return true; + public boolean hasNext() + { + if (currentIndex == length) + { + return false; + } + return true; } @Override - public Object nextElement() { - if (currentIndex < length) { - return criterion[currentIndex++]; - } else { - throw new NoSuchElementException(J3dI18N.getString("WakeupCriteriaEnumerator0")); - } + public WakeupCriterion next() + { + if (currentIndex < length) + { + return criterion[currentIndex++]; + } + else + { + throw new NoSuchElementException(J3dI18N.getString("WakeupCriteriaEnumerator0")); + } } + + @Override + public void remove() + { + throw new UnsupportedOperationException(); + } } diff --git a/src/javax/media/j3d/WakeupCriterion.java b/src/main/java/org/jogamp/java3d/WakeupCriterion.java index 784bde9..2ebaade 100644 --- a/src/javax/media/j3d/WakeupCriterion.java +++ b/src/main/java/org/jogamp/java3d/WakeupCriterion.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * An abstract class specifying a singleton wakeup Criterion. This diff --git a/src/javax/media/j3d/WakeupIndexedList.java b/src/main/java/org/jogamp/java3d/WakeupIndexedList.java index 5eb7de1..6293553 100644 --- a/src/javax/media/j3d/WakeupIndexedList.java +++ b/src/main/java/org/jogamp/java3d/WakeupIndexedList.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A strongly type unorder indexed array list. diff --git a/src/javax/media/j3d/WakeupOnAWTEvent.java b/src/main/java/org/jogamp/java3d/WakeupOnAWTEvent.java index effa7c2..30f76a6 100644 --- a/src/javax/media/j3d/WakeupOnAWTEvent.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnAWTEvent.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.awt.AWTEvent; import java.awt.event.FocusEvent; diff --git a/src/javax/media/j3d/WakeupOnActivation.java b/src/main/java/org/jogamp/java3d/WakeupOnActivation.java index 6b438c3..63ae31b 100644 --- a/src/javax/media/j3d/WakeupOnActivation.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnActivation.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup the first time an active Viewplatform's diff --git a/src/javax/media/j3d/WakeupOnBehaviorPost.java b/src/main/java/org/jogamp/java3d/WakeupOnBehaviorPost.java index 4e2d9c5..a5fa1b4 100644 --- a/src/javax/media/j3d/WakeupOnBehaviorPost.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnBehaviorPost.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class that specifies a Behavior wakeup when a specific behavior object diff --git a/src/javax/media/j3d/WakeupOnCollisionEntry.java b/src/main/java/org/jogamp/java3d/WakeupOnCollisionEntry.java index 27fcd63..386de5b 100644 --- a/src/javax/media/j3d/WakeupOnCollisionEntry.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnCollisionEntry.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; import java.util.Vector; diff --git a/src/javax/media/j3d/WakeupOnCollisionExit.java b/src/main/java/org/jogamp/java3d/WakeupOnCollisionExit.java index 775096f..8a33101 100644 --- a/src/javax/media/j3d/WakeupOnCollisionExit.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnCollisionExit.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup when the specified object diff --git a/src/javax/media/j3d/WakeupOnCollisionMovement.java b/src/main/java/org/jogamp/java3d/WakeupOnCollisionMovement.java index a4942e3..e07309e 100644 --- a/src/javax/media/j3d/WakeupOnCollisionMovement.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnCollisionMovement.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup when the specified object diff --git a/src/javax/media/j3d/WakeupOnDeactivation.java b/src/main/java/org/jogamp/java3d/WakeupOnDeactivation.java index 91acb03..4b0dff8 100644 --- a/src/javax/media/j3d/WakeupOnDeactivation.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnDeactivation.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup on first detection of a Viewplatform's diff --git a/src/javax/media/j3d/WakeupOnElapsedFrames.java b/src/main/java/org/jogamp/java3d/WakeupOnElapsedFrames.java index cb596a4..0be5808 100644 --- a/src/javax/media/j3d/WakeupOnElapsedFrames.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnElapsedFrames.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup when a specific number of frames have diff --git a/src/javax/media/j3d/WakeupOnElapsedTime.java b/src/main/java/org/jogamp/java3d/WakeupOnElapsedTime.java index 1f93bd3..fbd76a5 100644 --- a/src/javax/media/j3d/WakeupOnElapsedTime.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnElapsedTime.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup when a specific number of milliseconds diff --git a/src/javax/media/j3d/WakeupOnElapsedTimeHeap.java b/src/main/java/org/jogamp/java3d/WakeupOnElapsedTimeHeap.java index d14a148..27cad5f 100644 --- a/src/javax/media/j3d/WakeupOnElapsedTimeHeap.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnElapsedTimeHeap.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * A Binary heap to store WakeupOnElapsedTime. It is arranged so that the diff --git a/src/javax/media/j3d/WakeupOnSensorEntry.java b/src/main/java/org/jogamp/java3d/WakeupOnSensorEntry.java index 4da94dc..4e07688 100644 --- a/src/javax/media/j3d/WakeupOnSensorEntry.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnSensorEntry.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup on first sensor intersection with the diff --git a/src/javax/media/j3d/WakeupOnSensorExit.java b/src/main/java/org/jogamp/java3d/WakeupOnSensorExit.java index a7d314b..b550907 100644 --- a/src/javax/media/j3d/WakeupOnSensorExit.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnSensorExit.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup on first detection of sensors no diff --git a/src/javax/media/j3d/WakeupOnTransformChange.java b/src/main/java/org/jogamp/java3d/WakeupOnTransformChange.java index 2ef17c9..b0fa1b6 100644 --- a/src/javax/media/j3d/WakeupOnTransformChange.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnTransformChange.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup when the transform within a specified diff --git a/src/javax/media/j3d/WakeupOnViewPlatformEntry.java b/src/main/java/org/jogamp/java3d/WakeupOnViewPlatformEntry.java index 33f3d65..7de03e2 100644 --- a/src/javax/media/j3d/WakeupOnViewPlatformEntry.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnViewPlatformEntry.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup when an active ViewPlatform intersects the diff --git a/src/javax/media/j3d/WakeupOnViewPlatformExit.java b/src/main/java/org/jogamp/java3d/WakeupOnViewPlatformExit.java index 4778ea7..9650bd3 100644 --- a/src/javax/media/j3d/WakeupOnViewPlatformExit.java +++ b/src/main/java/org/jogamp/java3d/WakeupOnViewPlatformExit.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** * Class specifying a wakeup when an active ViewPlatform no longer diff --git a/src/javax/media/j3d/WakeupOr.java b/src/main/java/org/jogamp/java3d/WakeupOr.java index 1d4b934..386cff0 100644 --- a/src/javax/media/j3d/WakeupOr.java +++ b/src/main/java/org/jogamp/java3d/WakeupOr.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/WakeupOrOfAnds.java b/src/main/java/org/jogamp/java3d/WakeupOrOfAnds.java index 1038f23..9accb98 100644 --- a/src/javax/media/j3d/WakeupOrOfAnds.java +++ b/src/main/java/org/jogamp/java3d/WakeupOrOfAnds.java @@ -24,7 +24,7 @@ * */ -package javax.media.j3d; +package org.jogamp.java3d; /** diff --git a/src/javax/media/j3d/doc-files/Behaviors.html b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors.html index 7bcc4a2..7bcc4a2 100644 --- a/src/javax/media/j3d/doc-files/Behaviors.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors.html diff --git a/src/javax/media/j3d/doc-files/Behaviors1.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors1.gif Binary files differindex bb288ce..bb288ce 100644 --- a/src/javax/media/j3d/doc-files/Behaviors1.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors1.gif diff --git a/src/javax/media/j3d/doc-files/Behaviors2.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors2.gif Binary files differindex 005564f..005564f 100644 --- a/src/javax/media/j3d/doc-files/Behaviors2.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors2.gif diff --git a/src/javax/media/j3d/doc-files/Behaviors3.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors3.gif Binary files differindex a8beb09..a8beb09 100644 --- a/src/javax/media/j3d/doc-files/Behaviors3.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors3.gif diff --git a/src/javax/media/j3d/doc-files/Behaviors4.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors4.gif Binary files differindex 685bcb7..685bcb7 100644 --- a/src/javax/media/j3d/doc-files/Behaviors4.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors4.gif diff --git a/src/javax/media/j3d/doc-files/Behaviors5.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors5.gif Binary files differindex 74783fb..74783fb 100644 --- a/src/javax/media/j3d/doc-files/Behaviors5.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors5.gif diff --git a/src/javax/media/j3d/doc-files/Behaviors6.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors6.gif Binary files differindex 8614a4e..8614a4e 100644 --- a/src/javax/media/j3d/doc-files/Behaviors6.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors6.gif diff --git a/src/javax/media/j3d/doc-files/Behaviors7.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors7.gif Binary files differindex 0f2ce48..0f2ce48 100644 --- a/src/javax/media/j3d/doc-files/Behaviors7.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors7.gif diff --git a/src/javax/media/j3d/doc-files/Behaviors8.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors8.gif Binary files differindex d048cfa..d048cfa 100644 --- a/src/javax/media/j3d/doc-files/Behaviors8.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Behaviors8.gif diff --git a/src/javax/media/j3d/doc-files/Concepts.html b/src/main/javadoc/org/jogamp/java3d/doc-files/Concepts.html index 7b005af..7b005af 100644 --- a/src/javax/media/j3d/doc-files/Concepts.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Concepts.html diff --git a/src/javax/media/j3d/doc-files/Concepts1.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Concepts1.gif Binary files differindex 8aa0dbc..8aa0dbc 100644 --- a/src/javax/media/j3d/doc-files/Concepts1.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Concepts1.gif diff --git a/src/javax/media/j3d/doc-files/Concepts2.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Concepts2.gif Binary files differindex f21e085..f21e085 100644 --- a/src/javax/media/j3d/doc-files/Concepts2.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Concepts2.gif diff --git a/src/javax/media/j3d/doc-files/DAG.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/DAG.gif Binary files differindex 8479136..8479136 100644 --- a/src/javax/media/j3d/doc-files/DAG.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/DAG.gif diff --git a/src/javax/media/j3d/doc-files/HelloUniverse.html b/src/main/javadoc/org/jogamp/java3d/doc-files/HelloUniverse.html index 5e37bd6..5e37bd6 100644 --- a/src/javax/media/j3d/doc-files/HelloUniverse.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/HelloUniverse.html diff --git a/src/javax/media/j3d/doc-files/Immediate.html b/src/main/javadoc/org/jogamp/java3d/doc-files/Immediate.html index 101fe22..101fe22 100644 --- a/src/javax/media/j3d/doc-files/Immediate.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Immediate.html diff --git a/src/javax/media/j3d/doc-files/Immediate1.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/Immediate1.gif Binary files differindex 2d549b1..2d549b1 100644 --- a/src/javax/media/j3d/doc-files/Immediate1.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Immediate1.gif diff --git a/src/javax/media/j3d/doc-files/Rendering.html b/src/main/javadoc/org/jogamp/java3d/doc-files/Rendering.html index 7415ce8..7415ce8 100644 --- a/src/javax/media/j3d/doc-files/Rendering.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/Rendering.html diff --git a/src/javax/media/j3d/doc-files/SceneGraphOverview.html b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphOverview.html index f1616df..f1616df 100644 --- a/src/javax/media/j3d/doc-files/SceneGraphOverview.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphOverview.html diff --git a/src/javax/media/j3d/doc-files/SceneGraphSharing.html b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing.html index ff80cb4..ff80cb4 100644 --- a/src/javax/media/j3d/doc-files/SceneGraphSharing.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing.html diff --git a/src/javax/media/j3d/doc-files/SceneGraphSharing1.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing1.gif Binary files differindex f6ca47c..f6ca47c 100644 --- a/src/javax/media/j3d/doc-files/SceneGraphSharing1.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing1.gif diff --git a/src/javax/media/j3d/doc-files/SceneGraphSharing2.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing2.gif Binary files differindex c062c81..c062c81 100644 --- a/src/javax/media/j3d/doc-files/SceneGraphSharing2.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing2.gif diff --git a/src/javax/media/j3d/doc-files/SceneGraphSharing3.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing3.gif Binary files differindex 325cab1..325cab1 100644 --- a/src/javax/media/j3d/doc-files/SceneGraphSharing3.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing3.gif diff --git a/src/javax/media/j3d/doc-files/SceneGraphSharing4.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing4.gif Binary files differindex 78aeaab..78aeaab 100644 --- a/src/javax/media/j3d/doc-files/SceneGraphSharing4.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing4.gif diff --git a/src/javax/media/j3d/doc-files/SceneGraphSharing5.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing5.gif Binary files differindex 2ff6547..2ff6547 100644 --- a/src/javax/media/j3d/doc-files/SceneGraphSharing5.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/SceneGraphSharing5.gif diff --git a/src/javax/media/j3d/doc-files/ViewBranch.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewBranch.gif Binary files differindex 75cc40d..75cc40d 100644 --- a/src/javax/media/j3d/doc-files/ViewBranch.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewBranch.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel.html b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel.html index 3cc9ece..3cc9ece 100644 --- a/src/javax/media/j3d/doc-files/ViewModel.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel.html diff --git a/src/javax/media/j3d/doc-files/ViewModel1.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel1.gif Binary files differindex e94743e..e94743e 100644 --- a/src/javax/media/j3d/doc-files/ViewModel1.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel1.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel10.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel10.gif Binary files differindex aceb6e7..aceb6e7 100644 --- a/src/javax/media/j3d/doc-files/ViewModel10.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel10.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel11.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel11.gif Binary files differindex f943c15..f943c15 100644 --- a/src/javax/media/j3d/doc-files/ViewModel11.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel11.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel12.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel12.gif Binary files differindex 787afe7..787afe7 100644 --- a/src/javax/media/j3d/doc-files/ViewModel12.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel12.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel13.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel13.gif Binary files differindex a8482ef..a8482ef 100644 --- a/src/javax/media/j3d/doc-files/ViewModel13.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel13.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel14.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel14.gif Binary files differindex f201443..f201443 100644 --- a/src/javax/media/j3d/doc-files/ViewModel14.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel14.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel2.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel2.gif Binary files differindex 2d549b1..2d549b1 100644 --- a/src/javax/media/j3d/doc-files/ViewModel2.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel2.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel3.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel3.gif Binary files differindex 5285015..5285015 100644 --- a/src/javax/media/j3d/doc-files/ViewModel3.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel3.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel4.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel4.gif Binary files differindex ab9db1d..ab9db1d 100644 --- a/src/javax/media/j3d/doc-files/ViewModel4.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel4.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel5.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel5.gif Binary files differindex 859b456..859b456 100644 --- a/src/javax/media/j3d/doc-files/ViewModel5.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel5.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel6.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel6.gif Binary files differindex 2200595..2200595 100644 --- a/src/javax/media/j3d/doc-files/ViewModel6.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel6.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel7.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel7.gif Binary files differindex ec84ac2..ec84ac2 100644 --- a/src/javax/media/j3d/doc-files/ViewModel7.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel7.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel8.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel8.gif Binary files differindex ee4b331..ee4b331 100644 --- a/src/javax/media/j3d/doc-files/ViewModel8.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel8.gif diff --git a/src/javax/media/j3d/doc-files/ViewModel9.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel9.gif Binary files differindex 0cbf72c..0cbf72c 100644 --- a/src/javax/media/j3d/doc-files/ViewModel9.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/ViewModel9.gif diff --git a/src/javax/media/j3d/doc-files/VirtualUniverse.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/VirtualUniverse.gif Binary files differindex 4d713a8..4d713a8 100644 --- a/src/javax/media/j3d/doc-files/VirtualUniverse.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/VirtualUniverse.gif diff --git a/src/javax/media/j3d/doc-files/VirtualUniverse.html b/src/main/javadoc/org/jogamp/java3d/doc-files/VirtualUniverse.html index 2f9dd14..2f9dd14 100644 --- a/src/javax/media/j3d/doc-files/VirtualUniverse.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/VirtualUniverse.html diff --git a/src/javax/media/j3d/doc-files/intro.gif b/src/main/javadoc/org/jogamp/java3d/doc-files/intro.gif Binary files differindex 503f818..503f818 100644 --- a/src/javax/media/j3d/doc-files/intro.gif +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/intro.gif diff --git a/src/javax/media/j3d/doc-files/intro.html b/src/main/javadoc/org/jogamp/java3d/doc-files/intro.html index f5ea134..f5ea134 100644 --- a/src/javax/media/j3d/doc-files/intro.html +++ b/src/main/javadoc/org/jogamp/java3d/doc-files/intro.html diff --git a/src/javax/media/j3d/package.html b/src/main/javadoc/org/jogamp/java3d/package.html index a9a3553..d95eda6 100644 --- a/src/javax/media/j3d/package.html +++ b/src/main/javadoc/org/jogamp/java3d/package.html @@ -3,7 +3,7 @@ <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> - <title>javax.media.j3d</title> + <title>org.jogamp.java3d</title> </head> <body> diff --git a/src/javax/media/j3d/ExceptionStrings.properties b/src/main/resources/org/jogamp/java3d/ExceptionStrings.properties index 05ee875..05ee875 100644 --- a/src/javax/media/j3d/ExceptionStrings.properties +++ b/src/main/resources/org/jogamp/java3d/ExceptionStrings.properties |