uwerat / qpagbm

A Qt platform plugin for running Qt/OpenGL applications offscreen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Qt platform plugin for running Qt/OpenGL applications offscreen

It is supposed to work with Qt versions >= 5.x in UNIXoid environments, where you find an implementation of the Mesa Generic Buffer Management ( gbm ).

This platform allows running OpenGL applications without displaying anything on physical screens. In this respect it is similar to the "offscreen" platform plugin, but without being limited to OpenGL/X11.

The anticipated use cases will postprocess the frames:

My own motivation for this platform plugin is related to the EGLFS/VNC server project.

There are 2 environment variables, that can be used to configure the plugin

- GBM_SCREEN_SIZE

  The size of the platform screen. The default setting is 2000x2000

- GBM_SCALE_WINDOW

  Setting GBM_SCALE_WINDOW to 1 or true has an effect on the devicePixelRatio
  of a window on a GBM off-screen: "ratio = screen->width() / window->width();"

Qt/Quick

For Qt/Quick code might look like this

class FrameHandler : public QObject
{
    public:
        FrameHandler( QQuickWindow* window )
            : m_window( window )
        {
            connect( window, &QQuickWindow::afterRendering,
                     this, &FrameHandler::grabFrame, Qt::DirectConnection );
        }

    private:
        void grabFrame()
        {
            /*
                Still on the scene graph thread, ready to postprocess the frame.
                As an example the code below grabs it into an image.
             */

            extern QImage qt_gl_read_framebuffer(
                const QSize&, bool alpha_format, bool include_alpha );

            auto frameBuffer = qt_gl_read_framebuffer( m_window.size(), false, false );
            ...
        }

        QQuickWindow* m_window;
};

About

A Qt platform plugin for running Qt/OpenGL applications offscreen

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C++ 90.8%Language:QMake 9.2%