I am trying to use raw OpenGL with Qt and I am trying to strictly use the Qt API to do so. I am using OpenGL 2.1 because that is our hardware limitation. I am able to build without any errors but the first instance of a gl* fails. The first opengl function is glGetIntergv(GL_ENUM, int*) and through the debugger I am able to see that is where I crash first. I am just curious if anyone can see what I am missing because my guess is I have to do something special to initialize these functions (which I thought initializeOpenGLFunctions() accomplished). Any help or direction would be great!!

I am subclassing with QOpenGLFunctions_2_1 like so:
Qt Code:
  1. class GLWidget : public QGLWidget, protected QOpenGLFunctions_2_1
To copy to clipboard, switch view to plain text mode 

These are the relevant source file functions
Qt Code:
  1. GLWidget::GLWidget(QWidget *parent) :
  2. QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::Rgba | QGL::DepthBuffer),parent)
  3. {
  4. createActions();
  5. createMenus();
  6. }
  7.  
  8. void GLWidget::initializeGL()
  9. {
  10. initializeOpenGLFunctions();
  11.  
  12. pixels[0] = pixels[1] = pixels[2] = NULL;
  13. frameGood[0] = frameGood[1] = frameGood[2] = GL_FALSE;
  14.  
  15. qDebug() << "Pixel Buffer Object Demo";
  16.  
  17. QGLFunctions funcs(QGLContext::currentContext());
  18. bool isNonPowerTwo = funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures);
  19.  
  20. // // Make sure required functionality is available!
  21. // if (!GLEE_VERSION_2_1 && !GLEE_ARB_pixel_buffer_object)
  22. // {
  23. // qDebug() << "PBO extension is not available!";
  24. //// fprintf(stderr, "PBO extension is not available!\n");
  25. // Sleep(2000);
  26. // exit(0);
  27. // }
  28.  
  29. if (isNonPowerTwo)
  30. {
  31. npotTexturesAvailable = GL_TRUE;
  32. }
  33. else
  34. {
  35. qDebug() << "GL_ARB_texture_non_power_of_two extension is not available!";
  36. qDebug() << "Only portion of window will be used for rendering";
  37. }
  38.  
  39. // Check for minimum resources
  40. GLint intVal = 0;
  41. glGetIntegerv(GL_MAX_TEXTURE_UNITS, &intVal);
  42.  
  43. if (intVal < 3)
  44. {
  45. qDebug() << "Fewer than 3 texture units available!";
  46. Sleep(2000);
  47. exit(0);
  48. }
  49. glGetIntegerv(GL_MAX_TEXTURE_SIZE, &intVal);
  50. if (intVal < 1024)
  51. {
  52. qDebug() << "1024x1024 texture not supported!";
  53. Sleep(2000);
  54. exit(0);
  55. }
  56.  
  57. qDebug() << "Controls:";
  58. qDebug() << "\tRight-click for menu";
  59. qDebug() << "\tb\tToggle motion blur";
  60. qDebug() << "\tp\tToggle PBO usage";
  61. qDebug() << "\tarrows\t+/- rotation speed";
  62. qDebug() << "\tq\t\tExit demo";
  63.  
  64. // Colors
  65. glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
  66. glColor4f(0.0f, 0.0f, 0.0f, 1.0f );
  67.  
  68. // Texture matrix is the only one we'll change
  69. glMatrixMode(GL_TEXTURE);
  70.  
  71. // Set up textures
  72. SetupTextures();
  73. }
To copy to clipboard, switch view to plain text mode 

And as stated above the first call to glGetIntergv is what fails . Any ideas?