1   @Override
glVertexAttribPointer(GLArrayData array)2   public final void glVertexAttribPointer(GLArrayData array) {
3     if(array.getComponentCount()==0) return;
4     if(array.isVBO()) {
5         glVertexAttribPointer(array.getLocation(), array.getComponentCount(), array.getComponentType(),
6                               array.getNormalized(), array.getStride(), array.getVBOOffset());
7     } else {
8         glVertexAttribPointer(array.getLocation(), array.getComponentCount(), array.getComponentType(),
9                               array.getNormalized(), array.getStride(), array.getBuffer());
10     }
11   }
12 
13   @Override
glUniform(GLUniformData data)14   public final void glUniform(GLUniformData data) {
15     boolean done=false;
16     if(data.isBuffer()) {
17         Buffer buffer = data.getBuffer();
18         if(data.isMatrix()) {
19             if(buffer instanceof FloatBuffer) {
20                 switch(data.columns()) {
21                     case 2: glUniformMatrix2fv(data.getLocation(), data.count(), false, (FloatBuffer)buffer); done=true; break;
22                     case 3: glUniformMatrix3fv(data.getLocation(), data.count(), false, (FloatBuffer)buffer); done=true; break;
23                     case 4: glUniformMatrix4fv(data.getLocation(), data.count(), false, (FloatBuffer)buffer); done=true; break;
24                 }
25             }
26             if(!done) {
27                 throw new GLException("glUniformMatrix only available for 2fv, 3fv and 4fv");
28             }
29         } else {
30             if(buffer instanceof IntBuffer) {
31                 switch(data.components()) {
32                     case 1: glUniform1iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
33                     case 2: glUniform2iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
34                     case 3: glUniform3iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
35                     case 4: glUniform4iv(data.getLocation(), data.count(), (IntBuffer)buffer); done=true; break;
36                 }
37             } else if(buffer instanceof FloatBuffer) {
38                 switch(data.components()) {
39                     case 1: glUniform1fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
40                     case 2: glUniform2fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
41                     case 3: glUniform3fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
42                     case 4: glUniform4fv(data.getLocation(), data.count(), (FloatBuffer)buffer); done=true; break;
43                 }
44             }
45             if(!done) {
46                 throw new GLException("glUniform vector only available for 1[if]v 2[if]v, 3[if]v and 4[if]v");
47             }
48         }
49     } else {
50         Object obj = data.getObject();
51         if(obj instanceof Integer) {
52             glUniform1i(data.getLocation(), ((Integer)obj).intValue());
53             done=true;
54         } else if (obj instanceof Float) {
55             glUniform1f(data.getLocation(), ((Float)obj).floatValue());
56             done=true;
57         }
58         if(!done) {
59             throw new GLException("glUniform atom only available for 1i and 1f");
60         }
61     }
62   }
63 
64