public static VertexShader makemain(List<VertexShader> shaders) { StringBuilder buf = new StringBuilder(); Collections.sort(shaders, cmp); for (VertexShader sh : shaders) buf.append(sh.header + "\n"); buf.append("\n"); buf.append("void main()\n{\n"); buf.append(" vec4 fcol = gl_Color;\n"); buf.append(" vec4 bcol = gl_Color;\n"); buf.append(" vec4 objv = gl_Vertex;\n"); buf.append(" vec3 objn = gl_Normal;\n"); int i = 0; for (; i < shaders.size(); i++) { VertexShader sh = shaders.get(i); if (sh.uses("eyev") || sh.uses("eyen")) break; buf.append(" " + sh.call() + ";\n"); } buf.append(" vec4 eyev = gl_ModelViewMatrix * objv;\n"); buf.append(" vec3 eyen = gl_NormalMatrix * objn;\n"); for (; i < shaders.size(); i++) { VertexShader sh = shaders.get(i); buf.append(" " + sh.call() + ";\n"); } buf.append(" gl_FrontColor = fcol;\n"); buf.append(" gl_Position = gl_ProjectionMatrix * eyev;\n"); buf.append("}\n"); return (new VertexShader(buf.toString())); }
public void addTick(Cam c) { tickArr.add(new Tick(hs1.getSliderPos(), hsYPos, c, hs1.getPosInSeconds())); // set the older ticks to inactive for (int i = 0; i < tickArr.size() - 1; i++) { tickArr.get(i).setToInActive(); } // sort the ticks in case one was placed before an existing tick Collections.sort(tickArr); }
public static FragmentShader makemain(List<FragmentShader> shaders) { StringBuilder buf = new StringBuilder(); Collections.sort(shaders, cmp); for (FragmentShader sh : shaders) buf.append(sh.header + "\n"); buf.append("\n"); buf.append("void main()\n{\n"); buf.append(" vec4 res = gl_Color;\n"); for (FragmentShader sh : shaders) { buf.append(" " + sh.entry + "(res);\n"); } buf.append(" gl_FragColor = res;\n"); buf.append("}\n"); return (new FragmentShader(buf.toString())); }