Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Macros in QRhi shaders?
Qt 6.12 LTS is out! See what's new in the release blog

Macros in QRhi shaders?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 421 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.
  • H Offline
    H Offline
    hamer
    wrote on last edited by
    #1

    Hi,

    I need different code paths in a shader, for example:

    #ifdef QSHADER_GLSL
    layout(location = 0) in vec2 a_pos;
    #else
    layout(location = 0) in ivec2 a_pos_int;
    #endif
    

    I know that it is possible to manually define defines:

    qt6_add_shaders(my_target
        DEFINES "QSHADER_GLSL=true"
        FILES
            ...
    )
    

    But this way using qputenv("QSG_RHI_BACKEND", "opengl") does not work. Is there an alternative?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hamer
      wrote on last edited by
      #2

      As usual, after asking the question, I found the answer myself. The key is to passPERTARGETCOMPILE to qt6_add_shaders.

      1 Reply Last reply
      0
      • H hamer has marked this topic as solved on

      • Login

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