title: Transformations from pixels to NDC
body: <p>Let's say that my screen is (<code>800 * 600</code>) and I have a Quad (2D) drawn with the following vertices positions using <strong>Triangle_Strip</strong> (in NDC) :</p>
  <pre><code>float[] vertices = {-0.2f,0.2f,-0.2f,-0.2f,0.2f,0.2f,0.2f,-0.2f};
  </code></pre>
  <p>And I set up my Transformation Matrix in this way :</p>
  <pre><code>Vector2f position = new Vector2f(0,0);
  Vector2f size = new Vector2f(1.0f,1.0f);
  
  Matrix4f tranMatrix = new Matrix4f();
  tranMatrix.setIdentity();
  Matrix4f.translate(position, tranMatrix, tranMatrix);
  Matrix4f.scale(new Vector3f(size.x, size.y, 1f), tranMatrix, tranMatrix);
  </code></pre>
  <p>And my vertex Shader :</p>
  <pre><code>#version 150 core
  
  in vec2 in_Position;
  
  uniform mat4 transMatrix;
  
  void main(void) {
  
  gl_Position = transMatrix * vec4(in_Position,0,1.0);
  
  }
  </code></pre>
  <p>My question is, which formula should I use to modify the transformations of my quad with coordinates (in Pixels) ?</p>
  <p>For example :</p>
  <ul>
  <li><p><strong>set Scale</strong> : (50px, 50px)  =&gt; <code>Vector2f(width,height)</code></p>
  </li>
  <li><p><strong>set Position</strong> : (100px, 100px) =&gt; <code>Vector2f(x,y)</code></p>
  </li>
  </ul>
  <p>To better understand, I would create a function to convert my Pixels data to NDCs to send them next to the vertex shader. I was advised to use an Orthographic projection but I don't know how to create it correctly and as you can see in my vertex shader I don't use any projection matrix.</p>
  <p>Here is a topic similar to mine but not very clear - <a href="https://stackoverflow.com/q/33897004/6722667">Transform to NDC, calculate and transform back to worldspace</a></p>
  <hr />
  <p><strong>EDIT:</strong></p>
  <p>I created my orthographic projection matrix by following the formula but
  nothing seems to appear, here is how I proceeded :</p>
  <pre><code>public static Matrix4f glOrtho(float left, float right, float bottom, float top, float near, float far){
      
      final Matrix4f matrix = new Matrix4f();
      matrix.setIdentity();
  
      matrix.m00 = 2.0f / (right - left);
      matrix.m01 = 0;
      matrix.m02 = 0;
      matrix.m03 = 0;
      
      matrix.m10 = 0;
      matrix.m11 = 2.0f / (top - bottom);
      matrix.m12 = 0;
      matrix.m13 = 0;
      
      matrix.m20 = 0;
      matrix.m21 = 0;
      matrix.m22 = -2.0f / (far - near);
      matrix.m23 = 0;
      
      matrix.m30 = -(right+left)/(right-left);
      matrix.m31 = -(top+bottom)/(top-bottom);
      matrix.m32 = -(far+near)/(far-near);
      matrix.m33 = 1;
  
      return matrix;
  }
  </code></pre>
  <p>I then included my matrix in the vertex shader</p>
  <pre><code>#version 140
  
  in vec2 position;
  
  uniform mat4 projMatrix;
  
  void main(void){
  
  gl_Position = projMatrix * vec4(position,0.0,1.0);
  
  }
  </code></pre>
  <p>What did I miss ?</p>