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. QGLWidget ceased to work on Windows in Qt 5.7?

QGLWidget ceased to work on Windows in Qt 5.7?

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 4 Posters 7.6k Views 4 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by Violet Giraffe
    #1

    The following application works well with Qt 5.5, but only black screen with 5.7. What gives? My OGL application is entirely broken and I traced the problem back to this primitive example after 3 hours of banging my head on the wall.

    #include <QApplication>
    #include <QGLWidget>
    #include <QMainWindow>
    
    class GlTestWidget : public QGLWidget
    {
    public:
    	explicit GlTestWidget(QWidget *parent = 0) : QGLWidget(parent) {}
    
    protected:
    	void resizeGL(int h, int w) override {
    		glViewport(0, 0, (GLint)w, (GLint)h);
    	}
    
    	void paintGL() override {
    		glClearColor(1.0f, 0.7f, 0.0f, 1.0f);
    		glClear(GL_COLOR_BUFFER_BIT);
    	}
    };
    
    struct MainWindow : public QMainWindow
    {
    	MainWindow() {
    		setCentralWidget(new GlTestWidget(this));
    	}
    };
    
    int main(int argc, char *argv[])
    {
    	QApplication a(argc, argv);
    	MainWindow w;
    	w.show();
    
    	return a.exec();
    }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      The docs
      http://doc.qt.io/qt-5/qglwidget.html
      says
      "This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code."

      So no, it should still work.

      Have you tried other sample
      http://doc.qt.io/qt-4.8/qt-opengl-hellogl-example.html
      (C:\Qt\Examples\Qt-5.7\opengl\legacy\hellogl)

      One possible cause could be you do not use a
      void GLWidget::initializeGL()

      But it would good to know if that sample also produce black on Qt 5.7

      Update:
      Win 10 Desktop Pc , Qt 5.7 , Sample works here. using QGLWidget.
      Main difference to your sample is
      void GLWidget::initializeGL()
      {
      initializeOpenGLFunctions(); <<<<< important?

      and
      class GLWidget : public QGLWidget, public QOpenGLFunctions_1_1

      kshegunovK V 2 Replies Last reply
      2
      • mrjjM mrjj

        Hi
        The docs
        http://doc.qt.io/qt-5/qglwidget.html
        says
        "This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code."

        So no, it should still work.

        Have you tried other sample
        http://doc.qt.io/qt-4.8/qt-opengl-hellogl-example.html
        (C:\Qt\Examples\Qt-5.7\opengl\legacy\hellogl)

        One possible cause could be you do not use a
        void GLWidget::initializeGL()

        But it would good to know if that sample also produce black on Qt 5.7

        Update:
        Win 10 Desktop Pc , Qt 5.7 , Sample works here. using QGLWidget.
        Main difference to your sample is
        void GLWidget::initializeGL()
        {
        initializeOpenGLFunctions(); <<<<< important?

        and
        class GLWidget : public QGLWidget, public QOpenGLFunctions_1_1

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #3

        Works for me without a glitch on Qt 5.7.1, Linux 4.6.0 kernel.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        2
        • mrjjM mrjj

          Hi
          The docs
          http://doc.qt.io/qt-5/qglwidget.html
          says
          "This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code."

          So no, it should still work.

          Have you tried other sample
          http://doc.qt.io/qt-4.8/qt-opengl-hellogl-example.html
          (C:\Qt\Examples\Qt-5.7\opengl\legacy\hellogl)

          One possible cause could be you do not use a
          void GLWidget::initializeGL()

          But it would good to know if that sample also produce black on Qt 5.7

          Update:
          Win 10 Desktop Pc , Qt 5.7 , Sample works here. using QGLWidget.
          Main difference to your sample is
          void GLWidget::initializeGL()
          {
          initializeOpenGLFunctions(); <<<<< important?

          and
          class GLWidget : public QGLWidget, public QOpenGLFunctions_1_1

          V Offline
          V Offline
          Violet Giraffe
          wrote on last edited by
          #4

          @mrjj said in QGLWidget ceased to work in Qt 5.7?:

          Main difference to your sample is
          void GLWidget::initializeGL()
          {
          initializeOpenGLFunctions(); <<<<< important?

          and
          class GLWidget : public QGLWidget, public QOpenGLFunctions_1_1

          No, my application won't work like that, it uses many OpenGL functions that are not provided by QOpenGLFunctions.

          Forgot to add that I'm having problems on Windows 10. The same app works fine on Mac.

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Well, you should test on other win 10 then.
            The QGLWidget samples seems to work fine on win 10 when i run it.

            Did you try the sample ? Does it also produce black on that pc?

            V 1 Reply Last reply
            0
            • mrjjM mrjj

              Well, you should test on other win 10 then.
              The QGLWidget samples seems to work fine on win 10 when i run it.

              Did you try the sample ? Does it also produce black on that pc?

              V Offline
              V Offline
              Violet Giraffe
              wrote on last edited by Violet Giraffe
              #6

              @mrjj
              My glClear example from the first post produces black when combined with Qt 5.7 and orange (expected) with 5.5.
              Meanwhile, hellogl example crashes.

              mrjjM 1 Reply Last reply
              0
              • V Violet Giraffe

                @mrjj
                My glClear example from the first post produces black when combined with Qt 5.7 and orange (expected) with 5.5.
                Meanwhile, hellogl example crashes.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Violet-Giraffe
                So it seems that QGLWidget and that win 10 have issues?
                Tried hellogl on 3 very different win 10 pc and it worked.

                So if same sample crashes on the test pc you have, i would
                think its driver issue that first surfaces when using 5.7.

                V 1 Reply Last reply
                0
                • V Offline
                  V Offline
                  Violet Giraffe
                  wrote on last edited by
                  #8

                  OK, I have tried replacing the direct GL function calls with QOpenGLFunctions_1_1 (and then QOpenGLFunctions_2_0). But some of the functions I need are not loaded by that class. E. g. glMaterialfv: there is a method for that

                  inline void QOpenGLFunctions_2_0::glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
                  {
                      d_1_0_Deprecated->f.Materialfv(face, pname, params);
                  }
                  

                  Here f is a structure holding pointers to OpenGL functions, and it doesn't have a single non-nullptr field.

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Violet-Giraffe
                    So it seems that QGLWidget and that win 10 have issues?
                    Tried hellogl on 3 very different win 10 pc and it worked.

                    So if same sample crashes on the test pc you have, i would
                    think its driver issue that first surfaces when using 5.7.

                    V Offline
                    V Offline
                    Violet Giraffe
                    wrote on last edited by Violet Giraffe
                    #9

                    The example's problem is the same: it didn't load any OpenGL functions into d_1_0_Deprecated->f. But I don't care about the example. You know my drivers are OK and they do supply these functions because the same code works when compiled and linked with Qt 5.5 (didn't try 5.6) and calling OpenGL functions directly from OpenGl32.lib.

                    1 Reply Last reply
                    0
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      ok, But you dont find it odd that the
                      hellogl sample here works with 5.7 on all win 10 , i could test on?

                      But on that pc, you say it crash?

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        Violet Giraffe
                        wrote on last edited by
                        #11

                        Yes, it crashes because it fails to load OpenGL function pointers into d_1_0_Deprecated->f. I'm fairly sure it's a Qt bug. And there's no saying how many users of my app will experience this bug as well.

                        mrjjM 1 Reply Last reply
                        0
                        • V Violet Giraffe

                          Yes, it crashes because it fails to load OpenGL function pointers into d_1_0_Deprecated->f. I'm fairly sure it's a Qt bug. And there's no saying how many users of my app will experience this bug as well.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Violet-Giraffe
                          well if its a bug in Qt it must
                          be with certain hardware or drivers as i cannot make sample fail with the
                          hardware with win 10, i have at work.

                          You can look in
                          https://bugreports.qt.io/secure/Dashboard.jspa
                          if it has been reported before.

                          V 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @Violet-Giraffe
                            well if its a bug in Qt it must
                            be with certain hardware or drivers as i cannot make sample fail with the
                            hardware with win 10, i have at work.

                            You can look in
                            https://bugreports.qt.io/secure/Dashboard.jspa
                            if it has been reported before.

                            V Offline
                            V Offline
                            Violet Giraffe
                            wrote on last edited by Violet Giraffe
                            #13

                            @mrjj Indeed, it seems to occur only on some systems, but a bug nevertheless. I didn't find a corresponding issue in the tracker. I would report it but don't see a point - they probably won't be able to reproduce it as well. Seeing that the bugs I reported 2 years ago still aren't fixed, I'm not enthusiastic about spending more time trying to make Qt better. Just need to find the quickest way to restore functionality of my application.

                            1 Reply Last reply
                            0
                            • mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              Well I had hoped I could reproduce it
                              as clear reproduction steps is needed.

                              However, since QGLWidget is considered obsolete in 5.7,
                              I doubt the devs will spend much energy to correct it anyway.

                              1 Reply Last reply
                              0
                              • V Offline
                                V Offline
                                Violet Giraffe
                                wrote on last edited by
                                #15

                                The problem with hellogl example is not in QGLWidget. I'm about to try QOpenGLWidget instead, and I'm sure it will fail just the same. It's the QOpenGLFunctions_xx classes that are broken, although it doesn't explain why my application stopped working. I never used these classes.

                                1 Reply Last reply
                                0
                                • V Offline
                                  V Offline
                                  Violet Giraffe
                                  wrote on last edited by Violet Giraffe
                                  #16

                                  No functions are loaded into QOpenGLFunctions_x_x::d_x_x_Deprecated tables. That's d_1_0_Deprecated, d_1_2_Deprecated and d_1_4_Deprecated. And I need some functions from there. So it makes no difference what kind of widget I will use, the old or the new one.

                                  Unless I make direct OpenGL calls, of course, but direct calls are broken with Qt 5.7 as well. I don't understand why, but they are.

                                  1 Reply Last reply
                                  1
                                  • V Offline
                                    V Offline
                                    Violet Giraffe
                                    wrote on last edited by
                                    #17

                                    Update: the required functions are loaded in Qt 5.5 - but not in 5.7. I have Qt sources, I can debug if someone tells me where to look.

                                    kshegunovK 1 Reply Last reply
                                    1
                                    • V Violet Giraffe

                                      Update: the required functions are loaded in Qt 5.5 - but not in 5.7. I have Qt sources, I can debug if someone tells me where to look.

                                      kshegunovK Offline
                                      kshegunovK Offline
                                      kshegunov
                                      Moderators
                                      wrote on last edited by
                                      #18

                                      @Violet-Giraffe

                                      direct calls are broken with Qt 5.7 as well. I don't understand why, but they are.

                                      Then the problem (probably) has little to do with Qt. Qt only resolves the functions' addresses for you. List the symbols from your OpenGL library (the one you link against), see if it exports the deprecated functions you want to use.

                                      Update: the required functions are loaded in Qt 5.5 - but not in 5.7. I have Qt sources, I can debug if someone tells me where to look.

                                      <Qt source dir>/qtbase/src/gui/opengl
                                      

                                      Read and abide by the Qt Code of Conduct

                                      V 1 Reply Last reply
                                      0
                                      • kshegunovK kshegunov

                                        @Violet-Giraffe

                                        direct calls are broken with Qt 5.7 as well. I don't understand why, but they are.

                                        Then the problem (probably) has little to do with Qt. Qt only resolves the functions' addresses for you. List the symbols from your OpenGL library (the one you link against), see if it exports the deprecated functions you want to use.

                                        Update: the required functions are loaded in Qt 5.5 - but not in 5.7. I have Qt sources, I can debug if someone tells me where to look.

                                        <Qt source dir>/qtbase/src/gui/opengl
                                        
                                        V Offline
                                        V Offline
                                        Violet Giraffe
                                        wrote on last edited by Violet Giraffe
                                        #19

                                        @kshegunov said in QGLWidget ceased to work on Windows in Qt 5.7?:

                                        List the symbols from your OpenGL library (the one you link against), see if it exports the deprecated functions you want to use.

                                        I link with Windows default OpenGL32.lib. It's the same in both cases.

                                        <Qt source dir>/qtbase/src/gui/opengl
                                        

                                        That's not helpful.

                                        kshegunovK 1 Reply Last reply
                                        0
                                        • V Violet Giraffe

                                          @kshegunov said in QGLWidget ceased to work on Windows in Qt 5.7?:

                                          List the symbols from your OpenGL library (the one you link against), see if it exports the deprecated functions you want to use.

                                          I link with Windows default OpenGL32.lib. It's the same in both cases.

                                          <Qt source dir>/qtbase/src/gui/opengl
                                          

                                          That's not helpful.

                                          kshegunovK Offline
                                          kshegunovK Offline
                                          kshegunov
                                          Moderators
                                          wrote on last edited by
                                          #20

                                          @Violet-Giraffe said in QGLWidget ceased to work on Windows in Qt 5.7?:

                                          I link with Windows default OpenGL32.lib. It's the same in both cases.

                                          There's no such thing. The lib file is part of the Windows SDK.
                                          Are you using a statically built Qt? How did you install, Qt may be linked against another GL, or it may be resolving the functions at runtime (which is rather probable on desktop). Just list the symbols from opengl32.dll and see what's exported.

                                          That's not helpful.

                                          How so? It is where you should look if you intend to debug ...

                                          Read and abide by the Qt Code of Conduct

                                          V 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