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. Porting to Qt6 glsl shaders used via QOpenGLFunctions
Forum Updated to NodeBB v4.3 + New Features

Porting to Qt6 glsl shaders used via QOpenGLFunctions

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 649 Views 2 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.
  • J Offline
    J Offline
    joajoa
    wrote on last edited by joajoa
    #1

    Hi everyone, I'm porting an application from Qt 5.15 to Qt 6.4. This application has a custom scene graph renderer to render into external devices and uses OpenGL ES in some areas of the code. It has glsl files for shaders and subclasses QOpenGLFunctions to do this rendering. Unfortunately I can't make it work using OpenGL as the graphics api.

    I've read the porting guides but I can't figure out what's the next step. Do these files need to be ported to Vulkan and added via the qsb tools? I understand that this is mandatory for qml ShaderEffects but this is not exactly the case. Shaders are added via glAttachShader from a QOpenGLFunctions subclass.

    Thanks in advanced.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      My understanding is that, yes, you need to port all your shaders and compile them using the qsb tool.

      If you need to use textures, there is also the extra nasty trap of having to call the undocumented private function

      QSGTexture::commitTextureOperations(QRhi*, QRhiResourceUpdateBatch *);
      

      But I'm by no means an expert on that topic, hopefully someone else could elaborate.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        joajoa
        wrote on last edited by
        #3

        Compiling the shaders through the qsb tool makes me ask an additional question. Before I was adding the shaders through the source code and compiling it manually via QOpenGLFunctions::glShaderSource and QOpenGLFunctions::glCompileShader ... but now the shaders would be already compiled, right?

        EskilE 1 Reply Last reply
        0
        • J joajoa

          Compiling the shaders through the qsb tool makes me ask an additional question. Before I was adding the shaders through the source code and compiling it manually via QOpenGLFunctions::glShaderSource and QOpenGLFunctions::glCompileShader ... but now the shaders would be already compiled, right?

          EskilE Offline
          EskilE Offline
          Eskil
          wrote on last edited by
          #4

          @joajoa I'm not sure if I understand the use case completely, but when executing raw OpenGL calls, you shouldn't have to worry about any of the RHI stuff: That's for using ShaderEffect components and classes that have to work with the same input regardless of what graphics backend is in use.

          For calling OpenGL directly, you just follow the OpenGL documentation. Note that you do have to make sure the RHI is running on OpenGL (QSG_RHI_BACKEND=opengl), since we don't support mixing graphics backends, but beyond that you should be able to use the same GLSL shaders you were using in Qt 5.

          For the shaders processed through qsb, these will be converted to and passed as GLSL to OpenGL by the RHI layer.

          For custom OpenGL rendering in a Qt Quick scene, there are a couple of examples that might be useful to look at: OpenGL Under QML which shows how to execute OpenGL draw calls before Qt Quick renders its scene and Rendering FBOs. I see that the documentation of the latter is really minimal, but the code might still be useful. It uses QQuickFramebufferObject to forward raw OpenGL calls into an FBO and then draws this FBO into the Qt Quick scene.

          If you are actually making a renderer for Qt Quick itself, then you need to deal with input which is backend-agnostic, which means you have to deal with the RHI. But any shader code you pass directly to OpenGL should still be GLSL.

          I hope this was helpful.

          1 Reply Last reply
          2

          • Login

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