title: Open gl draw turns white after one frame drawn
body: <p>I am newbie in Opengl. I used the following example from Qt as a start in Opengl as I know Qt.<br>
  <a href="http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-squircle-cpp.html" rel="nofollow">http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-squircle-cpp.html</a>  </p>
  
  <p>I replaced the paint function of the program with following code with an intent to draw chess board pattern. Following is not the paint or render function of my program</p>
  
  <pre><code>paint()
  {
  if (!m_program) {
      initializeOpenGLFunctions();
  
      m_program = new QOpenGLShaderProgram();
      m_program-&gt;addShaderFromSourceCode(QOpenGLShader::Vertex,
                                         "attribute highp vec4 vertices;"
                                         "varying highp vec2 coords;"
                                         "void main() {"
                                         "    gl_Position = vertices;"
                                         "    coords = vertices.xy;"
                                         "}");
      m_program-&gt;addShaderFromSourceCode(QOpenGLShader::Fragment,
                                         "uniform lowp float t;"
                                         "varying highp vec2 coords;"
                                         "void main() {"
                                         "    lowp float i = 1. - (pow(abs(coords.x), 4.) + pow(abs(coords.y), 4.));"
                                         "    i = smoothstep(t - 0.8, t + 0.8, i);"
                                         "    i = floor(i * 20.) / 20.;"
                                         "    gl_FragColor = vec4(coords * .5 + .5, i, i);"
                                         "}");
  
      m_program-&gt;bindAttributeLocation("vertices", 0);
      m_program-&gt;link();
  }
  
  auto width = static_cast&lt;float&gt;(m_viewportSize.width());
  auto height = static_cast&lt;float&gt;(m_viewportSize.height());
  auto a = 2.f / width;
  auto b = 2.f / height;
  std::vector&lt;float&gt; matrix =
  {
       a , 0, 0, 0,
       0, -b, 0, 0,
       0,  0, 1, 0,
      -1,  1, 0, 1
  };
  
  // Set the projection matrix
  glMatrixMode(GL_PROJECTION);
  glLoadMatrixf(matrix.data());
  
  // Initialize vertices:
  std::vector&lt;float&gt; vertices =
  {
      0,     0,
      0,     height,
      width, height,
      width, 0
  };
  
  // Initialize colors
  std::vector&lt;float&gt; colors =
  {
      1, 0, 0,
      0, 1, 0,
      0, 0, 1,
      0, 1, 1
  };
  
  // Initialize texture virtice
  std::vector&lt;float&gt; texCoord =
  {
      0, 0,
      0, 1,
      1, 1,
      1, 0
  };
  
  // Create texture: simple chess board 8x8
  auto numRows = 8u;
  auto numCols = 8u;
  auto character = 172u;
  auto remain = 255u - character;
  std::vector&lt;unsigned char&gt; texture(numCols * numRows);
  for (auto i = 0u; i &lt; texture.size(); ++i)
      texture[i] = ((i + (i / numCols)) % 2) * remain + character;
  
  // Upload to GPU texture
  unsigned textureID;
  glGenTextures(1, &amp;textureID);
  glBindTexture(GL_TEXTURE_2D, textureID);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, numCols, numRows, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texture.data());
  
  // Initialize clear colors
  glClearColor(0.f, 0.f, 0.f, 1.f);
  // Activate necessary states
  glEnable(GL_TEXTURE_2D);
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glVertexPointer(2, GL_FLOAT, 0, vertices.data());
  glColorPointer(3, GL_FLOAT, 0, colors.data());
  glTexCoordPointer(2, GL_FLOAT, 0, texCoord.data());
  
  // render
  glClear(GL_COLOR_BUFFER_BIT);
  glDrawArrays(GL_QUADS, 0, 4);
  
  m_program-&gt;disableAttributeArray(0);
  m_program-&gt;release();
  m_window-&gt;resetOpenGLState();
  }
  </code></pre>
  
  <p>The chess board is drawn. But its drawn for a split second &amp; then the screen turns fully white. I want to draw the chess board pattern continiously with each frame draw. 
  Can someone pls point out what might be going wrong ?</p>