Android Open Source - OpenGL-es3-android 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   w w  w  .j  a v a2s. c  om*/
import android.content.Context;
import android.opengl.GLES30;
import android.util.Log;

import com.opengles3.demo.tools.Tools;

public abstract class ShaderProgram {
  //Uniforms
  protected static final String U_MATRIX = "u_Matrix";
  protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
  protected static final String U_COLOR = "u_Color";
  //Attributes
  protected static final String A_POSITION = "a_Position";
  protected static final String A_COLOR = "a_Color";
  protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
  
  protected final int program;
  
  protected ShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId){
    String vertexShaderSource = Tools.textFromRawRes(context, vertexShaderResourceId);
    String fragmentShaderSource = Tools.textFromRawRes(context, fragmentShaderResourceId);
    program = Tools.buildProgram(vertexShaderSource, fragmentShaderSource);
    
  }
  public void useProgram(){
    GLES30.glUseProgram(program);
  }
}




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