summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-30 03:41:38 +0200
committerSven Gothel <[email protected]>2011-08-30 03:41:38 +0200
commit7f2da7bb878813817efab0eb01bbf274065ef6c6 (patch)
tree6c4df36439747e239c84f88e676c4a6145738c54 /src/jogl/classes/com/jogamp/opengl/util
parentb8b25bb01b826e1216551c8f3d192bcec670e265 (diff)
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
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java39
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java95
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java40
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java5
5 files changed, 82 insertions, 104 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
index 3600081bc..ee9a21095 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
@@ -11,6 +11,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLException;
import javax.media.opengl.fixedfunc.GLPointerFuncUtil;
+import jogamp.opengl.util.GLArrayHandler;
import jogamp.opengl.util.GLFixedArrayHandler;
import jogamp.opengl.util.glsl.GLSLArrayHandler;
@@ -45,7 +46,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
{
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
- adc.init(null, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler, 0, 0, 0, 0);
+ adc.init(null, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler, 0, 0, 0, 0, false);
return adc;
}
@@ -76,36 +77,32 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
{
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
- adc.init(null, index, comps, dataType, normalized, stride, buffer, comps*comps, false, glArrayHandler, 0, 0, 0, 0);
+ adc.init(null, index, comps, dataType, normalized, stride, buffer, comps*comps, false, glArrayHandler, 0, 0, 0, 0, false);
return adc;
}
/**
* Create a client side buffer object, using a custom GLSL array attribute name
* and starting with a new created Buffer object with initialSize size
- *
- * @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
* @param name The custom name for the GL attribute.
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
* @param initialSize
*/
- public static GLArrayDataClient createGLSL(ShaderState st, String name,
- int comps, int dataType, boolean normalized, int initialSize)
+ public static GLArrayDataClient createGLSL(String name, int comps,
+ int dataType, boolean normalized, int initialSize)
throws GLException
{
GLArrayDataClient adc = new GLArrayDataClient();
- GLArrayHandler glArrayHandler = new GLSLArrayHandler(st, adc);
- adc.init(name, -1, comps, dataType, normalized, 0, null, initialSize, true, glArrayHandler, 0, 0, 0, 0);
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
+ adc.init(name, -1, comps, dataType, normalized, 0, null, initialSize, true, glArrayHandler, 0, 0, 0, 0, true);
return adc;
}
/**
* Create a client side buffer object, using a custom GLSL array attribute name
* and starting with a given Buffer object incl it's stride
- *
- * @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
* @param name The custom name for the GL attribute.
* @param comps The array component number
* @param dataType The array index GL data type
@@ -113,14 +110,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
* @param stride
* @param buffer the user define data
*/
- public static GLArrayDataClient createGLSL(ShaderState st, String name,
- int comps, int dataType, boolean normalized, int stride,
- Buffer buffer)
+ public static GLArrayDataClient createGLSL(String name, int comps,
+ int dataType, boolean normalized, int stride, Buffer buffer)
throws GLException
{
GLArrayDataClient adc = new GLArrayDataClient();
- GLArrayHandler glArrayHandler = new GLSLArrayHandler(st, adc);
- adc.init(name, -1, comps, dataType, normalized, stride, buffer, comps*comps, true, glArrayHandler, 0, 0, 0, 0);
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
+ adc.init(name, -1, comps, dataType, normalized, stride, buffer, comps*comps, true, glArrayHandler, 0, 0, 0, 0, true);
return adc;
}
@@ -162,12 +158,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
// init/generate VBO name if not done yet
init_vbo(gl);
}
+ final Object ext = usesGLSL ? ShaderState.getShaderState(gl) : null ;
if(enable) {
- glArrayHandler.syncData(gl, true);
- glArrayHandler.enableState(gl, true);
+ glArrayHandler.syncData(gl, true, ext);
+ glArrayHandler.enableState(gl, true, ext);
} else {
- glArrayHandler.enableState(gl, false);
- glArrayHandler.syncData(gl, false);
+ glArrayHandler.enableState(gl, false, ext);
+ glArrayHandler.syncData(gl, false, ext);
}
bufferEnabled = enable;
}
@@ -349,7 +346,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
protected void init(String name, int index, int comps, int dataType, boolean normalized, int stride, Buffer data,
int initialSize, boolean isVertexAttribute, GLArrayHandler handler,
- int vboName, long vboOffset, int vboUsage, int vboTarget)
+ int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL)
throws GLException
{
super.init(name, index, comps, dataType, normalized, stride, data, isVertexAttribute,
@@ -357,6 +354,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
this.initialSize = initialSize;
this.glArrayHandler = handler;
+ this.usesGLSL = usesGLSL;
this.sealed=false;
this.bufferEnabled=false;
this.enableBufferAlways=false;
@@ -385,5 +383,6 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
protected int initialSize;
protected GLArrayHandler glArrayHandler;
+ protected boolean usesGLSL;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index 8b254a9c9..d3bb2e3fd 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -9,14 +9,14 @@ import javax.media.opengl.GLArrayData;
import javax.media.opengl.GLException;
import javax.media.opengl.fixedfunc.GLPointerFuncUtil;
+import jogamp.opengl.util.GLArrayHandler;
+import jogamp.opengl.util.GLArrayHandlerInterleaved;
import jogamp.opengl.util.GLDataArrayHandler;
import jogamp.opengl.util.GLFixedArrayHandler;
import jogamp.opengl.util.GLFixedArrayHandlerFlat;
-import jogamp.opengl.util.GLFixedArrayHandlerInterleaved;
import jogamp.opengl.util.glsl.GLSLArrayHandler;
import jogamp.opengl.util.glsl.GLSLArrayHandlerFlat;
-import com.jogamp.opengl.util.glsl.ShaderState;
public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataEditable {
@@ -53,7 +53,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
ads.init(null, index, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler,
- 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
+ 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
return ads;
}
@@ -85,15 +85,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
ads.init(null, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler,
- 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
+ 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
return ads;
}
/**
* Create a VBO, using a custom GLSL array attribute name
* and starting with a new created Buffer object with initialSize size
- *
- * @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
* @param name The custom name for the GL attribute
* @param comps The array component number
* @param dataType The array index GL data type
@@ -101,23 +99,20 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* @param initialSize
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
*/
- public static GLArrayDataServer createGLSL(ShaderState st, String name,
- int comps, int dataType, boolean normalized, int initialSize,
- int vboUsage)
+ public static GLArrayDataServer createGLSL(String name, int comps,
+ int dataType, boolean normalized, int initialSize, int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
- GLArrayHandler glArrayHandler = new GLSLArrayHandler(st, ads);
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
ads.init(name, -1, comps, dataType, normalized, 0, null, initialSize,
- true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
+ true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
return ads;
}
/**
* Create a VBO, using a custom GLSL array attribute name
* and starting with a given Buffer object incl it's stride
- *
- * @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
* @param name The custom name for the GL attribute
* @param comps The array component number
* @param dataType The array index GL data type
@@ -126,15 +121,15 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* @param buffer the user define data
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
*/
- public static GLArrayDataServer createGLSL(ShaderState st, String name,
- int comps, int dataType, boolean normalized, int stride,
- Buffer buffer, int vboUsage)
+ public static GLArrayDataServer createGLSL(String name, int comps,
+ int dataType, boolean normalized, int stride, Buffer buffer,
+ int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
- GLArrayHandler glArrayHandler = new GLSLArrayHandler(st, ads);
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
ads.init(name, -1, comps, dataType, normalized, stride, buffer, buffer.limit(), true, glArrayHandler,
- 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
+ 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
return ads;
}
@@ -158,7 +153,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads);
ads.init(null, -1, comps, dataType, false, stride, buffer, buffer.limit(), false, glArrayHandler,
- 0, 0, vboUsage, vboTarget);
+ 0, 0, vboUsage, vboTarget, false);
return ads;
}
@@ -180,17 +175,15 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads);
ads.init(null, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
- 0, 0, vboUsage, vboTarget);
+ 0, 0, vboUsage, vboTarget, false);
return ads;
}
/**
- * Create a VBO for interleaved array data
+ * Create a VBO for fixed function interleaved array data
* starting with a new created Buffer object with initialSize size.
- * <p>User needs to <i>configure</i> the interleaved segments via {@link #addFixedSubArray(int, int, int)}
- * for fixed function arrays or via {@link #addGLSLSubArray(ShaderState, String, int, int)} for GLSL
- * attributes.</p>
+ * <p>User needs to <i>configure</i> the interleaved segments via {@link #addFixedSubArray(int, int, int)}.</p>
*
* @param comps The total number of all interleaved components.
* @param dataType The array index GL data type
@@ -198,22 +191,19 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* @param initialSize
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
*/
- public static GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize,
+ public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int initialSize,
int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
- GLArrayHandler glArrayHandler = new GLFixedArrayHandlerInterleaved(ads);
+ GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads);
ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
- 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
+ 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
return ads;
}
- int interleavedOffset = 0;
-
/**
- * Configure a segment of this interleaved array (see {@link #createInterleaved(int, int, boolean, int, int)})
- * for fixed function usage.
+ * Configure a segment of this fixed function interleaved array (see {@link #createFixedInterleaved(int, int, boolean, int, int)}).
* <p>
* This method may be called several times as long the sum of interleaved components does not
* exceed the total number of components of the created interleaved array.</p>
@@ -231,6 +221,9 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int iOffC = interleavedOffset / getComponentSizeInBytes();
throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
}
+ if(usesGLSL) {
+ throw new GLException("buffer uses GLSL");
+ }
GLArrayDataWrapper ad = GLArrayDataWrapper.createFixed(
index, comps, getComponentType(),
getNormalized(), getStride(), getBuffer(),
@@ -245,8 +238,29 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
/**
- * Configure a segment of this interleaved array (see {@link #createInterleaved(int, int, boolean, int, int)})
- * for GLSL usage.
+ * Create a VBO for GLSL interleaved array data
+ * starting with a new created Buffer object with initialSize size.
+ * <p>User needs to <i>configure</i> the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.</p>
+ *
+ * @param comps The total number of all interleaved components.
+ * @param dataType The array index GL data type
+ * @param normalized Whether the data shall be normalized
+ * @param initialSize
+ * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
+ */
+ public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int initialSize,
+ int vboUsage)
+ throws GLException
+ {
+ GLArrayDataServer ads = new GLArrayDataServer();
+ GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads);
+ ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
+ 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
+ return ads;
+ }
+
+ /**
+ * Configure a segment of this GLSL interleaved array (see {@link #createGLSLInterleaved(int, int, boolean, int, int)}).
* <p>
* This method may be called several times as long the sum of interleaved components does not
* exceed the total number of components of the created interleaved array.</p>
@@ -254,17 +268,18 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* The memory of the the interleaved array is being used.</p>
* <p>
* Must be called before using the array, eg: {@link #seal(boolean)}, {@link #putf(float)}, .. </p>
- *
- * @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
* @param name The custom name for the GL attribute, maybe null if vboTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
* @param comps This interleaved array segment's component number
* @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
*/
- public GLArrayData addGLSLSubArray(ShaderState st, String name, int comps, int vboTarget) {
+ public GLArrayData addGLSLSubArray(String name, int comps, int vboTarget) {
if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) {
final int iOffC = interleavedOffset / getComponentSizeInBytes();
throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
}
+ if(!usesGLSL) {
+ throw new GLException("buffer uses fixed function");
+ }
GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL(
name, comps, getComponentType(),
getNormalized(), getStride(), getBuffer(),
@@ -272,7 +287,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
ad.setVBOEnabled(isVBO());
interleavedOffset += comps * getComponentSizeInBytes();
if(GL.GL_ARRAY_BUFFER == vboTarget) {
- GLArrayHandler handler = new GLSLArrayHandlerFlat(st, ad);
+ GLArrayHandler handler = new GLSLArrayHandlerFlat(ad);
glArrayHandler.addSubHandler(handler);
}
return ad;
@@ -341,11 +356,11 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
protected void init(String name, int index, int comps, int dataType, boolean normalized,
int stride, Buffer data, int initialSize, boolean isVertexAttribute,
GLArrayHandler glArrayHandler,
- int vboName, long vboOffset, int vboUsage, int vboTarget)
+ int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL)
throws GLException
{
super.init(name, index, comps, dataType, normalized, stride, data, initialSize, isVertexAttribute, glArrayHandler,
- vboName, vboOffset, vboUsage, vboTarget);
+ vboName, vboOffset, vboUsage, vboTarget, usesGLSL);
vboEnabled=true;
}
@@ -358,5 +373,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
vboName = tmp[0];
}
}
+
+ private int interleavedOffset = 0;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java
deleted file mode 100644
index b30e220bd..000000000
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java
+++ /dev/null
@@ -1,40 +0,0 @@
-
-package com.jogamp.opengl.util;
-
-import javax.media.opengl.*;
-
-/**
- * Handles consistency of buffer data and array state.
- * Implementations shall consider buffer types (VBO, ..), interleaved, etc.
- * They also need to consider array state types, i.e. fixed function or GLSL.
- */
-public interface GLArrayHandler {
-
- /**
- * Implementation shall associate the data with the array
- * and synchronize the data with the GPU.
- *
- * @param gl current GL object
- * @param enable true if array data shall be valid, otherwise false.
- */
- public void syncData(GL gl, boolean enable);
-
- /**
- * Implementation shall enable or disable the array state.
- *
- * @param gl current GL object
- * @param enable true if array shall be enabled, otherwise false.
- */
- public void enableState(GL gl, boolean enable);
-
- /**
- * Supporting interleaved arrays, where sub handlers may handle
- * the array state and the <i>master</i> handler the buffer consistency.
- *
- * @param handler the sub handler
- * @throws UnsupportedOperationException if this array handler does not support interleaved arrays
- */
- public void addSubHandler(GLArrayHandler handler) throws UnsupportedOperationException;
-
-}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
index a2a012e08..36abd9d4d 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
@@ -49,7 +49,8 @@ import com.jogamp.opengl.util.GLArrayDataEditable;
public class ShaderState {
public static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true, AccessController.getContext());
-
+ private static final String currentStateKey = "jogamp.opengl.glsl.ShaderState" ;
+
public ShaderState() {
}
@@ -78,7 +79,7 @@ public class ShaderState {
* @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState()
*/
public static synchronized ShaderState getShaderState(GL gl) {
- return (ShaderState) gl.getContext().getAttachedObject(ShaderState.class.getName());
+ return (ShaderState) gl.getContext().getAttachedObject(currentStateKey);
}
/**
@@ -141,7 +142,7 @@ public class ShaderState {
if(null==shaderProgram) { throw new GLException("No program is attached"); }
if(on) {
// update the current ShaderState to the TLS ..
- gl.getContext().attachObject(ShaderState.class.getName(), this);
+ gl.getContext().attachObject(currentStateKey, this);
if(shaderProgram.linked()) {
shaderProgram.useProgram(gl, true);
if(resetAllShaderData) {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
index c81e1f961..9ccd38bf1 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
@@ -461,11 +461,12 @@ public class ShaderUtil {
private static Impl getImpl(GL _gl) {
GL2ES2 gl = _gl.getGL2ES2();
GLContext context = gl.getContext();
- Impl impl = (Impl) context.getAttachedObject(ShaderUtil.class.getName());
+ Impl impl = (Impl) context.getAttachedObject(implObjectKey);
if (impl == null) {
impl = new GL2ES2Impl();
- context.attachObject(ShaderUtil.class.getName(), impl);
+ context.attachObject(implObjectKey, impl);
}
return impl;
}
+ private static final String implObjectKey = "jogamp.opengl.glsl.ShaderUtilImpl" ;
}