title: Using latest OpenGL functions across classes in Qt 5.4
body: <p>I posted a question earlier on how to get OpenGL working on Qt, but now I want to be able to use the latest functions OpenGL has for use. Before Qt, I was using glew; but Qt is saying that glew is conflicting with its QtOpenGL header file. I looked into QGLWidget and QGLFunctions, but to be frank I'm confused as to what I should really be doing in order to simply access OpenGL's functions.</p>
  
  <p>Now, I got Qt 5.4 using Qt Creator 3.3.0 and am utilising the new QOpenGLWidget; however lack of guidance in how it ought to be used throws me off a little: the Qt documentation is there and does help, but it only demonstrates how to instantiate it, rather than utilise it in other locations of the program. I understand that this QOpenGLWidget functions similar to QGLWidget. Qt details that I should be inheriting from it; however I am not instantiating an OpenGL context within the class it wants to use OpenGL functions; that happens in the class 'glWidget', which inherits from QOpenGLWidget.</p>
  
  <p>For example, take this excerpt from one of my classes that uses OpenGL code:</p>
  
  <pre><code>void Mesh::init()
  {
      pNumIndices = pIndices.size();
  
      glGenVertexArrays(1, &amp;pVAO);
      glGenBuffers(1, &amp;pVertexBuffer);
      glGenBuffers(1, &amp;pIndexBuffer);
      glBindVertexArray(pVAO);
  
      glBindBuffer(GL_ARRAY_BUFFER, pVertexBuffer);
      glBufferData(GL_ARRAY_BUFFER, pVertices.size() * sizeof(Vertex),
                   &amp;pVertices[0], GL_STATIC_DRAW);
  
      // etc..
  }
  </code></pre>
  
  <p>Mesh is a class that doesn't inherit from anything. Originally, it only used glew so that it can get declarations of OpenGL functions; it didn't need to know whether they were valid or not, since that is glew's job. Then in the mainApp class, I would be instantiating glew. I also understand that there is also a QOpenGLFunctions class which somewhat functions similar to that of glew, but with all these GL classes it's blatantly confusing to know what to use. What's more is that I tried look for glGenVertexArrays(..) but it's not found in QOpenGLBuffer, QOpenGLFunctions or QOpenGLWidget; and as far I'm aware, as of OpenGL 4.5 it's still part of the spec; but my graphics drivers do not use OpenGL 4.5, so I use OpenGL 4.3 instead. Suffice it to say that I'm willing to abandon glew to adopt Qt's own approach to calling OpenGL functions. </p>
  
  <p><strong>In a program where various classes are using OpenGL functions, how can I utilise Qt to be able to call them without the use of glew?</strong> Mesh is one of those classes that doesn't instantiate OpenGL, but merely uses the functions thereof.</p>
  
  <p>Just so people know, I have been using Qt for some time (not enough though!) and do enjoy Qt; but I do need to know how I can use Qt in conjunction with OpenGL to continue development. Most tutorials out there still use pre-5.4 stuff.</p>