From 360b86f4b5d0e440863c1749fe990e39fbabc51c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 26 Apr 2011 07:53:27 +0200 Subject: ShaderState: Add 'ownUniform()/ownAttribute()'; rename glFunction -> function; switch program enh. ; Graph lifecycle Add 'ownUniform()/ownAttribute()' allowing to reset all bound uniforms/attributes, not just active ones plus handling the lifecycle of the owned attributes (destroy). This simplifies the lifecycle of all shader attributes. Rename glFunction -> function .. well, the GL attribute marks them GL related already Switch program enhancement. If switching to new program (unlinked), issue glBindAttributeLocation .. Graph lifecycle cleanup using the above .. --- .../classes/jogamp/graph/curve/opengl/VBORegionSPES2.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java') diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 1b295de16..7956e5137 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -62,15 +62,15 @@ public class VBORegionSPES2 implements Region { final int initialSize = 256; final ShaderState st = rs.getShaderState(); - indices = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialSize, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indices = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialSize, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); verticeAttr = GLArrayDataServer.createGLSL(st, AttributeNames.VERTEX_ATTR_NAME, 3, - GL2ES2.GL_FLOAT, false, initialSize, GL.GL_STATIC_DRAW); - st.bindAttribute(verticeAttr); + GL2ES2.GL_FLOAT, false, initialSize, GL.GL_STATIC_DRAW); + st.ownAttribute(verticeAttr, true); texCoordAttr = GLArrayDataServer.createGLSL(st, AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false, initialSize, GL.GL_STATIC_DRAW); - st.bindAttribute(texCoordAttr); + st.ownAttribute(texCoordAttr, true); if(DEBUG_INSTANCE) { System.err.println("VBORegionSPES2 Create: " + this); @@ -187,15 +187,18 @@ public class VBORegionSPES2 implements Region { return dirty; } - public final void destroy(GL2ES2 gl) { + public final void destroy(GL2ES2 gl, RenderState rs) { if(DEBUG_INSTANCE) { System.err.println("VBORegionSPES2 Destroy: " + this); } + final ShaderState st = rs.getShaderState(); if(null != verticeAttr) { + st.ownAttribute(verticeAttr, false); verticeAttr.destroy(gl); verticeAttr = null; } if(null != texCoordAttr) { + st.ownAttribute(texCoordAttr, false); texCoordAttr.destroy(gl); texCoordAttr = null; } -- cgit v1.2.3