<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Léo,<br>
    </p>
    <div class="moz-cite-prefix">On 2/25/20 3:15 PM, Léo Adam wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CANg790BKarRw5NS8G8TLedWYUKy2QQzQNK=w4FgNwpNQvKcumg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Hi,<br>
          <br>
        </div>
        <div>I am new to Qt3D and there's a few things I was wondering
          how to achieve:</div>
        <div><br>
        </div>
        <div>- I need to read and write an opengl texture from C++. <br>
          For example, I am rendering a scene into a texture during a
          first render pass, and then performing some postprocess effect
          before rendering that texture in a fullscreen quad during a
          second render pass. <br>
          I would like to access that texture from C++, and can't manage
          to do that. I've found the classes <i>QTextureImageData</i>/<i>QTextureData</i>/<i>QTextureDataGenerator</i>,
          but I don't know if that's really what I'm looking for and if
          it is, how to use it.</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <p>Have look at the manual tests in Qt3D <a
        href="https://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual?h=5.15">https://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual?h=5.15</a></p>
    <p>- texture-updates-cpp -> C++ to GPU uploads</p>
    <p>- rendercapture* -> GPU Back buffer / FBO to C++/QML download<br>
    </p>
    <p>- sharedtexture if you want to create a raw OpenGL texture and
      have Qt3D use it</p>
    <p>- deferred-renderer* for rendering into FBO and reusing FBO
      attachement in a second pass<br>
    </p>
    <blockquote type="cite"
cite="mid:CANg790BKarRw5NS8G8TLedWYUKy2QQzQNK=w4FgNwpNQvKcumg@mail.gmail.com">
      <div dir="ltr">
        <div>- I also would like to send preprocessor instructions to a
          shader from C++/QML and I don't know if this is possible.<br>
          For example, if I want to use <i>#ifdef</i> in a shader with
          a value defined in C++, I would need to send that value to the
          shader just like <i>QParameter</i> do with uniforms. <br>
          I've searched in the documentation and on internet, but I
          didn't find anything.<br>
        </div>
      </div>
    </blockquote>
    <p>changing the #ifdef would trigger a whole shader recompilation ,
      fine for prototyping, probably not for production.<br>
    </p>
    <p>You would have to modify the shader code directly, something
      like:</p>
    <p>property int value: 1</p>
    <p>ShaderProgram {</p>
    <p>    fragmentShader: "</p>
    <p>        #ifdef " + value + "</p>
    <p>            ...<br>
    </p>
    <p>       #else</p>
    <p>      ..."<br>
    </p>
    <p>}<br>
    </p>
    <blockquote type="cite"
cite="mid:CANg790BKarRw5NS8G8TLedWYUKy2QQzQNK=w4FgNwpNQvKcumg@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Any help would be highly appreciated :-)<br>
          <br>
        </div>
        <div>Sincerely,<br>
        </div>
        <div>Léo.<br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Interest mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Interest@qt-project.org">Interest@qt-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.qt-project.org/listinfo/interest">https://lists.qt-project.org/listinfo/interest</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Paul Lemire | <a class="moz-txt-link-abbreviated" href="mailto:paul.lemire@kdab.com">paul.lemire@kdab.com</a> | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel: France +33 (0)4 90 84 08 53, <a class="moz-txt-link-freetext" href="http://www.kdab.fr">http://www.kdab.fr</a>
KDAB - The Qt, C++ and OpenGL Experts</pre>
  </body>
</html>