summaryrefslogtreecommitdiffstats
path: root/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-06-15 22:57:38 +0000
committerKenneth Russel <[email protected]>2009-06-15 22:57:38 +0000
commita959c53b7ac91e489bf0959391e892790b9ff248 (patch)
tree4664742a4f9f6daa694364292e376ad2e6ee97d1 /make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java
parent506b634b780dcd23aa61015c2ceba3e687196abf (diff)
Copied JOGL_2_SANDBOX r1957 on to trunk; JOGL_2_SANDBOX branch is now closed
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1959 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java')
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java
new file mode 100644
index 000000000..0d0daf463
--- /dev/null
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java
@@ -0,0 +1,60 @@
+ public void glVertexAttribPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glVertexAttribPointer(array.getLocation(), array.getComponentNumber(), array.getComponentType(),
+ array.getNormalized(), array.getStride(), array.getOffset());
+ } else {
+ glVertexAttribPointer(array.getLocation(), array.getComponentNumber(), array.getComponentType(),
+ array.getNormalized(), array.getStride(), array.getBuffer());
+ }
+ }
+
+ public void glUniform(GLUniformData data) {
+ boolean done=false;
+ if(data.isBuffer()) {
+ Buffer buffer = data.getBuffer();
+ if(data.isMatrix()) {
+ if(buffer instanceof FloatBuffer) {
+ switch(data.columns()) {
+ case 2: glUniformMatrix2fv(data.getLocation(), data.count(), false, (FloatBuffer)buffer); done=true; break;
+ case 3: glUniformMatrix3fv(data.getLocation(), data.count(), false, (FloatBuffer)buffer); done=true; break;
+ case 4: glUniformMatrix4fv(data.getLocation(), data.count(), false, (FloatBuffer)buffer); done=true; break;
+ }
+ }
+ if(!done) {
+ throw new GLException("glUniformMatrix only available for 2fv, 3fv and 4fv");
+ }
+ } else {
+ if(buffer instanceof IntBuffer) {
+ switch(data.components()) {
+ case 1: glUniform1iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
+ case 2: glUniform2iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
+ case 3: glUniform3iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
+ case 4: glUniform4iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
+ }
+ } else if(buffer instanceof FloatBuffer) {
+ switch(data.components()) {
+ case 1: glUniform1fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
+ case 2: glUniform2fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
+ case 3: glUniform3fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
+ case 4: glUniform4fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
+ }
+ }
+ if(!done) {
+ throw new GLException("glUniform vector only available for 1[if]v 2[if]v, 3[if]v and 4[if]v");
+ }
+ }
+ } else {
+ Object obj = data.getObject();
+ if(obj instanceof Integer) {
+ glUniform1i(data.getLocation(), ((Integer)obj).intValue());
+ done=true;
+ } else if (obj instanceof Float) {
+ glUniform1f(data.getLocation(), ((Float)obj).floatValue());
+ done=true;
+ }
+ if(!done) {
+ throw new GLException("glUniform atom only available for 1i and 1f");
+ }
+ }
+ }