https://github.com/uwerat/qpagbm
A Qt platform plugin for running Qt/OpenGL applications offscreen
https://github.com/uwerat/qpagbm
gbm qpa qt qtquick
Last synced: about 1 year ago
JSON representation
A Qt platform plugin for running Qt/OpenGL applications offscreen
- Host: GitHub
- URL: https://github.com/uwerat/qpagbm
- Owner: uwerat
- License: bsd-3-clause
- Created: 2022-05-10T09:24:36.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-29T14:02:20.000Z (almost 4 years ago)
- Last Synced: 2025-03-22T21:07:41.330Z (over 1 year ago)
- Topics: gbm, qpa, qt, qtquick
- Language: C++
- Homepage:
- Size: 24.4 KB
- Stars: 13
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A Qt platform plugin for running Qt/OpenGL applications offscreen
- https://doc.qt.io/qt-6/qpa.html
- https://www.khronos.org/registry/EGL/extensions/MESA/EGL_MESA_platform_gbm.txt
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:
- remote desktop solutions ( f.e https://github.com/uwerat/vnc-eglfs )
- "screen" recorder
- test/development scenarios
- ...
My own motivation for this platform plugin is related to the
[EGLFS/VNC server project]( https://github.com/uwerat/vnc-eglfs ).
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;
};
```