Qt3D Custom FrameGraph: Surface



  • Qt3D surface object.

    With Qt3D, i would like made a picking rendering surface.
    I use a custom material, there are two render pass: one for the real rendering and one for the picking: object was determined with an unique color.
    I don't want use the Qt3D picking because a have a lot of objects and a i have merged them in only one QEntity (the color was determined by a color attribute in the vertex buffer).

    In the Frame Graph, i want use a QRenderSurfaceSelector and set a surface with QRenderSurfaceSelector::setSurface(QObject *surfaceObject), but what is available surface ?
    There are a QSurface class in Qt but i want use the surface for get the color in the position x and y.
    It is possible to use a QPixmap, it have a QPixmap::grabWindow() but this risk to be very slow ?

    Thank you in advance :)



  • I have find a way to get a QImage of an QWindow:
    Make a standard QWindow with is surface and add the following code:

        // set the current context OpenGL
        // check if an OpenGlContext is created
        QOpenGLContext context;
        context.setFormat(format());
        if (!context.create())
            qFatal("Cannot create the requested OpenGL context!");
        context.makeCurrent(this);
    
        // init a new framebuffer
        QOpenGLFramebufferObjectFormat fboFormat;
        fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
        fboFormat.setMipmap(true);
        fboFormat.setSamples(4);
        fboFormat.setTextureTarget(GL_TEXTURE_2D);
        fboFormat.setInternalTextureFormat(GL_RGB);
    
        resize(this->width(), this->height());
        const QRect drawRect(0, 0, this->width(), this->height());
        const QSize drawRectSize = drawRect.size();
    
        _fbo = new QOpenGLFramebufferObject(drawRectSize, fboFormat);
        _fbo->bind();
    
    ...
        _fboImage = new QImage(_fbo->toImage(false));
    
    

    But, this is work only if the window is "visible", when it is set to Hidden the rendering of Qt3D was made (the rendering loop, because the GPU is used and the FPS is divided by 3), but the QOpenGLFramebufferObject was not filled :/

    Do you have any idea of how force the filling of the fbo ?

    PS: I have found this here : http://stackoverflow.com/questions/17221730/do-offscreen-renderopengl-with-qt5


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.