Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenGL invalid operation after Qt 5.4.1 upgrade to 5.7.0 (glGetError 1282)
QtWS25 Last Chance

OpenGL invalid operation after Qt 5.4.1 upgrade to 5.7.0 (glGetError 1282)

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 4.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pvt.peter
    wrote on 14 Oct 2016, 20:30 last edited by pvt.peter
    #1

    Hi,

    I work on a project which is use Qt 5.4.1 with OpenGL, here is the installer which i installed earlier:
    qt-opensource-windows-x86-msvc2013_opengl-5.4.1.exe

    A few days ago, we have done an upgrade from Qt 5.4.1 to Qt 5.7.0, so i installed this package:
    qt-opensource-windows-x86-msvc2013-5.7.0.exe

    On this project, we use OpenGL context too, which is works perfectly under Qt 5.4.1.
    After upgade to Qt 5.7.0, we got unexpected errors.
    For debugging i use glGetError() method which is returned value of 1282, which means "invalid operation".
    Someone has encountered a similar problem?

    So everything is the same, the IDE, the project, the building process, OpenGL driver, except the version of Qt ...
    I did the required settings, i.e. setting properly environment variables, set the Qt version in Visual Studio ...

    Thanks in advance,
    Peter

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Oct 2016, 20:38 last edited by
      #2

      Hi and welcome to devnet,

      WARNING: I'm no OpenGL expert, just did small stuff with it.
      However, from what I know: are you writing any shader in your application ? If so are you checking that they still compile successfully ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply 18 Oct 2016, 16:26
      0
      • L Offline
        L Offline
        lilyofvalley
        wrote on 15 Oct 2016, 01:00 last edited by
        #3

        I met similar problem.
        In my case, the problem is caused by NULL opengl context in QQuickView's scene graph.
        After scene graph initialized successfully, the QOpenGLContext::currentContext() is still NULL.
        With NULL openglContext(), the gl functions failed and get error GL_INVALID_OPERATION.

        My solution is to create an opengl context to enable the gl functions. Make sure you share the context if you use the initialized textures, vertex buffers, etc. in other renderer with default qt provided opengl context.

        Actually the opengl context behaves quite different in Qt 5.7.0 than Qt 5.4.1. As far as I understand from Qt Document, the multiple QQuickWindow instance should use the same opengl context. And in Qt 5.4.1, it is the case. But in Qt 5.7.0, it seems that each QQuickWindow has its own opengl context, thus I got the error "Cannot make QOpenGLContext current in a different thread". I hope some one can answer my question.

        1 Reply Last reply
        0
        • S SGaist
          14 Oct 2016, 20:38

          Hi and welcome to devnet,

          WARNING: I'm no OpenGL expert, just did small stuff with it.
          However, from what I know: are you writing any shader in your application ? If so are you checking that they still compile successfully ?

          P Offline
          P Offline
          pvt.peter
          wrote on 18 Oct 2016, 16:26 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • P Offline
            P Offline
            pvt.peter
            wrote on 18 Oct 2016, 16:32 last edited by
            #5

            Hi guys, sorry for my delay.

            So the first is, big thanks for your reply.

            SGaist: I do not use any shader.

            Here is a little code snippet, which is the core of problem (i think).
            So, i use a valid shared QOpenGLContext pointer named sharedContext;
            After that i create a QOpenGLContext (glContext) and a QOffscreenSurface (glSurface) pointer too.
            After that i invoke the setShareContext() method of previous QOpenGLContext pointer (glContext) with parameter of sharedContext.
            You will see it in the first four lines.

            if (sharedContext) {
               QOpenGLContext glContext = new QOpenGLContext();
               QOffscreenSurface glSurface = new QOffscreenSurface;
               glContext->setShareContext(sharedContext);
            
               glContext->create(); // true
               glSurface->create();
               glContext->makeCurrent(glSurface); // true
            
               bool isValid = glContext->isValid(); // true
               auto error = glContext->functions()->glGetError(); // 0
               // isValid is true and error is 0, so everything is ?OK?
            	
               auto currentContext = wglGetCurrentContext(); // nullptr
               auto currentDC = wglGetCurrentDC(); // nullptr
               // but currentContext and currentDC is null
               ...
            }
            

            I do not understand why currentContext and currentDC is null, namely variable of isValid set as true and variable of error set as 0, so everything is OK at least in appearance.

            What could be the problem?

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lilyofvalley
              wrote on 24 Oct 2016, 23:26 last edited by
              #6

              After glContext->setShareContext(sharedContext);
              You need to call glContext->create();
              to create this opengl context.

              P 1 Reply Last reply 28 Oct 2016, 16:28
              0
              • L lilyofvalley
                24 Oct 2016, 23:26

                After glContext->setShareContext(sharedContext);
                You need to call glContext->create();
                to create this opengl context.

                P Offline
                P Offline
                pvt.peter
                wrote on 28 Oct 2016, 16:28 last edited by
                #7

                Thanks for your reply @lilyofvalley.
                Invoke of create() is already in code. You can see it in the main post.

                glContext->create(); // true
                

                But fortunately turned out, there is an other problem which causes everything.
                You can read it in this post: Can not set renderable type from OpenGLES to OpenGL in Qt 5.7.0

                Have you got any idea about it?

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pvt.peter
                  wrote on 3 Nov 2016, 09:13 last edited by
                  #8

                  Hi,

                  I think i found the solution. Qt::AA_UseDesktopOpenGL and Qt::AA_ShareOpenGLContexts attributes solved my problem.

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    e822104
                    wrote on 1 Feb 2017, 10:28 last edited by e822104 2 Jan 2017, 10:28
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved