diff options
author | Sven Gothel <[email protected]> | 2013-10-30 00:27:08 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-30 00:27:08 +0100 |
commit | 6f9cb656934fe9daa85e585ee2770210ceb43950 (patch) | |
tree | 642ecf339ac3a8e131e146a031ece504fe41723d | |
parent | 0943389a6d34622c112ed73ce3d2d2e25434ce59 (diff) |
Bug 776 GLContext Sharing: Fix copy-ctor GLArrayDataClient: Create new instance of GLArrayHandler of same type; Simplify GLArrayHandler inheritance.
Refines commit 9f2a9df0a4b7093925c8854b37fba053469a4b35
6 files changed, 19 insertions, 10 deletions
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<? extends GLArrayHandler> clazz = src.glArrayHandler.getClass(); + try { + final Constructor<? extends GLArrayHandler> 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<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>(); +public class GLArrayHandlerInterleaved extends GLVBOArrayHandler { + private final List<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>(); 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<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>(); +public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler { + private final List<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>(); public GLSLArrayHandlerInterleaved(GLArrayDataEditable ad) { super(ad); |