aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-12-16 02:55:07 +0100
committerSven Gothel <[email protected]>2012-12-16 02:55:07 +0100
commitb8a8fc24a3afb0cb06a31504bdea1a98b8f00ef4 (patch)
tree37bd8b49f7e4fd547ff58656dff09b5a88e65c47 /src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
parente7064ece049705e013d80985eae698ce0ee3c4e3 (diff)
GLArrayData/ImmModeSink: Remove implicit dependency on ShaderState - allow operating w/o it; ShaderState: Remove notion of GL context attachment, use pass-through or object association; GLArrayData/GLUniformData: Add basic GLSL location methods
- GLArrayData/GLUniformData: Add basic GLSL location methods - GLArrayData - add: setLocation(..) for attribute location/index retrieval (post link) and binding (pre link) - GLUniformData - add: setLocation(..) for attribute location/index retrieval (post link) - GLArrayData/ImmModeSink: Remove implicit dependency on ShaderState - allow operating w/o it - GLArrayData - add: 'public void associate(Object obj, boolean enable)', allows setting ShaderState usage - ShaderState: Remove notion of GL context attachment, use pass-through or object association - ownsAttribute(..) associates the attribute w/ ShaderState - removed GL context ShaderState attachment Tested: - ImmModeSink w/ GLSL/ES2 w/ and w/o ShaderState - GLArrayData* w/ and w/o ShaderState
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
index c5beb7dd0..855406db3 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
@@ -53,9 +53,13 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat {
public final void syncData(GL gl, Object ext) {
final GL2ES2 glsl = gl.getGL2ES2();
- final ShaderState st = (ShaderState) ext;
-
- st.vertexAttribPointer(glsl, ad);
+ if( null != ext ) {
+ ((ShaderState)ext).vertexAttribPointer(glsl, ad);
+ } else {
+ if( 0 <= ad.getLocation() ) {
+ glsl.glVertexAttribPointer(ad);
+ }
+ }
/**
* Due to probable application VBO switching, this might not make any sense ..
*
@@ -75,13 +79,22 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat {
public final void enableState(GL gl, boolean enable, Object ext) {
final GL2ES2 glsl = gl.getGL2ES2();
- final ShaderState st = (ShaderState) ext;
-
- if(enable) {
- st.enableVertexAttribArray(glsl, ad);
+ if( null != ext ) {
+ final ShaderState st = (ShaderState)ext;
+ if(enable) {
+ st.enableVertexAttribArray(glsl, ad);
+ } else {
+ st.disableVertexAttribArray(glsl, ad);
+ }
} else {
- st.disableVertexAttribArray(glsl, ad);
+ final int location = ad.getLocation();
+ if( 0 <= location ) {
+ if(enable) {
+ glsl.glEnableVertexAttribArray(location);
+ } else {
+ glsl.glDisableVertexAttribArray(location);
+ }
+ }
}
}
}
-