Qt 5.6, Windows 7 - getting OpenGL errors (1286, 1280, "Unsupported framebuffer format") in qopenglframebufferobject.cpp
-
wrote on 7 Aug 2016, 14:21 last edited by Arun V 8 Jul 2016, 17:27
Hi,
The program I am working on uses QOpenGLWidget to render a 2D image. However, I keep getting OpenGL errors in qopenglframebufferobject.cpp (as described below). The fact that I am relatively new to OpenGL doesn't help matters either!
I use Qt 5.6.0, and OpenGL 2.1.0. OS is Windows 7, display adapter is Intel HD graphics.
A minimal program that reproduces the error is as follows:
#include <GL/glew.h> #include <QtWidgets/QApplication> #include <QOpenGLWidget> #include <QSurfaceFormat> #include <GL/GLU.h> #include <iostream> using namespace std; class OGLErrorTest : public QOpenGLWidget { public: OGLErrorTest(QWidget *p = nullptr) : QOpenGLWidget(p) { QSurfaceFormat sformat; sformat.setProfile(QSurfaceFormat::CompatibilityProfile); sformat.setMajorVersion(2); sformat.setMinorVersion(1); sformat.setDepthBufferSize(0); sformat.setAlphaBufferSize(0); sformat.setRedBufferSize(8); sformat.setGreenBufferSize(8); sformat.setBlueBufferSize(8); sformat.setStencilBufferSize(0); sformat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); sformat.setStereo(false); setFormat(sformat); } ~OGLErrorTest() {} protected: void initializeGL() { glewExperimental = GL_TRUE; GLenum err = glewInit(); if (err != GLEW_OK) { cout << "Failed to initialize GLEW" << endl; exit(-1); } const char *glv = (const char *)glGetString(GL_VERSION); glv = glv ? glv : "(unable to get OpenGL version)"; cout << glv << endl; } void resizeGL(int w, int h) {} void paintGL() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, 100, 0, 100); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_LINES); glVertex2d(0, 0); glVertex2d(100, 100); glEnd(); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); const char *qt_version = qVersion(); qt_version = qt_version ? qt_version : "(unable to get qt version)"; cout << qt_version << endl; OGLErrorTest w; w.show(); return a.exec(); }
The output of the above program is:
5.6.0 2.1.0 - Build 8.15.10.2104 [opengl\qopenglframebufferobject.cpp line 538] OpenGL Error: 1286 QOpenGLFramebufferObject: Unsupported framebuffer format. QOpenGLFramebufferObject: Unsupported framebuffer format. [opengl\qopenglframebufferobject.cpp line 730] OpenGL Error: 1280
The image gets displayed correctly. Not issues with that.
However, my question: how can I get rid of the two OpenGL errors (1286, 1280) please? Does it look like a Qt problem, or does it look like it can be gotten rid of by (say) properly configuring the OpenGL context? I think Qt is trying to make use of some features that my hardware doesn't support. If that's the case, my question is, how can I find out what these features are, and how can I tell Qt to not expect these features to be available?
I tried looking at the source code (qopenglframebufferobject.cpp), but couldn't figure out anything obvious that can be done to fix the error.
Many thanks in advance!
1/1