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. Finding and setting supported opengl version for QOpenGLWidget
Forum Updated to NodeBB v4.3 + New Features

Finding and setting supported opengl version for QOpenGLWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 571 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.
  • G Offline
    G Offline
    gde23
    wrote on 18 Apr 2018, 13:33 last edited by
    #1

    Hello,

    i have a ui with a QOpenGLWidget.
    On my default machine it runs as it should. However on another machine (with odler graphics card) it just shows a black screen.
    I guess because there the maximum opengl version that is supported is 3.1
    How can i determine inside Qt which version is supported on a machine and then set the QOpenGLWidget to work with that one?

    1 Reply Last reply
    0
    • W Offline
      W Offline
      webzoid
      wrote on 18 Apr 2018, 14:56 last edited by
      #2

      @gde23 I would be interested in finding the solution to this. I also have issues when using QOpenGLWidget on different computers with differing supported OpenGL versions. I've tried various solutions but all of which have not worked.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jeremy Walker
        wrote on 23 Jun 2024, 15:33 last edited by
        #3

        I have the same question. Surprisingly difficult to find the answer.

        J 1 Reply Last reply 24 Jun 2024, 14:08
        0
        • J Jeremy Walker
          23 Jun 2024, 15:33

          I have the same question. Surprisingly difficult to find the answer.

          J Offline
          J Offline
          JoeCFD
          wrote on 24 Jun 2024, 14:08 last edited by JoeCFD
          #4

          @Jeremy-Walker Try it out to find the version of OpenGL.

          #include <QGuiApplication>
          #include <QDebug>
          #include <QOpenGLContext>
          #include <QSurfaceFormat>
          
          int main(int argc, char *argv[])
          {
              QGuiApplication app(argc, argv);
          
              QOpenGLContext context;
              if ( context.create() ) {
                  QSurfaceFormat format = context.format();
                  int majorVersion = format.majorVersion();
                  int minorVersion = format.minorVersion();
          
                  qDebug() << "Supported OpenGL version: " << majorVersion << "." << minorVersion;
              }
              else {
                  qDebug() << "OpenGL creation failed: ";
              }
          
              return app.exec();
          }
          
          1 Reply Last reply
          0
          • J Offline
            J Offline
            JoeCFD
            wrote on 24 Jun 2024, 14:25 last edited by
            #5

            Try to set openGL version:
            // Set OpenGL version and profile
            QSurfaceFormat format;
            format.setVersion(3, 3); // Set OpenGL version (e.g., 3.3)
            format.setProfile(QSurfaceFormat::CoreProfile); // Set OpenGL core profile

            https://doc.qt.io/qt-5/qopenglwidget.html#setFormat

            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