Skip to content

Instantly share code, notes, and snippets.

@busti
Created July 18, 2016 21:53
Show Gist options
  • Save busti/5fddce4b52930efa8704c9d53032e211 to your computer and use it in GitHub Desktop.
Save busti/5fddce4b52930efa8704c9d53032e211 to your computer and use it in GitHub Desktop.
public void draw(final int programHandle) {
final int positionHandle = GLES20.glGetAttribLocation(programHandle, "vertPos");
final int colorHandle = GLES20.glGetUniformLocation(programHandle, "vertColor");
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 12, vertexBuffer);
GLES20.glEnableVertexAttribArray(colorHandle);
GLES20.glVertexAttribPointer(colorHandle, 4, GLES20.GL_FLOAT, false, 16, colorBuffer);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, vertCount, GLES20.GL_UNSIGNED_SHORT, indexBuffer);
GLES20.glDisableVertexAttribArray(positionHandle);
GLES20.glDisableVertexAttribArray(colorHandle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment