Android Open Source - OpenGL-es3-android Color Shader Program






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.programs;
/*from ww  w  .  j  a  va  2 s. co m*/
import com.example.opengl_es_3_demo.R;

import android.content.Context;
import android.opengl.GLES30;
import android.util.Log;

public class ColorShaderProgram extends ShaderProgram {
  //Uniform locations
  private final int uMatrixLocation;
  private final int uColorLocation;
  
  //Attribute locations
  private final int aPositionLocation;
  
  public ColorShaderProgram(Context context){
    super(context, R.raw.color_vertex_shader,R.raw.color_fragment_shader);
    
    uMatrixLocation = GLES30.glGetUniformLocation(program, U_MATRIX);
    uColorLocation = GLES30.glGetUniformLocation(program, U_COLOR);
    
    aPositionLocation = GLES30.glGetAttribLocation(program, A_POSITION);
  }
  public void setUniforms(float[] matrix, float r, float g, float b){
    //pass the matrix to shader program
    GLES30.glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0);
    GLES30.glUniform4f(uColorLocation, r, g, b, 1f);
    
  }
  public int getPositionAttributeLocation(){
    return aPositionLocation;
  }
}




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