Hi,

I'm using Qt 5.0 (I checked on the forums if there were similar issues, I tried them all, but they were related to Qt 4.x).
My problem is that my QGLWidget subclass is black even though I'm clearing it to green.

GLIntercept reports similar errors for all of my GL calls:
Function glClearColor is being called before context creation
Call to glClearColor made outside of context/init


Here is my code:

HEADER FILE
Qt Code:
  1. #include <QtOpenGL>
  2.  
  3. #ifndef GLWIDGET_H
  4. #define GLWIDGET_H
  5.  
  6. class GLWidget : public QGLWidget
  7. {
  8. Q_OBJECT
  9. protected:
  10. virtual void initializeGL();
  11. virtual void resizeGL(int w, int h);
  12. virtual void paintGL();
  13. public:
  14. GLWidget();
  15. };
  16.  
  17. #endif
To copy to clipboard, switch view to plain text mode 
CPP FILE
Qt Code:
  1. #include "stdafx.h";
  2.  
  3. GLWidget::GLWidget()
  4. {
  5. setFixedWidth(256);
  6. setFixedHeight(256);
  7. }
  8.  
  9. void GLWidget::initializeGL()
  10. {
  11. glClearColor(0.0, 1.0, 0.0, 1.0);
  12. glEnable(GL_DEPTH_TEST);
  13. glDisable(GL_CULL_FACE);
  14. }
  15.  
  16. void GLWidget::resizeGL(int w, int h)
  17. {
  18. glViewport(0, 0, (GLint)w, (GLint)h);
  19. }
  20.  
  21. void GLWidget::paintGL()
  22. {
  23. glClear(GL_COLOR_BUFFER_BIT);
  24. }
To copy to clipboard, switch view to plain text mode 

I might as well mention that I use the precompiled Qt binaries for Visual Studio.

Can somebody please advise me on what to do to fix this?
Thanks in advance!