Android Open Source - touchgloid Index Buffer






From Project

Back to project page touchgloid.

License

The source code is released under:

MIT License

If you think the Android project touchgloid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package rucamzu.opengl;
/*w w  w . j  av a 2 s . c o  m*/
import static android.opengl.GLES20.GL_ELEMENT_ARRAY_BUFFER;
import static android.opengl.GLES20.GL_STATIC_DRAW;

import java.nio.ShortBuffer;

public final class IndexBuffer extends Buffer {
  
  private static final int TARGET = GL_ELEMENT_ARRAY_BUFFER;
  private static final int DEFAULT_USAGE = GL_STATIC_DRAW;
  
  public static IndexBuffer create() {
    return new IndexBuffer(Buffer.generateBufferId());
  }

  public static IndexBuffer create(short[] indices) {
    return create(indices, DEFAULT_USAGE);
  }
  
  public static IndexBuffer create(short[] indices, int usage) {
    IndexBuffer indexBuffer = create();
    
    indexBuffer.bind();
    indexBuffer.buffer(indices, usage);
    indexBuffer.unbind();
    
    return indexBuffer;
  }

  private IndexBuffer(int id) {
    super(id);
  }

  public void buffer(short[] indices) {
    buffer(indices, DEFAULT_USAGE);
  }

  public void buffer(short[] indices, int usage) {
    buffer(buildShortBuffer(indices), usage);
  }
  
  public void buffer(ShortBuffer indices) {
    buffer(indices, DEFAULT_USAGE);
  }

  @Override
  protected int target() {
    return TARGET;
  }
  
}




Java Source Code List

rucamzu.opengl.Buffer.java
rucamzu.opengl.FragmentShader.java
rucamzu.opengl.IndexBuffer.java
rucamzu.opengl.Object.java
rucamzu.opengl.Program.java
rucamzu.opengl.Shader.java
rucamzu.opengl.Transform.java
rucamzu.opengl.Vector.java
rucamzu.opengl.VertexBuffer.java
rucamzu.opengl.VertexShader.java
rucamzu.touchgloid.TouchgloidActivity.java
rucamzu.touchgloid.TouchgloidRenderer.java
rucamzu.touchgloid.TouchgloidView.java