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. QOpenGLWidget with QOpenGLFunctions_3_3_Core is initialized failed on Mac OS
Forum Updated to NodeBB v4.3 + New Features

QOpenGLWidget with QOpenGLFunctions_3_3_Core is initialized failed on Mac OS

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.8k Views 1 Watching
  • 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.
  • F Offline
    F Offline
    fisher103
    wrote on 30 Jun 2018, 10:54 last edited by fisher103
    #1
    I have a TestWidget inherited from QOpenGLWidget and QOpenGLFunctions_3_3_Core, which works fine on windows platform but failed on MacOS. my macbook pro is the latest one and OpenGL3.x is support and Graphic card shows it support 3.x 4.x as well.
    

    When I changed to gl es with inheriting from QOpenGLFunctions everything works fine. Also I can run OpenGL example from Qt Creator normal, in which all widget inherit from QOpenGLFunctions.

    Then

    1. it's Qt's lose to support OpenGL3.x or I miss something?
    2. we can only use GL ES with Qt in MacOS without modern OpenGL?

    class GLTest : public QOpenGLWidget,
    public QOpenGLFunctions_3_3_Core

    {
    Q_OBJECT

    public:
    static E_GL_TEST_CODE HaveGLTest();

    protected:
        //QOpenGLWidget need override
        virtual void initializeGL() Q_DECL_OVERRIDE;
        virtual void resizeGL(int w, int h) Q_DECL_OVERRIDE;
        virtual void paintGL() Q_DECL_OVERRIDE;
    
    private:
        explicit GLTest(QWidget *parent = 0);
    
    private:
        E_GL_TEST_CODE m_iStatus;
    };    
    
    void GLTest::initializeGL()
    {
        if (!initializeOpenGLFunctions())
        {
            m_iStatus = E_TEST_NO_DRIVER;
            qDebug() << "ohoop ...";
            return;
        }
    
        const GLubyte *pvender = glGetString(GL_VENDOR);
        const GLubyte *prender = glGetString(GL_RENDERER);
    
        m_iStatus = E_TEST_NORMAL;
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 30 Jun 2018, 22:03 last edited by
      #2

      Hi,

      What version of Qt are you using ?
      What macOS version are you running on ?
      What Mac computer are you using for development ?

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

      F 1 Reply Last reply 2 Jul 2018, 01:38
      0
      • S SGaist
        30 Jun 2018, 22:03

        Hi,

        What version of Qt are you using ?
        What macOS version are you running on ?
        What Mac computer are you using for development ?

        F Offline
        F Offline
        fisher103
        wrote on 2 Jul 2018, 01:38 last edited by fisher103 7 Feb 2018, 02:30
        #3

        @SGaist Qt5.9.5
        version 10.13.3 (17D47)
        MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
        Intel Iris Plus Graphics 650 1536 MB

        I went to qt source and find context format is version 2.1 which makes it failed.

        bool QOpenGLFunctions_3_3_Core_Pri::isContextCompatible(QOpenGLContext *context)
        {
        Q_ASSERT(context);
        QSurfaceFormat f = context->format();
        const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
        qDebug() << v; //output is 2.1
        if (v < qMakePair(3, 3))
        return false;
        else
        return true;
        }

        F 1 Reply Last reply 2 Jul 2018, 08:02
        0
        • F fisher103
          2 Jul 2018, 01:38

          @SGaist Qt5.9.5
          version 10.13.3 (17D47)
          MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
          Intel Iris Plus Graphics 650 1536 MB

          I went to qt source and find context format is version 2.1 which makes it failed.

          bool QOpenGLFunctions_3_3_Core_Pri::isContextCompatible(QOpenGLContext *context)
          {
          Q_ASSERT(context);
          QSurfaceFormat f = context->format();
          const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
          qDebug() << v; //output is 2.1
          if (v < qMakePair(3, 3))
          return false;
          else
          return true;
          }

          F Offline
          F Offline
          fisher103
          wrote on 2 Jul 2018, 08:02 last edited by fisher103 7 Feb 2018, 08:04
          #4

          @fisher103
          From Qt doc, I finally find that QSurfaceFormat::setDefaultFormat() should be called before constructing QApplication on Mac, in which we can set OpenGL Core Profile version. And then the initializeOpenGlFunctions work normal.
          But the deeper reason of this can be also to be explored.

          1 Reply Last reply
          1
          • W Offline
            W Offline
            wrosecrans
            wrote on 2 Jul 2018, 20:23 last edited by
            #5

            The deeper reason is that Apple doesn't support modern features in compatibility contexts that are backwards compatible. In order to keep old apps working, the default of a compatibility context rather than one that only supports core profile. So if you want to use modern features, you need to opt-in.

            Don't expect it to change much -- Apple has deprecated OpenGL going forward so that narrow support of core profile is probably about as good as it will get on OS-X.

            1 Reply Last reply
            2

            1/5

            30 Jun 2018, 10:54

            • Login

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