title: Android NDK GLES 2.0 Nothing Drawing
body: <p>I am trying to Draw with GLES 2.0 through the NDK, doing everything except creating the surface in C++, but nothing is drawing on the screen...And I can't figure out why.</p>
  
  <p>I have tried/verified many different things and am still at a loss.</p>
  
  <p>my last few guesses are these:</p>
  
  <p>my textures are somehow now compatible with the screen:</p>
  
  <p>I load textures like this:</p>
  
  <pre><code>glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image-&gt;GetPixels());
  </code></pre>
  
  <p>but the default GLSurfaceView format is RGB_565</p>
  
  <p>I tried this with no success:</p>
  
  <pre><code>mGLView.getHolder().setFormat(PixelFormat.RGBA_8888);
  </code></pre>
  
  <p>and also this:</p>
  
  <pre><code>glTexImage2D(GL_TEXTURE_2D, 0, GL_UNSIGNED_SHORT_5_6_5, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image-&gt;GetPixels());
  </code></pre>
  
  <p>could texture format have anything to do with the problem? I have no reference because the Android SDK abstracts this away completely..</p>
  
  <p>this is the shader I am using:</p>
  
  <pre><code>const char *vertexShader = "\
      uniform mat4 uMtxProjection; \
      uniform mat4 uMtxModelView; \
      attribute vec2 aPosition; \
      attribute vec2 aTexCoord; \
      varying vec2 vTexCoord; \
      void main() \
      { \
          gl_Position = uMtxProjection * (uMtxModelView * vec4(aPosition.x, aPosition.y, 0.0, 1.0)); \
          vTexCoord = aTexCoord; \
      }";
  
  const char *fragmentShader = "\
      precision mediump float; \
      varying vec2 vTexCoord; \
      uniform sampler2D sTexture; \
      void main() \
      { \
          gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); \
      }";
  </code></pre>
  
  <p>After further testing, and removing the texture(filling triangle with only red) I can see a distorted red box flash exactly 3 times each time the app is run, then the screen goes blank =/</p>
  
  <p>and the ortho matrix:</p>
  
  <pre><code>Mat4 Ortho2D(float left, float right, float bottom, T top, float zNear, float zFar)
  {
      float dx = right - left;
      float dy = top - bottom;
      float dz = zFar - zNear;
  
      // avoid division by zero
      float tx = (dx != 0) ? -(right + left) / dx : 0;
      float ty = (dy != 0) ? -(top + bottom) / dy : 0;
      float tz = (dz != 0) ? -(zFar + zNear) / dz : 0;
  
      return Mat4(2.0f / dx, 0,           0,          tx,
                  0,          2.0f / dy, 0,           ty,
                  0,          0,          -2.0f / dz, tz,
                  0,          0,          0,          1);
  }
  </code></pre>