diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/glsl')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java | 11 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java | 23 |
2 files changed, 10 insertions, 24 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java index d7327a4e8..79bed90c9 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java @@ -35,6 +35,7 @@ import javax.media.opengl.GL2ES2; import jogamp.opengl.util.GLArrayHandler; import jogamp.opengl.util.GLArrayHandlerFlat; +import jogamp.opengl.util.GLVBOArrayHandler; import com.jogamp.opengl.util.GLArrayDataEditable; import com.jogamp.opengl.util.glsl.ShaderState; @@ -43,11 +44,10 @@ 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 implements GLArrayHandler { - private GLArrayDataEditable ad; - +public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandler { + public GLSLArrayHandler(GLArrayDataEditable ad) { - this.ad = ad; + super(ad); } public final void setSubArrayVBOName(int vboName) { @@ -63,7 +63,6 @@ public class GLSLArrayHandler implements GLArrayHandler { final ShaderState st = (ShaderState) ext; if(enable) { - final Buffer buffer = ad.getBuffer(); /* * This would be the non optimized code path: * @@ -78,6 +77,7 @@ public class GLSLArrayHandler implements GLArrayHandler { } st.vertexAttribPointer(glsl, ad); */ + final Buffer buffer = ad.getBuffer(); if(ad.isVBO()) { // bind and refresh the VBO / vertex-attr only if necessary if(!ad.isVBOWritten()) { @@ -108,6 +108,5 @@ public class GLSLArrayHandler implements GLArrayHandler { 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 index 6c80e31fa..f36693e19 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java @@ -28,7 +28,6 @@ package jogamp.opengl.util.glsl; -import java.nio.Buffer; import java.util.ArrayList; import java.util.List; @@ -36,6 +35,7 @@ import javax.media.opengl.GL; import jogamp.opengl.util.GLArrayHandler; import jogamp.opengl.util.GLArrayHandlerFlat; +import jogamp.opengl.util.GLVBOArrayHandler; import com.jogamp.opengl.util.GLArrayDataEditable; @@ -43,12 +43,11 @@ import com.jogamp.opengl.util.GLArrayDataEditable; * Interleaved fixed function arrays, i.e. where this buffer data * represents many arrays. */ -public class GLSLArrayHandlerInterleaved implements GLArrayHandler { - private GLArrayDataEditable ad; +public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLArrayHandler { private List<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>(); public GLSLArrayHandlerInterleaved(GLArrayDataEditable ad) { - this.ad = ad; + super(ad); } public final void setSubArrayVBOName(int vboName) { @@ -72,22 +71,10 @@ public class GLSLArrayHandlerInterleaved implements GLArrayHandler { if(!ad.isVBO()) { throw new InternalError("Interleaved handle is not VBO: "+ad); } - - final Buffer buffer = ad.getBuffer(); - final boolean vboWritten = ad.isVBOWritten(); - - // 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(!vboWritten) { - if(null!=buffer) { - gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSizeInBytes(), buffer, ad.getVBOUsage()); - } - ad.setVBOWritten(true); - } + bindBuffer(gl, true); // sub data will decide weather to update the vertex attrib pointer syncSubData(gl, ext); - gl.glBindBuffer(ad.getVBOTarget(), 0); + bindBuffer(gl, false); } for(int i=0; i<subArrays.size(); i++) { subArrays.get(i).enableState(gl, enable, ext); |