Android Open Source - OpenGL-es3-android Mallet






From Project

Back to project page OpenGL-es3-android.

License

The source code is released under:

GNU General Public License

If you think the Android project OpenGL-es3-android 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 com.opengles3.demo.objects;
/*  www.j ava  2  s. c  om*/
import java.util.List;

import com.opengles3.demo.geometry.ObjectBuilder;
import com.opengles3.demo.geometry.VertexArray;
import com.opengles3.demo.geometry.ObjectBuilder.DrawCommand;
import com.opengles3.demo.geometry.ObjectBuilder.GeneratedData;
import com.opengles3.demo.geometry.Shapes.Point;
import com.opengles3.demo.programs.ColorShaderProgram;

public class Mallet {
  private static final int POSITION_COMPONENT_COUNT = 3;
  
  public final float radius, height;
  
  private final VertexArray vertexArray;
  private final List<DrawCommand> drawList;
  
  
  public Mallet(float radius, float height, int numPointsAroundMallet){
    GeneratedData generatedData = ObjectBuilder.createMallet(
        new Point(0f, 0f, 0f), radius,
        height, numPointsAroundMallet);
    this.radius = radius;
    this.height = height;
    
    vertexArray = new VertexArray(generatedData.vertexData);
    drawList = generatedData.drawList;
  }
  public void bindData(ColorShaderProgram colorProgram){
    vertexArray.setVertexAttribPointer(0,
        colorProgram.getPositionAttributeLocation(),
        POSITION_COMPONENT_COUNT, 0);
    
  }
  public void draw(){
    for(DrawCommand drawCommand : drawList){
      drawCommand.draw();
    }
  }
}




Java Source Code List

com.opengles3.demo.GLRenderer.java
com.opengles3.demo.GLTextureView.java
com.opengles3.demo.MainActivity.java
com.opengles3.demo.geometry.ObjectBuilder.java
com.opengles3.demo.geometry.Shapes.java
com.opengles3.demo.geometry.VertexArray.java
com.opengles3.demo.objects.Mallet.java
com.opengles3.demo.objects.Puck.java
com.opengles3.demo.objects.Table.java
com.opengles3.demo.objects.TexturedTriangleFan.java
com.opengles3.demo.programs.ColorShaderProgram.java
com.opengles3.demo.programs.ShaderProgram.java
com.opengles3.demo.programs.TextureShaderProgram.java
com.opengles3.demo.tools.Debug.java
com.opengles3.demo.tools.Tools.java