aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-05 01:44:07 +0200
committerSven Gothel <[email protected]>2011-04-05 01:44:07 +0200
commit8297ef88b927e07b41760ab3e9de05bc49fd4695 (patch)
treefa04678a48b061c6a5355623fbba4012ff5a1be5 /src
parent2f2879256fe999c5019bd800f564e9cb2a83a0b6 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java5
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java5
-rwxr-xr-xsrc/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java12
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java10
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java13
5 files changed, 32 insertions, 13 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index c1fec10b8..c6e03cad6 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -54,6 +54,11 @@ public abstract class RegionRenderer extends Renderer {
regions.clear();
}
+ @Override
+ protected void disposeImpl(GL2ES2 gl) {
+ flushCache();
+ }
+
/** Create an ogl {@link Region} defining this {@link OutlineShape}
* @param sharpness parameter for Region generation
* @return the resulting Region.
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
index 79ae8c11e..45f78fc23 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
@@ -72,6 +72,11 @@ public abstract class TextRenderer extends Renderer {
stringCacheArray.clear();
}
+ @Override
+ protected void disposeImpl(GL2ES2 gl) {
+ flushCache();
+ }
+
public final void setCacheMaxSize(int newSize ) { stringCacheMaxSize = newSize; validateCache(0); }
public final int getCacheMaxSize() { return stringCacheMaxSize; }
public final int getCacheSize() { return stringCacheArray.size(); }
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
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
index cdf54796b..92b9323e2 100755
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
@@ -25,6 +25,8 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestTextRendererNEWT01 extends UITestCase {
+ static final boolean DEBUG = false;
+ static final boolean TRACE = false;
public static void main(String args[]) throws IOException {
String tstname = TestTextRendererNEWT01.class.getName();
@@ -64,7 +66,7 @@ public class TestTextRendererNEWT01 extends UITestCase {
caps.setAlphaBits(4);
GLWindow window = createWindow("text-r2t1-msaa0", caps, 800,400);
- TextGLListener textGLListener = new TextGLListener(Region.TWO_PASS);
+ TextGLListener textGLListener = new TextGLListener(Region.TWO_PASS, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
@@ -100,7 +102,7 @@ public class TestTextRendererNEWT01 extends UITestCase {
caps.setNumSamples(4);
GLWindow window = createWindow("text-r2t0-msaa1", caps, 800, 400);
- TextGLListener textGLListener = new TextGLListener(Region.SINGLE_PASS);
+ TextGLListener textGLListener = new TextGLListener(Region.SINGLE_PASS, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
@@ -130,8 +132,8 @@ public class TestTextRendererNEWT01 extends UITestCase {
private class TextGLListener extends GPUTextRendererListenerBase01 {
String winTitle;
- public TextGLListener(int type) {
- super(SVertex.factory(), type, false, false);
+ public TextGLListener(int type, boolean debug, boolean trace) {
+ super(SVertex.factory(), type, debug, trace);
}
public void attachInputListenerTo(GLWindow window) {
@@ -143,8 +145,9 @@ public class TestTextRendererNEWT01 extends UITestCase {
}
public void init(GLAutoDrawable drawable) {
+ super.init(drawable);
+
GL2ES2 gl = drawable.getGL().getGL2ES2();
- super.init(drawable);
gl.setSwapInterval(1);
gl.glEnable(GL.GL_DEPTH_TEST);