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 .. --- .../util/glsl/fixedfunc/FixedFuncPipeline.java | 122 ++++++++++----------- 1 file changed, 61 insertions(+), 61 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/util') diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index b77cf4617..fadce2b4d 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -83,9 +83,9 @@ public class FixedFuncPipeline { } public void glEnableClientState(GL2ES2 gl, int glArrayIndex) { - shaderState.glUseProgram(gl, true); + shaderState.useProgram(gl, true); - shaderState.glEnableVertexAttribArray(gl, getArrayIndexName(glArrayIndex)); + shaderState.enableVertexAttribArray(gl, getArrayIndexName(glArrayIndex)); // textureCoordsEnabled |= (1 << activeTextureUnit); if ( textureCoordsEnabled.get(activeTextureUnit) != 1 ) { textureCoordsEnabled.put(activeTextureUnit, 1); @@ -94,9 +94,9 @@ public class FixedFuncPipeline { } public void glDisableClientState(GL2ES2 gl, int glArrayIndex) { - shaderState.glUseProgram(gl, true); + shaderState.useProgram(gl, true); - shaderState.glDisableVertexAttribArray(gl, getArrayIndexName(glArrayIndex)); + shaderState.disableVertexAttribArray(gl, getArrayIndexName(glArrayIndex)); // textureCoordsEnabled &= ~(1 << activeTextureUnit); if ( textureCoordsEnabled.get(activeTextureUnit) != 0 ) { textureCoordsEnabled.put(activeTextureUnit, 0); @@ -105,37 +105,37 @@ public class FixedFuncPipeline { } public void glVertexPointer(GL2ES2 gl, GLArrayData data) { - shaderState.glUseProgram(gl, true); - shaderState.glVertexAttribPointer(gl, data); + shaderState.useProgram(gl, true); + shaderState.vertexAttribPointer(gl, data); } public void glColorPointer(GL2ES2 gl, GLArrayData data) { - shaderState.glUseProgram(gl, true); - shaderState.glVertexAttribPointer(gl, data); + shaderState.useProgram(gl, true); + shaderState.vertexAttribPointer(gl, data); } public void glColor4fv(GL2ES2 gl, FloatBuffer data ) { - shaderState.glUseProgram(gl, true); + shaderState.useProgram(gl, true); GLUniformData ud = shaderState.getUniform(mgl_ColorStatic); if(null!=ud) { ud.setData(data); - shaderState.glUniform(gl, ud); + shaderState.uniform(gl, ud); } } public void glNormalPointer(GL2ES2 gl, GLArrayData data) { - shaderState.glUseProgram(gl, true); - shaderState.glVertexAttribPointer(gl, data); + shaderState.useProgram(gl, true); + shaderState.vertexAttribPointer(gl, data); } public void glTexCoordPointer(GL2ES2 gl, GLArrayData data) { - shaderState.glUseProgram(gl, true); + shaderState.useProgram(gl, true); data.setName( getArrayIndexName(data.getIndex()) ); - shaderState.glVertexAttribPointer(gl, data); + shaderState.vertexAttribPointer(gl, data); } public void glLightfv(GL2ES2 gl, int light, int pname, java.nio.FloatBuffer params) { - shaderState.glUseProgram(gl, true); + shaderState.useProgram(gl, true); light -=GLLightingFunc.GL_LIGHT0; if(0 <= light && light < MAX_LIGHTS) { GLUniformData ud = null; @@ -178,7 +178,7 @@ public class FixedFuncPipeline { } if(null!=ud) { ud.setData(params); - shaderState.glUniform(gl, ud); + shaderState.uniform(gl, ud); } } else if(verbose) { System.err.println("glLightfv light not within [0.."+MAX_LIGHTS+"]: "+light); @@ -186,7 +186,7 @@ public class FixedFuncPipeline { } public void glMaterialfv(GL2ES2 gl, int face, int pname, java.nio.FloatBuffer params) { - shaderState.glUseProgram(gl, true); + shaderState.useProgram(gl, true); switch (face) { case GL.GL_FRONT: @@ -228,33 +228,33 @@ public class FixedFuncPipeline { } if(null!=ud) { ud.setData(params); - shaderState.glUniform(gl, ud); + shaderState.uniform(gl, ud); } } public void glShadeModel(GL2ES2 gl, int mode) { - shaderState.glUseProgram(gl, true); + shaderState.useProgram(gl, true); GLUniformData ud = shaderState.getUniform(mgl_ShadeModel); if(null!=ud) { ud.setData(mode); - shaderState.glUniform(gl, ud); + shaderState.uniform(gl, ud); } } public void glActiveTexture(GL2ES2 gl, int textureUnit) { textureUnit -= GL.GL_TEXTURE0; if(0 <= textureUnit && textureUnit