title: LibGDX Shader does not work
body: <p>I am trying to render independent Cube Mesh pieces using LibGDX, in order to make them independent I created a Cube class for mesh encapsulation. here is the Code I wrote</p>
  
  <pre><code>import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.graphics.*;
  import com.badlogic.gdx.graphics.glutils.ShaderProgram;
  import com.badlogic.gdx.math.Matrix4;
  
  public class Cube {
  
  private static final String VERTEX_SHADER =
          "attribute vec4 position;\n" +
                  "attribute vec4 color;\n" +
                  "uniform mat4 projection;\n" +
                  "uniform mat4 transformation;\n" +
                  "varying vec4 vColor;\n" +
                  "void main(){\n" +
                  "   vColor = color;\n" +
                  "   gl_Position = projection * transformation * position;\n" +
                  "}";
  
  private static final String FRAGMENT_SHADER =
          "#ifdef GL_ES\n" +
                  "precision mediump float;\n" +
                  "#endif\n" +
                  "varying vec4 vColor;\n" +
                  "void main(){\n" +
                  "   gl_FragColor = vColor;\n" +
                  "}";
  
  private static final float[] vertxs = {
          //0            1
          -1f, -1f, -1f, 1f, -1f, -1f,
          //2            3
          1f,  1f,  -1f, -1f, 1f, -1f,
          //4           5
          -1f, -1f, 1f, 1f, -1f, 1f,
          //6           7
          1f,  1f,  1f, -1f, 1f, 1f,
  };
  
  private static Matrix4 projection = new Matrix4();
  static{
      final float aspect = Gdx.graphics.getWidth() / (float) Gdx.graphics.getHeight();
      projection.setToProjection(1.0f, 20.0f, 60.0f, aspect);
  }
  
  private static final short[] indicies = {
      1, 3, 0, 1, 2, 3, //front
      1, 6, 2, 1, 5, 6, //right
      2, 7, 3, 1, 6, 7, //top
      4, 7, 6, 4, 5, 6, //back
      7, 4, 3, 4, 3, 0, //left
      0, 4, 1, 4, 5, 1  //bottom
  };
  
  private static ShaderProgram createProgram() {
  
      ShaderProgram.pedantic = false;
      final ShaderProgram program = new ShaderProgram(VERTEX_SHADER, FRAGMENT_SHADER);
      final String log = program.getLog();
      if (!program.isCompiled()) {
          System.out.println("Failed to compile Cube Shader Program");
      }
      if (log != null &amp;&amp; !log.isEmpty()) {
          System.out.println(log);
      }
      return program;
  }
  
  public static final ShaderProgram program = createProgram();
  
  
  private Mesh mesh;
  private Color color;
  private Matrix4 transform;
  
  public Cube(final Color color){
      this.color = color;
      mesh = new Mesh(true, 24, 36,
              new VertexAttribute(VertexAttributes.Usage.Position, 3, "position"),
              new VertexAttribute(VertexAttributes.Usage.ColorUnpacked, 3, "color"));
      mesh.setVertices(vertxs).setIndices(indicies);
      mesh.getVertexAttribute(VertexAttributes.Usage.Position).alias = "position";
  
      transform = new Matrix4();
  }
  
  public void addTransform(final Matrix4 additionalTrans){
      transform.mul(additionalTrans);
  }
  
  public Matrix4 getTransform(){
      return transform;
  }
  
  public Color getColor() {
      return color;
  }
  
  public void render(){
      Gdx.gl20.glDepthMask(true);
      Gdx.gl20.glEnable(GL20.GL_BLEND);
      Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_CONSTANT_ALPHA);
  
      program.begin();
      program.setUniform4fv("projection", projection.getValues(), 0, projection.getValues().length);
      program.setUniform4fv("transformation", transform.getValues(), 0, transform.getValues().length);
      program.setAttributef("color", color.r, color.g, color.b, color.a);
      mesh.render(program, GL20.GL_TRIANGLES);
      program.end();
  }
  
  }
  </code></pre>
  
  <p>and the invocation class </p>
  
  <pre><code>import com.badlogic.gdx.ApplicationAdapter;
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.graphics.Color;
  import com.badlogic.gdx.graphics.GL20;
  
  public class MeshStudies extends ApplicationAdapter {
  private Cube cube;
  
  @Override
  public void create() {
      cube = new Cube(Color.BLUE);
  }
  
  @Override
  public void render() {
      Gdx.gl20.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      Gdx.gl20.glClearColor(0.5f, 0.3f, 0.8f, 1f);
      Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
      cube.render();
  }
  }
  </code></pre>
  
  <p>When I run this code, I got a black blank screen without any Shader compilation error or hint.</p>
  
  <p>Please can someone help me to figure out what went wrong? and it would be better if any experienced LibGDX user can tell me if there is any more efficient way to design this program (saving transformation matrix in each Cube class is necessary) but did this code actually render every thing efficiently in OpenGL perspective?</p>
  
  <p>Thanks</p>