public ITCore(String vertShader, String fragShader) { super(vertShader, fragShader); // determine our various shader program locations uScreenSize = prog.getUniform2f("u_ScreenSize"); aMatrix = prog.getAttrib("a_Matrix", 4, GL20.GL_FLOAT); aTranslation = prog.getAttrib("a_Translation", 2, GL20.GL_FLOAT); aColor = prog.getAttrib("a_Color", 2, GL20.GL_FLOAT); aPosition = prog.getAttrib("a_Position", 2, GL20.GL_FLOAT); aTexCoord = prog.getAttrib("a_TexCoord", 2, GL20.GL_FLOAT); // create our vertex and index buffers stableAttrs = new float[stableAttrsSize()]; vertices = ctx.createFloatBuffer(START_VERTS*vertexSize()); elements = ctx.createShortBuffer(START_ELEMS); }
public QuadCore(String vertShader, String fragShader) { super(vertShader, fragShader); // compile the shader and get our uniform and attribute uScreenSize = prog.getUniform2f("u_ScreenSize"); uData = prog.getUniform4fv("u_Data"); aVertex = prog.getAttrib("a_Vertex", VERTEX_SIZE, GL20.GL_SHORT); // create our stock supply of unit quads and stuff them into our buffers vertices = ctx.createShortBuffer(maxQuads*VERTICES_PER_QUAD*VERTEX_SIZE); elements = ctx.createShortBuffer(maxQuads*ELEMENTS_PER_QUAD); for (int ii = 0; ii < maxQuads; ii++) { vertices.add(0, 0).add(ii); vertices.add(1, 0).add(ii); vertices.add(0, 1).add(ii); vertices.add(1, 1).add(ii); int base = ii * VERTICES_PER_QUAD; elements.add(base+0).add(base+1).add(base+2); elements.add(base+1).add(base+3).add(base+2); } // create the buffer that will hold quad data, and the float array that we'll use to avoid // making too many calls to FloatBuffer.put() which has crap performance on Android data = ctx.createFloatBuffer(maxQuads*vec4sPerQuad()*4); vertices.bind(GL20.GL_ARRAY_BUFFER); vertices.send(GL20.GL_ARRAY_BUFFER, GL20.GL_STATIC_DRAW); elements.bind(GL20.GL_ELEMENT_ARRAY_BUFFER); elements.send(GL20.GL_ELEMENT_ARRAY_BUFFER, GL20.GL_STATIC_DRAW); }