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. How to setup QOpenGLWindow to have access to desirable functionality?
QtWS25 Last Chance

How to setup QOpenGLWindow to have access to desirable functionality?

Scheduled Pinned Locked Moved Solved General and Desktop
qopenglwiqsurfaceformatwindows
10 Posts 6 Posters 4.7k 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.
  • L_RaizL Offline
    L_RaizL Offline
    L_Raiz
    wrote on last edited by
    #1

    In my Qt OpenGL desktop application, I use some pre-2.0 aspects of openGL in combination with buffer arrays, flat shading, and simple lighting. I do not use shaders.

    The application is built with VS2013 and works fine on my Windows 10 development machine. However, when I tried to install and run it on Windows 7 I run into problems that I can't figure out how to deal with.

    Initially, I found out that simple GL functions refused to work. For example glEnable(GL_RESCALE_NORMAL) resulted in glGetError() returning GL_INVALID_ENUM. That prompted my checking of GL version. I discovered that if I don't set anything but sampling in the format of my QOpenGLWindow then inside of my initializeGL() method on Win7 I see QOpenGLContext with GL version 2.0 while it is 4.3 on Win10. I figured that Win7 must be trying to run GL 2.0 ES which does not support rescaling of normals.

    Next, I tried to give Qt some hints about my desired GL features. I added calls to set OpenGLContextProfile to QSurfaceFormat::CompatibilityProfile and RenderableType to QSurfaceFormat::OpenGL. I checked resulting QOpenGLContext and on Win10 it was just as I requested while on Win7 my settings were somewhat ignored and created QOpenGLContext had ContextProfile as CompatibilityProfileType but RenderableType changed to OpenGLES, and GL version was 2.0. glEnable(GL_RESCALE_NORMAL) still reported an error.

    Subsequently, I tried to be even more explicit and added calls to set major and minor versions of GL. That resulted in even stranger behavior. On my development Win10, the same code that worked okay without explicit setting of version after I set it to the same value as previously was selected by default stopped working. Now glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE) started reporting GL_INVALID_OPERATION error. Crazy.

    I fill lost. Where should I look?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you check what kind of driver was available on Win7. It seems that the backend detection starts the ANGLE backend. You could try forcing the OpenGL mode to be desktop.

      See here for more information.

      Hope it helps

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

      LRaizL 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you check what kind of driver was available on Win7. It seems that the backend detection starts the ANGLE backend. You could try forcing the OpenGL mode to be desktop.

        See here for more information.

        Hope it helps

        LRaizL Offline
        LRaizL Offline
        LRaiz
        wrote on last edited by
        #3

        @SGaist Thanks for the suggestion. I think Win7 computer had d3d9 installed, but not d3d11 (will double check tomorrow when I get into the office). I did see the piece of documentation that you pointed out. However, I was confused by it. I developed everything using VS2013 with the latest studio plug-in and didn't have to deal with the configure script. I just compiled and linked. By the way, opengl32.dll is one of my link dependencies.

        • Does not using configure script implies that I would need to rebuild Qt from source?
        • If I do that wouldn't I loose the convenience of not thinking about specific graphics cards afforded by ANGLE?
        • Is it a bug that Qt would not make QOpenGLContext with render type OpenGL as opposed to OpenGLES when I explicitly asked for it? Is there a way to force OpenGL render type by requesting some specific version of OpenGL?

        Thanks,
        ~ LR

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Indeed, configure means that you are building Qt yourself. The thing that was of interest to you is under that paragraph i.e. the use of AA_UseDesktopOpenGL to force the backend to desktop OpenGL.

          AFAIK, Qt queries the system to try to get what you asked and returns what the system provided as a answer.

          To request specific version and other options IIRC, it's the QSurfaceFormat that interests you.

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

          1 Reply Last reply
          0
          • L_RaizL Offline
            L_RaizL Offline
            L_Raiz
            wrote on last edited by
            #5

            I already tried using QSurfaceFormat to request render type QSurfaceFormat::OpenGL to no avail.

            The main point of your reply turned out to be very useful. I managed to overcome my problems by setting an environment variable QT_OPENGL=desktop (just wish the documentation was explicit about specific value to use).

            Calling QCoreApplication:::setAttribute(AA_UseDesktopOpenGL) is an even more elegant solution. I just wish I'd noticed that this method is static sooner and thus makes it easy to satisfy documentation requirement of being called before my application is instantiated.

            Your help is much appreciated.

            lilyofvalleyL 1 Reply Last reply
            0
            • L_RaizL L_Raiz

              I already tried using QSurfaceFormat to request render type QSurfaceFormat::OpenGL to no avail.

              The main point of your reply turned out to be very useful. I managed to overcome my problems by setting an environment variable QT_OPENGL=desktop (just wish the documentation was explicit about specific value to use).

              Calling QCoreApplication:::setAttribute(AA_UseDesktopOpenGL) is an even more elegant solution. I just wish I'd noticed that this method is static sooner and thus makes it easy to satisfy documentation requirement of being called before my application is instantiated.

              Your help is much appreciated.

              lilyofvalleyL Offline
              lilyofvalleyL Offline
              lilyofvalley
              wrote on last edited by
              #6

              @L_Raiz Hi Raiz, how did you set the environment variable QT_OPENGL=desktop? I set it in the System variable (advanced system settings -> advanced -> environment variables), but does not work. Also put it in the .pro file, do not work. I think I must have misunderstand something...

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi @lilyofvalley,

                You can do it in the Run part of the Project panel of Qt Creator

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

                lilyofvalleyL 1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi @lilyofvalley,

                  You can do it in the Run part of the Project panel of Qt Creator

                  lilyofvalleyL Offline
                  lilyofvalleyL Offline
                  lilyofvalley
                  wrote on last edited by
                  #8

                  @SGaist Thank you so much! I will try it~~~

                  1 Reply Last reply
                  0
                  • _ Offline
                    _ Offline
                    __dalin__
                    wrote on last edited by
                    #9

                    Sorry for being late on this but I'm thinking that this may solve my issue with the QT ERROR OF DEATH "Qt Quick emulation layer crashed. (Line: 1)" but I have no clue as to what steps you guys speak of. I don't know where to find the "Run part of the project panel", and in the system variable do we literally type "QT_OPENGL=desktop" in the field for the path. I'm super confused.

                    jsulmJ 1 Reply Last reply
                    0
                    • _ __dalin__

                      Sorry for being late on this but I'm thinking that this may solve my issue with the QT ERROR OF DEATH "Qt Quick emulation layer crashed. (Line: 1)" but I have no clue as to what steps you guys speak of. I don't know where to find the "Run part of the project panel", and in the system variable do we literally type "QT_OPENGL=desktop" in the field for the path. I'm super confused.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @__dalin__ said in How to setup QOpenGLWindow to have access to desirable functionality?:

                      Run part of the project panel

                      In QtCreator click on Projects on the right side, then "Build & Run/Run".
                      "and in the system variable do we literally type "QT_OPENGL=desktop" in the field for the path" - there is no path. You simply add a new variable there (by clicking on Add button), change the Variable name to QT_OPENGL and Value to desktop, that's all.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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