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. Querying OpenGL version / getting OpenGL > 2.x in Qt3D, OS X 10.11
QtWS25 Last Chance

Querying OpenGL version / getting OpenGL > 2.x in Qt3D, OS X 10.11

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • M Offline
    M Offline
    Marburg
    wrote on last edited by
    #1

    All,

    I'm working on my first Qt3D app --- and first significant OpenGL project -- under Qt 5.7, OS X 10.11, XCode 7.3.1. By starting with some code from Qt3DExtras (and lots of mistakes) I've been able to construct a working scenegraph. My code (based margely on the QPhongMaterial class) uses the APIFilter to select between GL2 and GL3 vertex and fragment shader snippets.

    I want to go strictly OpenGL >3, but it sure seems like I'm consistently loading the OpenGL2 shaders (e.g., if I introduce a bug to the GL2 code, I get an error message, if I put a bug in the GL3 code, no error message). This seems strange to me as OS X should have GL 4.x.

    I don't even know where to start debugging. With Qt3D as an abstraction layer on top of OpenGL, I don't know how to get to the OpenGL context to read strings, etc.

    1 Reply Last reply
    0
    • NeoswN Offline
      NeoswN Offline
      Neosw
      wrote on last edited by
      #2

      Hi,

      When you create the view have you selected a version of OpenGl > 3 ?
      In Qt3DWindow constructor, qt team defined the surface with the following code:

      ...
          setSurfaceType(QSurface::OpenGLSurface);
      
          resize(1024, 768);
      
          QSurfaceFormat format;
      #ifdef QT_OPENGL_ES_2
          format.setRenderableType(QSurfaceFormat::OpenGLES);
      #else
          if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
              format.setVersion(4, 3);
              format.setProfile(QSurfaceFormat::CoreProfile);
          }
      #endif
          format.setDepthBufferSize(24);
          format.setSamples(4);
          format.setStencilBufferSize(8);
          setFormat(format);
          create();
      ...
      

      If you want check if you can load a OpenGL 3 shader, comment the line where you add the shader in the QEffect:

         // _phongEffect->addTechnique(_phongAlphaGL2Technique);
      

      You can also check if you have add the good number of version on the top of you shader file.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marburg
        wrote on last edited by
        #3

        I was able to get this working by explicitly setting the default QSurfaceFormat at the top of main():

            // Set default OpenGL version
            QSurfaceFormat format;
            format.setMajorVersion(3);
            format.setMinorVersion(3);
            format.setProfile( QSurfaceFormat::CoreProfile );
            QSurfaceFormat::setDefaultFormat( format );
        

        It's interesting the code from the Qt3DWindow constructor doesn't seem to be effective (?).

        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