title: OpenGL ortho, perspective and frustum projections
body: <p>45I am trying to understand OpenGL projections on a single point. I am using QGLWidget for rendering context and QMatrix4x4 for projection matrix. Here is the draw function</p>
  
  <pre><code>    attribute vec4 vPosition;      
          uniform mat4 projection;  
          uniform mat4 modelView; 
          void main()
          {
            gl_Position = projection* vPosition;
          }       
  
          void OpenGLView::Draw()
          {
             glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
      glUseProgram(programObject);
      glViewport(0, 0, width(), height());
  
      qreal aspect = (qreal)800 / ((qreal)600);
      const qreal zNear = 3.0f, zFar = 7.0f, fov = 45.0f;
  
      QMatrix4x4 projection;
      projection.setToIdentity();
      projection.ortho(-1.0f,1.0f,-1.0f,1.0f,-20.0f,20.0f);
     // projection.frustum(-1.0f,1.0f,-1.0f,1.0f,-20.0f,20.0f);
     // projection.perspective(fov,aspect,zNear, zFar);
  
     position.setToIdentity();
     position.translate(0.0f, 0.0f, -5.0f);
     position.rotate(0,0,0, 0);
  
      QMatrix4x4 mvpMatrix =   projection * position;
  
      for (int r=0; r&lt;4; r++)
          for (int c=0; c&lt;4; c++)
              tempMat[r][c] = mvpMatrix.constData()[ r*4 + c ];
  
      glUniformMatrix4fv(projection, 1, GL_FALSE, (float*)&amp;tempMat[0][0]);
  
      //Draw point at 0,0
      GLfloat f_RefPoint[2];
      glUniform4f(color,1, 0,1,1);
      glPointSize(15);
      f_RefPoint[0] = 0;
      f_RefPoint[1] = 0;
      glEnableVertexAttribArray(vertexLoc);
      glVertexAttribPointer(vertexLoc, 2, GL_FLOAT, 0, 0, f_RefPoint);
      glDrawArrays (GL_POINTS, 0, 1);            
          }
  </code></pre>
  
  <p>Observations:</p>
  
  <p>1) projection.ortho: the point rendered on the window and translating the point with different z-axis value has no effect </p>
  
  <p>2) projection.frustum: the point is drawn on the windown only the point is translated as translate(0.0f, 0.0f, -20.0f)</p>
  
  <p>3) projection.perspective: the point is never rendered on the screen.</p>
  
  <p>Could someone help me understand this behaviour?</p>