From 8297ef88b927e07b41760ab3e9de05bc49fd4695 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 5 Apr 2011 01:44:07 +0200 Subject: Fix: shaderProgram.program(); glBindAttribLocation() call; dispose/disposeImpl sequence; Use shaderProgram.program() instead of shaderProgram.id() - the id() is just a unique sequence name. Call glBindAttribLocation() after program object init and before linkage. Chain call disposeImpl() properly to fix destruction sequence: TextRendererImpl01 -> TextRenderer -> GlyphString -> Region RegionRendererImpl01 -> RegionRenderer -> Region --- .../jogamp/graph/curve/opengl/RegionRendererImpl01.java | 12 +++++++----- .../jogamp/graph/curve/opengl/TextRendererImpl01.java | 10 +++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/jogl/classes/jogamp') diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index c1f293fff..9208afc24 100755 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -83,15 +83,17 @@ public class RegionRendererImpl01 extends RegionRenderer { ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); - + + sp.init(gl); + gl.glBindAttribLocation(sp.program(), Region.VERTEX_ATTR_IDX, "v_position"); + gl.glBindAttribLocation(sp.program(), Region.TEXCOORD_ATTR_IDX, "texCoord"); + if(!sp.link(gl, System.err)) { throw new GLException("RegionRenderer: Couldn't link program: "+sp); } st = new ShaderState(); st.attachShaderProgram(gl, sp); - gl.glBindAttribLocation(sp.id(), 0, "v_position"); - gl.glBindAttribLocation(sp.id(), 1, "texCoord"); st.glUseProgram(gl, true); @@ -145,9 +147,9 @@ public class RegionRendererImpl01 extends RegionRenderer { @Override protected void disposeImpl(GL2ES2 gl) { + super.disposeImpl(gl); } - - + @Override public float getAlpha() { return mgl_alpha.floatValue(); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 0f0b91412..01572de58 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -36,6 +36,7 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc; import jogamp.graph.curve.text.GlyphString; +import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.TextRenderer; import com.jogamp.graph.font.Font; import com.jogamp.graph.geom.Vertex; @@ -84,14 +85,16 @@ public class TextRendererImpl01 extends TextRenderer { ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); - + + sp.init(gl); + gl.glBindAttribLocation(sp.program(), Region.VERTEX_ATTR_IDX, "v_position"); + gl.glBindAttribLocation(sp.program(), Region.TEXCOORD_ATTR_IDX, "texCoord"); + if(!sp.link(gl, System.err)) { throw new GLException("TextRendererImpl01: Couldn't link program: "+sp); } st.attachShaderProgram(gl, sp); - gl.glBindAttribLocation(sp.id(), 0, "v_position"); - gl.glBindAttribLocation(sp.id(), 1, "texCoord"); st.glUseProgram(gl, true); @@ -145,6 +148,7 @@ public class TextRendererImpl01 extends TextRenderer { @Override protected void disposeImpl(GL2ES2 gl) { + super.disposeImpl(gl); } @Override -- cgit v1.2.3