Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can I implement QQuickItem::updatePaintNode() to show an video image using QSGTexture?

How can I implement QQuickItem::updatePaintNode() to show an video image using QSGTexture?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 4.6k Views 1 Watching
  • 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.
  • N Offline
    N Offline
    nan3113
    wrote on last edited by
    #1

    @
    QSGTexture texture;
    QSGNode * updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData )
    {
    QSGNode
    node;
    if(!oldNode)
    {
    node = new QSGSimpleTextureNode();
    }

    node->setTexture(&texture);
    
    return node;   
    

    }
    @

    How can I construct a QSGTexture object to show an image?
    (there's an image buffer pointer which points to pixels data of an image: imgBuffer)
    should I need to call EGL library function?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      extronus
      wrote on last edited by
      #2

      You need to derive from QSGTexture class.

      If you need a framebuffer to draw into, do something like this.

      @
      // ---------------------------------------------------------------------------
      class QMLRenderTarget : public QSGTexture
      {
      Q_OBJECT
      public :
      QMLRenderTarget(int width, int height);
      virtual ~QMLRenderTarget();
      void begin();
      void end();
      virtual void bind();
      virtual bool hasAlphaChannel() const;
      virtual bool hasMipmaps() const;
      virtual int textureId() const;
      virtual QSize textureSize() const;
      public:
      QOpenGLFramebufferObject *fbo;
      };

      // ---------------------------------------------------------------------------
      QMLRenderTarget::QMLRenderTarget(int width, int height)
      {
      QOpenGLFramebufferObjectFormat fmt;
      fmt.setMipmap(true);
      fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
      fbo = new QOpenGLFramebufferObject(width, height, fmt);
      }

      // ---------------------------------------------------------------------------
      QMLRenderTarget::~QMLRenderTarget()
      {
      delete fbo;
      }

      // ---------------------------------------------------------------------------
      void QMLRenderTarget::begin()
      {
      if (!fbo->bind()) {
      throw lock_failed();
      }
      }

      // ---------------------------------------------------------------------------
      void QMLRenderTarget::end()
      {
      fbo->release();
      }

      // ---------------------------------------------------------------------------
      void QMLRenderTarget::bind()
      {
      glBindTexture(GL_TEXTURE_2D, fbo->texture());
      }

      // ---------------------------------------------------------------------------
      bool QMLRenderTarget::hasAlphaChannel() const
      {
      return true;
      }

      // ---------------------------------------------------------------------------
      bool QMLRenderTarget::hasMipmaps() const
      {
      return true;
      }

      // ---------------------------------------------------------------------------
      int QMLRenderTarget::textureId() const
      {
      return fbo->texture();
      }

      // ---------------------------------------------------------------------------
      QSize QMLRenderTarget::textureSize() const
      {
      return QSize(fbo->width(), fbo->height());
      }

      @

      Turgut Hakkı Özdemir

      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