diff options
author | Sven Gothel <[email protected]> | 2008-08-04 12:11:21 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2008-08-04 12:11:21 +0000 |
commit | dc5883b13f157586dd2d89a84f9ea91d945edf70 (patch) | |
tree | d94df2e293bc24529b632514dfde6e73e22545fb /make/gl-impl-CustomJavaCode-gl2_es2.java | |
parent | 3224cf710cd4eaaca51d42dfd7302579be412498 (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 'make/gl-impl-CustomJavaCode-gl2_es2.java')
-rw-r--r-- | make/gl-impl-CustomJavaCode-gl2_es2.java | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/make/gl-impl-CustomJavaCode-gl2_es2.java b/make/gl-impl-CustomJavaCode-gl2_es2.java index cdc5c3898..0a525c4e7 100644 --- a/make/gl-impl-CustomJavaCode-gl2_es2.java +++ b/make/gl-impl-CustomJavaCode-gl2_es2.java @@ -1,4 +1,3 @@ - public String glGetShaderInfoLog(int shaderObj) { int[] infoLogLength=new int[1]; glGetShaderiv(shaderObj, GL_INFO_LOG_LENGTH, infoLogLength, 0); @@ -232,4 +231,63 @@ shaders.clear(); } + public void glVertexAttribPointer(GLArrayData array) { + if(array.isVBO()) { + glVertexAttribPointer(array.getLocation(), array.getComponents(), array.getDataType(), + array.getNormalized(), array.getStride(), array.getOffset()); + } else { + glVertexAttribPointer(array.getLocation(), array.getComponents(), array.getDataType(), + 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"); + } + } + } |