title: How do you implement glOrtho for opengles 2.0? With or without tx,ty,tz values from the glOrtho spec?
body: <p>Im trying to implement my own glOtho function from the opengles docs <a href="http://www.khronos.org/opengles/documentation/opengles1_0/html/glOrtho.html" rel="noreferrer">http://www.khronos.org/opengles/documentation/opengles1_0/html/glOrtho.html</a><br>
  to modify a Projection matrix in my vertex shader. It's currently not working properly as I see my simple triangles vertices out of place. Can you please check the code below and see if i'm doing things wrong.</p>
  
  <p>I've tried setting tx,ty and tz to 0 and that seems to make it render properly. Any ideas why would this be so?</p>
  
  <pre><code>void ES2Renderer::_applyOrtho(float left, float right,float bottom, float top,float near, float far) const{ 
  
          float a = 2.0f / (right - left);
          float b = 2.0f / (top - bottom);
          float c = -2.0f / (far - near);
  
          float tx = - (right + left)/(right - left);
          float ty = - (top + bottom)/(top - bottom);
          float tz = - (far + near)/(far - near);
  
          float ortho[16] = {
              a, 0, 0, tx,
              0, b, 0, ty,
              0, 0, c, tz,
              0, 0, 0, 1
          };
  
  
          GLint projectionUniform = glGetUniformLocation(_shaderProgram, "Projection");
          glUniformMatrix4fv(projectionUniform, 1, 0, &amp;ortho[0]);
  
  }
  
  void ES2Renderer::_renderScene()const{
      GLfloat vVertices[] = {
          0.0f,  5.0f, 0.0f,  
          -5.0f, -5.0f, 0.0f,
          5.0f, -5.0f,  0.0f};
  
      GLuint positionAttribute = glGetAttribLocation(_shaderProgram, "Position");
  
      glEnableVertexAttribArray(positionAttribute);
  
  
      glVertexAttribPointer(positionAttribute, 3, GL_FLOAT, GL_FALSE, 0, vVertices);  
      glDrawArrays(GL_TRIANGLES, 0, 3);       
  
  
      glDisableVertexAttribArray(positionAttribute);
  
  }
  </code></pre>
  
  <p>Vert shader</p>
  
  <pre><code>attribute vec4 Position;
  uniform mat4 Projection;
  void main(void){
      gl_Position = Projection*Position;
  }
  </code></pre>
  
  <p><strong>Solution</strong>
  From Nicols answer below I modifed my matrix as so and it seemed render properly</p>
  
  <pre><code>float ortho[16] = {
      a, 0, 0, 0,
      0, b, 0, 0,
      0, 0, c, 0,
      tx, ty, tz, 1
  };
  </code></pre>
  
  <p><strong>Important note</strong>
  You cannot use GL_TRUE for transpose argument for glUniform as below. opengles does not support it. it must be GL_FALSE </p>
  
  <pre><code>glUniformMatrix4fv(projectionUniform, 1, GL_TRUE, &amp;ortho[0]);
  </code></pre>
  
  <p>From <a href="http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml" rel="noreferrer">http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml</a></p>
  
  <p>transpose
  Specifies whether to transpose the matrix as the values are loaded into the uniform variable. Must be GL_FALSE.</p>