title: Opengl rendering quad
body: <p>For some reason, the quad that I'm rendering doesn't show and it only renders a black screen. I've checked the code multiple times and couldn't find the problem maybe someone can see what I don't see!</p>
  
  <p>The purpose is to have a quad that follows the camera, right now I just want to show the quad with a single color, but all I get is a black screen. I am using <code>QOpenGLWindow</code> and <code>QOpenGLFunctions</code>.</p>
  
  <pre><code>void CSLFWindow::renderQuad()
  {
      float x0 = -(float)1.f, y0 = -(float)1.f;
      float x1 = (float)1.f, y1 = (float)1.f;
  
      const QVector3D vertices[4] = {
          QVector3D( x0, y0, 0.0f),
          QVector3D( x0, y1, 0.0f),
          QVector3D( x1, y1, 0.0f),
          QVector3D( x1, y0, 0.0f)
      };
  
      const QVector3D normals[4] = {
          QVector3D(0.0f, 0.0f,1.0f),
          QVector3D(0.0f, 0.0f,1.0f),
          QVector3D(0.0f, 0.0f,1.0f),
          QVector3D(0.0f, 0.0f,1.0f)
      };
      const QVector2D texcoords[4] = {
          QVector2D(0.0f, 1.0f),
          QVector2D(0.0f, 0.0f),
          QVector2D(1.0f, 0.0f),
          QVector2D(1.0f, 1.0f)
      };
  
        const unsigned int indices[4] = { 3, 2, 1, 0 };
  
      m_shaderProgram.enableAttributeArray("vVertices");
      m_shaderProgram.enableAttributeArray("vTexCoords");
      m_shaderProgram.enableAttributeArray("vNormals");
  
      m_shaderProgram.setAttributeArray("vVertices", vertices);
      m_shaderProgram.setAttributeArray("vTexCoords", texcoords);
      m_shaderProgram.setAttributeArray("vNormals", normals);
  
      glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, indices);
  
      m_shaderProgram.disableAttributeArray("vVertices");
      m_shaderProgram.disableAttributeArray("vTexCoords");
      m_shaderProgram.disableAttributeArray("vNormals");
  }
  </code></pre>
  
  <p>and the rendering: </p>
  
  <pre><code>void CSLFWindow::paintGL()
  {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
        m_shaderProgram.bind();
  
        m_model.setToIdentity();
        m_view = m_camera.toMatrix();
        QMatrix4x4 modelMatrix = m_model ;
        QMatrix4x4 modelViewMatrix = m_view * modelMatrix;
  
  
        QMatrix4x4 mvp = m_projection * modelViewMatrix;
  
        m_shaderProgram.setUniformValue("MV", modelViewMatrix);
  
        m_shaderProgram.setUniformValue("MVP", mvp);           
        m_shaderProgram.setUniformValue("P", m_projection);      
  
        renderQuad();
        m_shaderProgram.release();
  }
  </code></pre>
  
  <p>I'm setting the projection matrix as: </p>
  
  <pre><code>m_view.setToIdentity();
  float aspect = h / w;
  m_projection.setToIdentity();
  m_projection.perspective(
      m_fov,          
      aspect,         
      0.1f,           
      1000.0f);       
  </code></pre>
  
  <p>here are my camera parameters: </p>
  
  <pre><code>m_cameraPos   = QVector3D(0.0f, 0.0f,  3.0f);
  m_cameraFront = QVector3D(0.0f, 0.0f,  -1.0f);
  m_cameraUp    = QVector3D(0.0f, 1.0f,  0.0f); 
  
  QMatrix4x4 toMatrix()
  {
       QMatrix4x4 vMatrix;
       vMatrix.setToIdentity();
       vMatrix.lookAt(m_cameraPos,  QVector3D(0.0f, 0.0f,  0.0f), 
                      m_cameraUp);
  
       return vMatrix;
   }
  </code></pre>
  
  <p>and here is my vertex shader: </p>
  
  <pre><code>#version 330 core
  
  layout (location = 0)in vec3 vVertices;
  layout (location = 1)in vec2 vTexCoords;
  layout (location = 2)in vec3 vNormals;
  
  uniform mat4 MV;
  uniform mat4 MVP;
  uniform mat4 P;
  
  out vec2 FragTexCoord;
  out vec3 FragNormals;
  
  void main()
  {
     FragTexCoord = vTexCoords;
     FragNormals = vNormals;
  
     gl_Position = MVP * vec4(vVertices,1);
  }
  </code></pre>
  
  <p>and my fragment shader:</p>
  
  <pre><code>#version 330 core
  
  out vec4 fragmentColor;
  
  in vec2 FragTexCoord;
  in vec3 FragNormals;
  
  void main()
  {
      fragmentColor = vec4(1.0,1.0,1.0,1.0);
  }
  </code></pre>