[Interest] [Qt3D] Get OpenGL texture data / Send preprocessor instructions to shaders

Paul Lemire paul.lemire at kdab.com
Tue Feb 25 15:46:23 CET 2020


Hi Léo,

On 2/25/20 3:15 PM, Léo Adam wrote:
> Hi,
>
> I am new to Qt3D and there's a few things I was wondering how to achieve:
>
> - I need to read and write an opengl texture from C++.
> 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.
> I would like to access that texture from C++, and can't manage to do 
> that. I've found the classes 
> /QTextureImageData///QTextureData///QTextureDataGenerator/, but I 
> don't know if that's really what I'm looking for and if it is, how to 
> use it.
>
Have look at the manual tests in Qt3D 
https://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual?h=5.15

- texture-updates-cpp -> C++ to GPU uploads

- rendercapture* -> GPU Back buffer / FBO to C++/QML download

- sharedtexture if you want to create a raw OpenGL texture and have Qt3D 
use it

- deferred-renderer* for rendering into FBO and reusing FBO attachement 
in a second pass

> - I also would like to send preprocessor instructions to a shader from 
> C++/QML and I don't know if this is possible.
> For example, if I want to use /#ifdef/ in a shader with a value 
> defined in C++, I would need to send that value to the shader just 
> like /QParameter/ do with uniforms.
> I've searched in the documentation and on internet, but I didn't find 
> anything.

changing the #ifdef would trigger a whole shader recompilation , fine 
for prototyping, probably not for production.

You would have to modify the shader code directly, something like:

property int value: 1

ShaderProgram {

     fragmentShader: "

         #ifdef " + value + "

             ...

        #else

       ..."

}

>
> Any help would be highly appreciated :-)
>
> Sincerely,
> Léo.
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest

-- 
Paul Lemire | paul.lemire at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel: France +33 (0)4 90 84 08 53, http://www.kdab.fr
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200225/f9f8513c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4282 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200225/f9f8513c/attachment.bin>


More information about the Interest mailing list