From 6f9cb656934fe9daa85e585ee2770210ceb43950 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Oct 2013 00:27:08 +0100 Subject: Bug 776 GLContext Sharing: Fix copy-ctor GLArrayDataClient: Create new instance of GLArrayHandler of same type; Simplify GLArrayHandler inheritance. Refines commit 9f2a9df0a4b7093925c8854b37fba053469a4b35 --- .../classes/com/jogamp/opengl/util/GLArrayDataClient.java | 13 ++++++++++++- .../jogamp/opengl/util/GLArrayHandlerInterleaved.java | 4 ++-- src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java | 2 +- .../classes/jogamp/opengl/util/GLFixedArrayHandler.java | 2 +- .../classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java | 3 +-- .../opengl/util/glsl/GLSLArrayHandlerInterleaved.java | 5 ++--- 6 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index e281b14fd..f84342e88 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.util; +import java.lang.reflect.Constructor; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.FloatBuffer; @@ -461,7 +462,17 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData this.bufferWritten = src.bufferWritten; this.enableBufferAlways = src.enableBufferAlways; this.initialElementCount = src.initialElementCount; - this.glArrayHandler = src.glArrayHandler; + if( null != src.glArrayHandler ) { + final Class clazz = src.glArrayHandler.getClass(); + try { + final Constructor ctor = clazz.getConstructor(GLArrayDataEditable.class); + this.glArrayHandler = ctor.newInstance(this); + } catch (Exception e) { + throw new RuntimeException("Could not ctor "+clazz.getName()+"("+this.getClass().getName()+")", e); + } + } else { + this.glArrayHandler = null; + } this.usesGLSL = src.usesGLSL; this.shaderState = src.shaderState; } diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java index 0d4452864..89e01edd8 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java +++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java @@ -39,8 +39,8 @@ import com.jogamp.opengl.util.GLArrayDataEditable; * Interleaved fixed function arrays, i.e. where this buffer data * represents many arrays. */ -public class GLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLArrayHandler { - private List subArrays = new ArrayList(); +public class GLArrayHandlerInterleaved extends GLVBOArrayHandler { + private final List subArrays = new ArrayList(); public GLArrayHandlerInterleaved(GLArrayDataEditable ad) { super(ad); diff --git a/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java index c1f6b954a..8a587980d 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java @@ -38,7 +38,7 @@ import com.jogamp.opengl.util.GLArrayDataEditable; * Used for pure VBO data arrays, i.e. where the buffer data * does not represents a specific array name. */ -public class GLDataArrayHandler extends GLVBOArrayHandler implements GLArrayHandler { +public class GLDataArrayHandler extends GLVBOArrayHandler { public GLDataArrayHandler(GLArrayDataEditable ad) { super(ad); diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java index 3aac9612a..7f7a99a2d 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java @@ -38,7 +38,7 @@ import com.jogamp.opengl.util.GLArrayDataEditable; * Used for 1:1 fixed function arrays, i.e. where the buffer data * represents this array only. */ -public class GLFixedArrayHandler extends GLVBOArrayHandler implements GLArrayHandler { +public class GLFixedArrayHandler extends GLVBOArrayHandler { public GLFixedArrayHandler(GLArrayDataEditable ad) { super(ad); } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java index 3b443fdd0..1f402f48b 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java @@ -33,7 +33,6 @@ import java.nio.Buffer; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; -import jogamp.opengl.util.GLArrayHandler; import jogamp.opengl.util.GLArrayHandlerFlat; import jogamp.opengl.util.GLVBOArrayHandler; @@ -44,7 +43,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; * Used for 1:1 GLSL arrays, i.e. where the buffer data * represents this array only. */ -public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandler { +public class GLSLArrayHandler extends GLVBOArrayHandler { public GLSLArrayHandler(GLArrayDataEditable ad) { super(ad); diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java index b175bb5dc..e153082e0 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java @@ -33,7 +33,6 @@ import java.util.List; import javax.media.opengl.GL; -import jogamp.opengl.util.GLArrayHandler; import jogamp.opengl.util.GLArrayHandlerFlat; import jogamp.opengl.util.GLVBOArrayHandler; @@ -43,8 +42,8 @@ import com.jogamp.opengl.util.GLArrayDataEditable; * Interleaved fixed function arrays, i.e. where this buffer data * represents many arrays. */ -public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLArrayHandler { - private List subArrays = new ArrayList(); +public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler { + private final List subArrays = new ArrayList(); public GLSLArrayHandlerInterleaved(GLArrayDataEditable ad) { super(ad); -- cgit v1.2.3