From 6c346d98f04e2355210960fe9ffde47432f04d62 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 22 Aug 2011 01:59:00 +0200 Subject: Misc Rename/Reloc; GLArrayData*/PMVMatrix enhancments; Test fixes/adds (GearsES1/ES2) rename/reloc: - javax.media.nativewindow.util: DimensionReadOnly -> DimensionImmutable PointReadOnly -> PointImmutable RectangleReadOnly -> RectangleImmutable unified 'immutable' name as used within jogamp already - remove array handler from public API com.jogamp.opengl.util.GL*ArrayHandler -> jogamp.opengl.util.GL*ArrayHandler - GLArrayData: Clarify method names getComponentNumber() -> getComponentCount() getComponentSize() -> getComponentSizeInBytes() getElementNumber() -> getElementCount() getByteSize() -> getSizeInBytes() - FixedFuncPipeline: Moved def. array names to GLPointerFuncUtil enhancement: - GLArrayDataServer: Add support for interleaved arrays/VBO - GLArrayData*.createFixed(..) remove 'name' argument (non sense for fixed function) - PMVMatrix: - one nio buffer - removed 'Pmv' multiplied matrix - removed 2x2 cut down 'Mvi' normal matrix (use 4x4 Mvi) - tests: - RedSquare -> RedSquareES1/RedSquareES2 - Gears ES1 fixed + ES2 added. Both work properly and share common Gears VBO construction - Added TestMapBuffer01NEWT, testing glMapBuffer --- .../jogamp/opengl/util/GLDataArrayHandler.java | 73 ++++++++++++++++ .../jogamp/opengl/util/GLFixedArrayHandler.java | 99 ++++++++++++++++++++++ .../opengl/util/GLFixedArrayHandlerFlat.java | 82 ++++++++++++++++++ .../util/GLFixedArrayHandlerInterleaved.java | 87 +++++++++++++++++++ .../jogamp/opengl/util/glsl/GLSLArrayHandler.java | 94 ++++++++++++++++++++ .../opengl/util/glsl/GLSLArrayHandlerFlat.java | 66 +++++++++++++++ .../util/glsl/GLSLArrayHandlerInterleaved.java | 96 +++++++++++++++++++++ .../opengl/util/glsl/fixedfunc/FixedFuncHook.java | 27 +++++- .../util/glsl/fixedfunc/FixedFuncPipeline.java | 65 +++++++------- .../glsl/fixedfunc/shaders/FixedFuncColorLight.vp | 4 +- .../util/glsl/fixedfunc/shaders/mgl_attribute.glsl | 2 +- .../util/glsl/fixedfunc/shaders/mgl_uniform.glsl | 3 +- 12 files changed, 659 insertions(+), 39 deletions(-) create mode 100644 src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java create mode 100644 src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java create mode 100644 src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java create mode 100644 src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java create mode 100644 src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java create mode 100644 src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java create mode 100644 src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java (limited to 'src/jogl/classes/jogamp/opengl/util') diff --git a/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java new file mode 100644 index 000000000..718b63822 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java @@ -0,0 +1,73 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util; + +import javax.media.opengl.*; +import com.jogamp.opengl.util.*; + +import java.nio.*; + +/** + * Used for pure VBO data arrays, i.e. where the buffer data + * does not represents a specific array name. + */ +public class GLDataArrayHandler implements GLArrayHandler { + private GLArrayDataEditable ad; + + public GLDataArrayHandler(GLArrayDataEditable ad) { + this.ad = ad; + if(!ad.isVBO()) { + // makes no sense otherwise + throw new GLException("GLDataArrayHandler can only handle VBOs."); + } + } + + public final void addSubHandler(GLArrayHandler handler) { + throw new UnsupportedOperationException(); + } + + public final void enableBuffer(GL gl, boolean enable) { + if(enable) { + Buffer buffer = ad.getBuffer(); + + // always bind and refresh the VBO mgr, + // in case more than one gl*Pointer objects are in use + gl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName()); + if(!ad.isVBOWritten()) { + if(null!=buffer) { + gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSizeInBytes(), buffer, ad.getVBOUsage()); + } + ad.setVBOWritten(true); + } + } else { + gl.glBindBuffer(ad.getVBOTarget(), 0); + } + } +} + diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java new file mode 100644 index 000000000..e365f0f4b --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java @@ -0,0 +1,99 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util; + +import javax.media.opengl.*; +import javax.media.opengl.fixedfunc.*; + +import com.jogamp.opengl.util.GLArrayDataEditable; +import com.jogamp.opengl.util.GLArrayHandler; + +import java.nio.*; + +/** + * Used for 1:1 fixed function arrays, i.e. where the buffer data + * represents this array only. + */ +public class GLFixedArrayHandler implements GLArrayHandler { + private GLArrayDataEditable ad; + + public GLFixedArrayHandler(GLArrayDataEditable ad) { + this.ad = ad; + } + + public final void addSubHandler(GLArrayHandler handler) { + throw new UnsupportedOperationException(); + } + + private final void passArrayPointer(GLPointerFunc gl) { + switch(ad.getIndex()) { + case GLPointerFunc.GL_VERTEX_ARRAY: + gl.glVertexPointer(ad); + break; + case GLPointerFunc.GL_NORMAL_ARRAY: + gl.glNormalPointer(ad); + break; + case GLPointerFunc.GL_COLOR_ARRAY: + gl.glColorPointer(ad); + break; + case GLPointerFunc.GL_TEXTURE_COORD_ARRAY: + gl.glTexCoordPointer(ad); + break; + default: + throw new GLException("invalid glArrayIndex: "+ad.getIndex()+":\n\t"+ad); + } + } + + public final void enableBuffer(GL gl, boolean enable) { + GLPointerFunc glp = gl.getGL2ES1(); + if(enable) { + Buffer buffer = ad.getBuffer(); + + if(ad.isVBO()) { + // always bind and refresh the VBO mgr, + // in case more than one gl*Pointer objects are in use + gl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName()); + if(!ad.isVBOWritten()) { + if(null!=buffer) { + gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSizeInBytes(), buffer, ad.getVBOUsage()); + } + ad.setVBOWritten(true); + } + } + passArrayPointer(glp); + glp.glEnableClientState(ad.getIndex()); + } else { + glp.glDisableClientState(ad.getIndex()); + if(ad.isVBO()) { + gl.glBindBuffer(ad.getVBOTarget(), 0); + } + } + } +} + diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java new file mode 100644 index 000000000..e1cf5d572 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java @@ -0,0 +1,82 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util; + +import javax.media.opengl.GL; +import javax.media.opengl.GLArrayData; +import javax.media.opengl.GLException; +import javax.media.opengl.fixedfunc.GLPointerFunc; + +import com.jogamp.opengl.util.GLArrayHandler; + +/** + * Used for interleaved fixed function arrays, i.e. where the buffer data itself is handled + * separately and interleaves many arrays. + */ +public class GLFixedArrayHandlerFlat implements GLArrayHandler { + private GLArrayData ad; + + public GLFixedArrayHandlerFlat(GLArrayData ad) { + this.ad = ad; + } + + public final void addSubHandler(GLArrayHandler handler) { + throw new UnsupportedOperationException(); + } + + private final void passArrayPointer(GLPointerFunc gl) { + switch(ad.getIndex()) { + case GLPointerFunc.GL_VERTEX_ARRAY: + gl.glVertexPointer(ad); + break; + case GLPointerFunc.GL_NORMAL_ARRAY: + gl.glNormalPointer(ad); + break; + case GLPointerFunc.GL_COLOR_ARRAY: + gl.glColorPointer(ad); + break; + case GLPointerFunc.GL_TEXTURE_COORD_ARRAY: + gl.glTexCoordPointer(ad); + break; + default: + throw new GLException("invalid glArrayIndex: "+ad.getIndex()+":\n\t"+ad); + } + } + + public final void enableBuffer(GL gl, boolean enable) { + GLPointerFunc glp = gl.getGL2ES1(); + if(enable) { + passArrayPointer(glp); + glp.glEnableClientState(ad.getIndex()); + } else { + glp.glDisableClientState(ad.getIndex()); + } + } +} + diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java new file mode 100644 index 000000000..838032646 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java @@ -0,0 +1,87 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util; + +import javax.media.opengl.*; +import javax.media.opengl.fixedfunc.*; + +import com.jogamp.opengl.util.GLArrayDataEditable; +import com.jogamp.opengl.util.GLArrayHandler; + +import java.nio.*; +import java.util.ArrayList; +import java.util.List; + +/** + * Interleaved fixed function arrays, i.e. where this buffer data + * represents many arrays. + */ +public class GLFixedArrayHandlerInterleaved implements GLArrayHandler { + private GLArrayDataEditable ad; + private List subArrays = new ArrayList(); + + public GLFixedArrayHandlerInterleaved(GLArrayDataEditable ad) { + this.ad = ad; + } + + public final void addSubHandler(GLArrayHandler handler) { + subArrays.add(handler); + } + + private final void enableSubBuffer(GL gl, boolean enable) { + for(int i=0; i= 0) { + // didn't experience a performance hit on this query .. + final int[] qi = new int[1]; + glsl.glGetVertexAttribiv(ad.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0); + if(ad.getVBOName() != qi[0]) { + glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName()); + st.vertexAttribPointer(glsl, ad); + } + } + } else if(null!=buffer) { + st.vertexAttribPointer(glsl, ad); + } + st.enableVertexAttribArray(glsl, ad); + } else { + st.disableVertexAttribArray(glsl, ad); + if(ad.isVBO()) { + glsl.glBindBuffer(ad.getVBOTarget(), 0); + } + } + } + +} + diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java new file mode 100644 index 000000000..38379877f --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java @@ -0,0 +1,66 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util.glsl; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLArrayData; +import com.jogamp.opengl.util.GLArrayHandler; +import com.jogamp.opengl.util.glsl.ShaderState; + +/** + * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled + * separately and interleaves many arrays. + */ +public class GLSLArrayHandlerFlat implements GLArrayHandler { + private ShaderState st; + private GLArrayData ad; + + public GLSLArrayHandlerFlat(ShaderState st, GLArrayData ad) { + this.st = st; + this.ad = ad; + } + + public final void addSubHandler(GLArrayHandler handler) { + throw new UnsupportedOperationException(); + } + + public final void enableBuffer(GL gl, boolean enable) { + GL2ES2 glsl = gl.getGL2ES2(); + + if(enable) { + st.vertexAttribPointer(glsl, ad); + st.enableVertexAttribArray(glsl, ad); + } else { + st.disableVertexAttribArray(glsl, ad); + } + } + +} + diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java new file mode 100644 index 000000000..ba5814a09 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java @@ -0,0 +1,96 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util.glsl; + +import java.nio.Buffer; +import java.util.ArrayList; +import java.util.List; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLException; + +import jogamp.opengl.util.GLFixedArrayHandlerFlat; + +import com.jogamp.opengl.util.GLArrayDataEditable; +import com.jogamp.opengl.util.GLArrayHandler; +import com.jogamp.opengl.util.glsl.ShaderState; + +/** + * Interleaved GLSL arrays, i.e. where this buffer data + * represents many arrays. + */ +public class GLSLArrayHandlerInterleaved implements GLArrayHandler { + private GLArrayDataEditable ad; + private ShaderState st; + private List subArrays = new ArrayList(); + + public GLSLArrayHandlerInterleaved(ShaderState st, GLArrayDataEditable ad) { + this.st = st; + this.ad = ad; + } + + public final void addSubHandler(GLArrayHandler handler) { + subArrays.add(handler); + } + + private final void enableSubBuffer(GL gl, boolean enable) { + for(int i=0; i