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); }
private void bindAttribsBufs() { vertices.bind(GL20.GL_ARRAY_BUFFER); // bind our stable attributes int stride = vertexStride(); aMatrix.bind(stride, 0); aTranslation.bind(stride, 16); aColor.bind(stride, 24); // bind our changing attributes int offset = stableAttrsSize()*FLOAT_SIZE_BYTES; aPosition.bind(stride, offset); if (aTexCoord != null) aTexCoord.bind(stride, offset+8); elements.bind(GL20.GL_ELEMENT_ARRAY_BUFFER); }
protected int vertexSize() { return stableAttrsSize() + 4; }