From 7f2da7bb878813817efab0eb01bbf274065ef6c6 Mon Sep 17 00:00:00 2001 From: Sven Gothel <sgothel@jausoft.com> Date: Tue, 30 Aug 2011 03:41:38 +0200 Subject: GLSL DataArray/Handler: Remove ShaderState state and pass it through: ShaderState.getShaderState(gl) This removes the dependency of a GLSL GLDataArray object to a specific ShaderState and enables sharing of this VBO data, i.e. via a shared context. Test: TestSharedContextVBOES2NEWT --- .../classes/com/jogamp/graph/curve/opengl/RenderState.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/curve') diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index e0d2490dc..eb07142a3 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -39,6 +39,7 @@ import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderState; public abstract class RenderState { + private static final String thisKey = "jogamp.graph.curve.RenderState" ; public static RenderState createRenderState(ShaderState st, Vertex.Factory<? extends Vertex> pointFactory) { return new RenderStateImpl(st, pointFactory); @@ -48,6 +49,10 @@ public abstract class RenderState { return new RenderStateImpl(st, pointFactory, pmvMatrix); } + public static final RenderState getRenderState(GL2ES2 gl) { + return (RenderState) gl.getContext().getAttachedObject(thisKey); + } + protected final ShaderState st; protected final Vertex.Factory<? extends Vertex> vertexFactory; protected final PMVMatrix pmvMatrix; @@ -76,13 +81,13 @@ public abstract class RenderState { // public abstract GLUniformData getStrength(); public final RenderState attachTo(GL2ES2 gl) { - return (RenderState) gl.getContext().attachObject(RenderState.class.getName(), this); + return (RenderState) gl.getContext().attachObject(thisKey, this); } public final boolean detachFrom(GL2ES2 gl) { - RenderState _rs = (RenderState) gl.getContext().getAttachedObject(RenderState.class.getName()); + RenderState _rs = (RenderState) gl.getContext().getAttachedObject(thisKey); if(_rs == this) { - gl.getContext().detachObject(RenderState.class.getName()); + gl.getContext().detachObject(thisKey); return true; } return false; -- cgit v1.2.3