title: Resolving OpenGL functions using glew in QT
body: <p><strong>Its been 17 days</strong> I'm struggling to write a simple program in OpenGL using QT, but all tutorials searched on Google are failed.
  I'v compiled my QT 5.0.1 with -opengl desktop using msvc2010 to make desktop opengl default.</p>
  
  <p>I'v read tutorial by Sean Harmer, but it is depended on QT to resolve opengl functions.</p>
  
  <p>According to some people, it is not possible to use glew in QT, as QT's built in libraries prevent glew from including its headers, but according to Sean Harmer <a href="http://www.kdab.com/opengl-in-qt-5-1-part-1/" rel="noreferrer"> HERE </a>, it is possible (but it is not explained there how).</p>
  
  <p>Even using QGLWidget I'm not able to use OpenGL extensions.</p>
  
  <p>Now all I want is to use all OpenGL functions separate and all windowing functions from QT separate, i.e. no interference in OpenGL by QT.</p>
  
  <p>If anybody explain me the procedure with simple triangle example and using any extension, I'l be so thankful..</p>
  
  <p>I'v used glew library in my project and #included glew.h in very start of my program, but when compiled it gives error:
  glwidget.obj:-1: error: LNK2001: unresolved external symbol <strong>imp_</strong>_glewGenVertexArrays</p>
  
  <p>My .pro file</p>
  
  <pre><code>QT       += core gui opengl
  
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
  TARGET = Trial
  TEMPLATE = app
  
  SOURCES += main.cpp\
          mainwindow.cpp \
      glwidget.cpp
  
  HEADERS  += mainwindow.h \
      glwidget.h
  
  FORMS    += mainwindow.ui
  
  RESOURCES += \
      resources.qrc
  win32: LIBS += -L$$PWD/../../../../../OpenGL/glew-1.9.0/lib/ -lglew32s
  
  INCLUDEPATH += $$PWD/../../../../../OpenGL/glew-1.9.0/include
  DEPENDPATH += $$PWD/../../../../../OpenGL/glew-1.9.0/include
  
  win32: PRE_TARGETDEPS += $$PWD/../../../../../OpenGL/glew-1.9.0/lib/glew32s.lib
  </code></pre>
  
  <p>Output by glewInfo :
  GLEW version 1.9.0
  Reporting capabilities of pixelformat 1
  Running on a GeForce GT 540M/PCIe/SSE2 from NVIDIA Corporation
  OpenGL version 4.3.0 is supported</p>
  
  <pre><code>void GLWidget::initializeGL()
  {
      GLenum err = glewInit();
      if(err != GLEW_OK)
      {
          printf("%s",glewGetErrorString(err));
      }
  
      glEnable(GL_DEPTH_TEST);
      qglClearColor(QColor(Qt::red));
  
      shaderProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/vertexShader.vsh");
      shaderProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/fragmentShader.fsh");
      shaderProgram.link();
      shaderProgram.bind();
  
      const GLubyte *oglVersion = glGetString(GL_VERSION);
      printf( "%s\n",oglVersion );
  
      GLfloat vertices[3][3] ={{ -0.5, -0.5, -1 },
                  { 0,    0.5,    -1},
                      { 0.5,  -0.5,   -1}};
      vertexArray.create();
      vertexArray.setUsagePattern(QOpenGLBuffer::StaticDraw);
      vertexArray.allocate( vertices, 3 * 3 * sizeof( GLfloat ) );
      vertexArray.bind();
      shaderProgram.setAttributeBuffer( "vVertex", GL_FLOAT, 0, 3 );
      shaderProgram.enableAttributeArray( "vVertex" );
  
      GLuint arr[5];
      glGenBuffers(5,arr);
  }
  </code></pre>