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. Get Pixels buffer of Desktop QtOpenGL
QtWS25 Last Chance

Get Pixels buffer of Desktop QtOpenGL

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.1k 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.
  • O Offline
    O Offline
    OptimusDev
    wrote on last edited by
    #1

    Hello,

    I'm currently developing a Windows application.
    I would like to convert the current screen of the computer into a pixel framebuffer and be able to send it into the network in order to simulate a mirroring.

    I am currently using :

    QScreen *screen = QGuiApplication::primaryScreen();
    QWindow *window = windowHandle()
    screen = window->screen();
    originalPixmap = screen->grabWindow(0);
    

    I noticed that is not very efficient, it takes a lot of CPU. And if I want to sent this huge packet into network it would take a while.
    I'm looking for the same method but with OpenGL.

    But how can I do this with QtOpenGL ?
    I saw this function that can be useful but I don't know how to use it for this purpose :

    QOpenGLFunctions::glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
    

    Or is there any solution that can be faster ?

    Thank you very much for your help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are you trying to re-implement something like VNC ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • O Offline
        O Offline
        OptimusDev
        wrote on last edited by
        #3

        Hello SGaist,

        Thank you for your answer.
        Yes I'm trying to do something similar.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then you should rather use one of the available libraries that already implement the protocol. Currently you are likely trying to grab Full HD frames maybe even 4k to send over the network. You already saw that it's pretty harsh.

          One thing that is not clear is: do you want to do it for the whole desktop or only for your application ? In the second case, Qt 5 has a VNC backend since 5.8.0.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          O 1 Reply Last reply
          0
          • SGaistS SGaist

            Then you should rather use one of the available libraries that already implement the protocol. Currently you are likely trying to grab Full HD frames maybe even 4k to send over the network. You already saw that it's pretty harsh.

            One thing that is not clear is: do you want to do it for the whole desktop or only for your application ? In the second case, Qt 5 has a VNC backend since 5.8.0.

            O Offline
            O Offline
            OptimusDev
            wrote on last edited by
            #5

            @SGaist
            The goal is to reimplement these protocols.
            I would like to know then how do these protocols works.
            Maybe I can compress the FULL HD image after I did take the screenshot.
            For me, a loop of screenshot is not very efficient, it should have a better way to do it.
            I'm looking an other method to do it without using a lot of CPU, maybe a library like QTOpenGL can do this.
            Does this library (QTOpenGL) can take picture from a PID or something like that ?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              No it can't and it's outside of its scope.

              IIRC ffmpeg might be of help.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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