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. Qt3D Custom FrameGraph: Surface
QtWS25 Last Chance

Qt3D Custom FrameGraph: Surface

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3dqsurfaceqt5.7.0qpixmap
2 Posts 1 Posters 1.7k 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.
  • NeoswN Offline
    NeoswN Offline
    Neosw
    wrote on last edited by
    #1

    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 :)

    1 Reply Last reply
    0
    • NeoswN Offline
      NeoswN Offline
      Neosw
      wrote on last edited by Neosw
      #2

      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

      1 Reply Last reply
      0

      • Login

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