protected int vertexSize () { return stableAttrsSize() + 4; } protected int vertexStride () { return vertexSize() * FLOAT_SIZE_BYTES; }
protected int vertexSize () { return stableAttrsSize() + 4; } protected int vertexStride () { return vertexSize() * FLOAT_SIZE_BYTES; }
private void bindAttribsBufs () { gl.glBindBuffer(GL_ARRAY_BUFFER, verticesId); // bind our stable vertex attributes int stride = vertexStride(); glBindVertAttrib(aMatrix, 4, GL_FLOAT, stride, 0); glBindVertAttrib(aTranslation, 2, GL_FLOAT, stride, 16); glBindVertAttrib(aColor, 2, GL_FLOAT, stride, 24); // bind our changing vertex attributes int offset = stableAttrsSize()*FLOAT_SIZE_BYTES; glBindVertAttrib(aPosition, 2, GL_FLOAT, stride, offset); glBindVertAttrib(aTexCoord, 2, GL_FLOAT, stride, offset+8); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementsId); gl.glActiveTexture(GL_TEXTURE0); gl.glUniform1i(uTexture, 0); }
private void bindAttribsBufs () { gl.glBindBuffer(GL_ARRAY_BUFFER, verticesId); // bind our stable vertex attributes int stride = vertexStride(); glBindVertAttrib(aMatrix, 4, GL_FLOAT, stride, 0); glBindVertAttrib(aTranslation, 2, GL_FLOAT, stride, 16); glBindVertAttrib(aColor, 2, GL_FLOAT, stride, 24); // bind our changing vertex attributes int offset = stableAttrsSize()*FLOAT_SIZE_BYTES; glBindVertAttrib(aPosition, 2, GL_FLOAT, stride, offset); glBindVertAttrib(aTexCoord, 2, GL_FLOAT, stride, offset+8); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementsId); gl.glActiveTexture(GL_TEXTURE0); gl.glUniform1i(uTexture, 0); }
/** Creates a triangle batch with the supplied custom shader program. */ public TriangleBatch (GL20 gl, Source source) { super(gl); delayedBinding = "Intel".equals(gl.glGetString(GL20.GL_VENDOR)); program = new GLProgram(gl, source.vertex(), source.fragment()); uTexture = program.getUniformLocation("u_Texture"); uHScreenSize = program.getUniformLocation("u_HScreenSize"); uFlip = program.getUniformLocation("u_Flip"); aMatrix = program.getAttribLocation("a_Matrix"); aTranslation = program.getAttribLocation("a_Translation"); aColor = program.getAttribLocation("a_Color"); aPosition = program.getAttribLocation("a_Position"); aTexCoord = program.getAttribLocation("a_TexCoord"); // create our vertex and index buffers stableAttrs = new float[stableAttrsSize()]; vertices = new float[START_VERTS*vertexSize()]; elements = new short[START_ELEMS]; // create our GL buffers int[] ids = new int[2]; gl.glGenBuffers(2, ids, 0); verticesId = ids[0]; elementsId = ids[1]; gl.checkError("TriangleBatch end ctor"); }
/** Creates a triangle batch with the supplied custom shader program. */ public TriangleBatch (GL20 gl, Source source) { super(gl); delayedBinding = "Intel".equals(gl.glGetString(GL20.GL_VENDOR)); program = new GLProgram(gl, source.vertex(), source.fragment()); uTexture = program.getUniformLocation("u_Texture"); uHScreenSize = program.getUniformLocation("u_HScreenSize"); uFlip = program.getUniformLocation("u_Flip"); aMatrix = program.getAttribLocation("a_Matrix"); aTranslation = program.getAttribLocation("a_Translation"); aColor = program.getAttribLocation("a_Color"); aPosition = program.getAttribLocation("a_Position"); aTexCoord = program.getAttribLocation("a_TexCoord"); // create our vertex and index buffers stableAttrs = new float[stableAttrsSize()]; vertices = new float[START_VERTS*vertexSize()]; elements = new short[START_ELEMS]; // create our GL buffers int[] ids = new int[2]; gl.glGenBuffers(2, ids, 0); verticesId = ids[0]; elementsId = ids[1]; gl.checkError("TriangleBatch end ctor"); }