aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-08-04 12:11:21 +0000
committerSven Gothel <[email protected]>2008-08-04 12:11:21 +0000
commitdc5883b13f157586dd2d89a84f9ea91d945edf70 (patch)
treed94df2e293bc24529b632514dfde6e73e22545fb /src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
parent3224cf710cd4eaaca51d42dfd7302579be412498 (diff)
../jogl.log
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1741 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java')
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
new file mode 100644
index 000000000..551eb525f
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
@@ -0,0 +1,58 @@
+
+package com.sun.opengl.impl.glsl;
+
+import javax.media.opengl.*;
+import javax.media.opengl.util.glsl.ShaderState;
+import java.nio.*;
+
+public class GLSLArrayDataServer extends GLArrayDataServer {
+
+ public GLSLArrayDataServer(String name, int comps, int dataType, boolean normalized,
+ int stride, Buffer buffer, int glBufferUsage) {
+ init(name, -1, comps, dataType, normalized, stride, buffer, 0, buffer.limit(), glBufferUsage, true);
+ }
+
+ public GLSLArrayDataServer(String name, int comps, int dataType, boolean normalized,
+ int stride, long bufferOffset) {
+ init(name, -1, comps, dataType, normalized, stride, null, bufferOffset, 0, -1, true);
+ }
+
+ public GLSLArrayDataServer(String name, int comps, int dataType, boolean normalized,
+ int initialSize, int glBufferUsage) {
+ init(name, -1, comps, dataType, normalized, 0, null, 0, initialSize, glBufferUsage, true);
+ }
+
+
+ protected void enableBufferGLImpl(GL gl, boolean enable) {
+ GL2ES2 glsl = gl.getGL2ES2();
+ ShaderState st = ShaderState.getCurrent();
+ if(null==st) {
+ throw new GLException("No ShaderState current");
+ }
+
+ if(enable) {
+ if(!st.glEnableVertexAttribArray(glsl, name)) {
+ throw new RuntimeException("Internal Error");
+ }
+ bufferEnabled = true;
+
+ if(vboUsage) {
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName);
+ if(!bufferWritten) {
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit() * getBufferCompSize(), buffer, glBufferUsage);
+ }
+ }
+ if ( ! st.glVertexAttribPointer(glsl, this) ) {
+ throw new RuntimeException("Internal Error");
+ }
+ bufferWritten=true;
+ } else {
+ if(!st.glDisableVertexAttribArray(glsl, name)) {
+ throw new RuntimeException("Internal Error");
+ }
+ bufferEnabled = false;
+ }
+ }
+
+}
+