Android Open Source - touchgloid Vertex 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;
//from   w w  w. j a v  a2 s .  c  om
import static android.opengl.GLES20.GL_ARRAY_BUFFER;
import static android.opengl.GLES20.GL_STATIC_DRAW;

import java.nio.FloatBuffer;

public final class VertexBuffer extends Buffer {

  private static final int TARGET = GL_ARRAY_BUFFER;
  private static final int DEFAULT_USAGE = GL_STATIC_DRAW;
  
  public static VertexBuffer create() {
    return new VertexBuffer(Buffer.generateBufferId());
  }

  public static VertexBuffer create(float[] vertices) {
    return create(vertices, DEFAULT_USAGE);
  }
  
  public static VertexBuffer create(float[] vertices, int usage) {
    VertexBuffer vertexBuffer = create();
    
    vertexBuffer.bind();
    vertexBuffer.buffer(vertices, usage);
    vertexBuffer.unbind();
    
    return vertexBuffer;
  }

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

  public void buffer(float[] vertices) {
    buffer(vertices, DEFAULT_USAGE);
  }

  public void buffer(float[] vertices, int usage) {
    buffer(buildFloatBuffer(vertices), usage);
  }

  public void buffer(FloatBuffer vertices) {
    buffer(vertices, 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