diff options
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve')
6 files changed, 64 insertions, 57 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 4dcc4560e..0b47606e4 100755 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -62,13 +62,13 @@ public class RegionRendererImpl01 extends RegionRenderer { sp.init(gl);
st.attachShaderProgram(gl, sp);
- st.glBindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME);
- st.glBindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME);
+ st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME);
+ st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME);
if(!sp.link(gl, System.err)) {
throw new GLException("RegionRenderer: Couldn't link program: "+sp);
}
- st.glUseProgram(gl, true);
+ st.useProgram(gl, true);
if(DEBUG) {
System.err.println("RegionRendererImpl01 initialized: " + Thread.currentThread()+" "+st);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java index 4c4a325ae..eef64dab5 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java @@ -29,15 +29,13 @@ package jogamp.graph.curve.opengl; import java.nio.FloatBuffer; -import javax.media.opengl.GL; -import javax.media.opengl.GLProfile; +import javax.media.opengl.GL2ES2; import javax.media.opengl.GLUniformData; import javax.media.opengl.fixedfunc.GLMatrixFunc; import jogamp.graph.curve.opengl.shader.UniformNames; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.VersionUtil; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.geom.Vertex; import com.jogamp.opengl.util.PMVMatrix; @@ -45,22 +43,22 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class RenderStateImpl implements RenderState { - public final ShaderState st; - public final Vertex.Factory<? extends Vertex> pointFactory; - public final PMVMatrix pmvMatrix; - public final GLUniformData mgl_PMVMatrix; + private final ShaderState st; + private final Vertex.Factory<? extends Vertex> pointFactory; + private final PMVMatrix pmvMatrix; + private final GLUniformData gcu_PMVMatrix; /** * Sharpness is equivalent to the texture-coord component <i>t</i> * on the off-curve vertex. Higher values of sharpness will * result in higher curvature. */ - public final GLUniformData mgl_sharpness; - public final GLUniformData mgl_alpha; - public final GLUniformData mgl_colorStatic; - public final GLUniformData mgl_strength; + private final GLUniformData gcu_Sharpness; + private final GLUniformData gcu_Alpha; + private final GLUniformData gcu_ColorStatic; + private final GLUniformData gcu_Strength; - public static final RenderState getRenderState(GL gl) { + public static final RenderState getRenderState(GL2ES2 gl) { return (RenderState) gl.getContext().getAttachedObject(RenderState.class.getName()); } @@ -68,12 +66,17 @@ public class RenderStateImpl implements RenderState { this.st = st; this.pointFactory = pointFactory; this.pmvMatrix = pmvMatrix; - this.mgl_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMatrixf()); + this.gcu_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(gcu_PMVMatrix); - mgl_sharpness = new GLUniformData(UniformNames.gcu_P1Y, 0.5f); - mgl_alpha = new GLUniformData(UniformNames.gcu_Alpha, 1.0f); - mgl_colorStatic = new GLUniformData(UniformNames.gcu_ColorStatic, 3, FloatBuffer.allocate(3)); - mgl_strength = new GLUniformData(UniformNames.gcu_Strength, 3.0f); + gcu_Sharpness = new GLUniformData(UniformNames.gcu_P1Y, 0.5f); + st.ownUniform(gcu_PMVMatrix); + gcu_Alpha = new GLUniformData(UniformNames.gcu_Alpha, 1.0f); + st.ownUniform(gcu_Alpha); + gcu_ColorStatic = new GLUniformData(UniformNames.gcu_ColorStatic, 3, FloatBuffer.allocate(3)); + st.ownUniform(gcu_ColorStatic); + gcu_Strength = new GLUniformData(UniformNames.gcu_Strength, 3.0f); + st.ownUniform(gcu_Strength); } public RenderStateImpl(ShaderState st, Vertex.Factory<? extends Vertex> pointFactory) { @@ -89,17 +92,21 @@ public class RenderStateImpl implements RenderState { public final ShaderState getShaderState() { return st; } public final Vertex.Factory<? extends Vertex> getPointFactory () { return pointFactory; } - public final PMVMatrix getPMVMatrix() { return pmvMatrix; } - public final GLUniformData getPMVMatrixUniform() { return mgl_PMVMatrix; } - public final GLUniformData getSharpness() { return mgl_sharpness; } - public final GLUniformData getAlpha() { return mgl_alpha; } - public final GLUniformData getColorStatic() { return mgl_colorStatic; } - public final GLUniformData getStrength() { return mgl_strength; } + public final PMVMatrix pmvMatrix() { return pmvMatrix; } + public final GLUniformData getPMVMatrix() { return gcu_PMVMatrix; } + public final GLUniformData getSharpness() { return gcu_Sharpness; } + public final GLUniformData getAlpha() { return gcu_Alpha; } + public final GLUniformData getColorStatic() { return gcu_ColorStatic; } + public final GLUniformData getStrength() { return gcu_Strength; } - public final RenderState attachTo(GL gl) { + public void destroy(GL2ES2 gl) { + st.destroy(gl); + } + + public final RenderState attachTo(GL2ES2 gl) { return (RenderState) gl.getContext().attachObject(RenderState.class.getName(), this); } - public final boolean detachFrom(GL gl) { + public final boolean detachFrom(GL2ES2 gl) { RenderState _rs = (RenderState) gl.getContext().getAttachedObject(RenderState.class.getName()); if(_rs == this) { gl.getContext().detachObject(RenderState.class.getName()); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 3bddaed3b..2255251a7 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -64,13 +64,13 @@ public class TextRendererImpl01 extends TextRenderer { sp.init(gl); st.attachShaderProgram(gl, sp); - st.glBindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME); - st.glBindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); + st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME); + st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); if(!sp.link(gl, System.err)) { throw new GLException("TextRendererImpl01: Couldn't link program: "+sp); } - st.glUseProgram(gl, true); + st.useProgram(gl, true); if(DEBUG) { System.err.println("TextRendererImpl01 initialized: " + Thread.currentThread()+" "+st); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java index 181ce77b0..90b3d47cd 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java @@ -93,7 +93,7 @@ public class VBORegion2PES2 implements Region { texCoordFboAttr = GLArrayDataServer.createGLSL(st, AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false, initialSize, GL.GL_STATIC_DRAW); - st.bindAttribute(texCoordFboAttr); + st.ownAttribute(texCoordFboAttr, true); texCoordFboAttr.putf(5); texCoordFboAttr.putf(5); texCoordFboAttr.putf(5); texCoordFboAttr.putf(6); texCoordFboAttr.putf(6); texCoordFboAttr.putf(6); @@ -102,7 +102,7 @@ public class VBORegion2PES2 implements Region { verticeFboAttr = GLArrayDataServer.createGLSL(st, AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false, initialSize, GL.GL_STATIC_DRAW); - st.bindAttribute(verticeFboAttr); + st.ownAttribute(verticeFboAttr, true); box = new AABBox(); @@ -111,11 +111,11 @@ public class VBORegion2PES2 implements Region { verticeTxtAttr = GLArrayDataServer.createGLSL(st, AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false, initialSize, GL.GL_STATIC_DRAW); - st.bindAttribute(verticeTxtAttr); + st.ownAttribute(verticeTxtAttr, true); texCoordTxtAttr = GLArrayDataServer.createGLSL(st, AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false, initialSize, GL.GL_STATIC_DRAW); - st.bindAttribute(texCoordTxtAttr); + st.ownAttribute(texCoordTxtAttr, true); if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Create: " + this); @@ -232,7 +232,7 @@ public class VBORegion2PES2 implements Region { gl.glGetIntegerv(GL.GL_ACTIVE_TEXTURE, currentActiveTextureEngine, 0); */ gl.glActiveTexture(activeTexture); - st.glUniform(gl, mgl_ActiveTexture); + st.uniform(gl, mgl_ActiveTexture); fbo.use(gl); verticeFboAttr.enableBuffer(gl, true); @@ -275,14 +275,14 @@ public class VBORegion2PES2 implements Region { //render texture gl.glViewport(0, 0, tex_width_c, tex_height_c); - st.glUniform(gl, mgl_fboPMVMatrix); // use orthogonal matrix + st.uniform(gl, mgl_fboPMVMatrix); // use orthogonal matrix gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT); renderRegion(gl); fbo.unbind(gl); - st.glUniform(gl, rs.getPMVMatrixUniform()); // switch back to real PMV matrix + st.uniform(gl, rs.getPMVMatrix()); // switch back to real PMV matrix } private void renderRegion(GL2ES2 gl) { @@ -316,28 +316,22 @@ public class VBORegion2PES2 implements Region { return dirty; } - public void destroy(GL2ES2 gl) { + public void destroy(GL2ES2 gl, RenderState rs) { if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Destroy: " + this); } - destroyFbo(gl); - destroyTxtAttr(gl); - destroyFboAttr(gl); - triangles.clear(); - vertices.clear(); - } - final void destroyFbo(GL2ES2 gl) { + final ShaderState st = rs.getShaderState(); if(null != fbo) { fbo.destroy(gl); fbo = null; } - } - final void destroyTxtAttr(GL2ES2 gl) { if(null != verticeTxtAttr) { + st.ownAttribute(verticeTxtAttr, false); verticeTxtAttr.destroy(gl); verticeTxtAttr = null; } if(null != texCoordTxtAttr) { + st.ownAttribute(texCoordTxtAttr, false); texCoordTxtAttr.destroy(gl); texCoordTxtAttr = null; } @@ -345,13 +339,13 @@ public class VBORegion2PES2 implements Region { indicesTxt.destroy(gl); indicesTxt = null; } - } - final void destroyFboAttr(GL2ES2 gl) { if(null != verticeFboAttr) { + st.ownAttribute(verticeFboAttr, false); verticeFboAttr.destroy(gl); verticeFboAttr = null; } if(null != texCoordFboAttr) { + st.ownAttribute(texCoordFboAttr, false); texCoordFboAttr.destroy(gl); texCoordFboAttr = null; } @@ -359,6 +353,8 @@ public class VBORegion2PES2 implements Region { indicesFbo.destroy(gl); indicesFbo = null; } + triangles.clear(); + vertices.clear(); } public boolean isFlipped() { 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; } diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java index 8f7dcf30a..1faee87ff 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java @@ -155,9 +155,10 @@ public class GlyphString { } /** Destroy the associated OGL objects + * @param rs TODO */ - public void destroy(GL2ES2 gl){ - region.destroy(gl); + public void destroy(GL2ES2 gl, RenderState rs){ + region.destroy(gl, rs); } public AABBox getBounds(){ |