Skip to content

background_cleaner

Alexandre Marcireau edited this page Jun 1, 2018 · 3 revisions

In header "../third_party/chameleon/source/background_cleaner.hpp"

chameleon::background_cleaner cleans the background for OpenGL renderers.

namespace chameleon {
    class background_cleaner : public QQuickItem {
        Q_OBJECT
        Q_INTERFACES(QQmlParserStatus)
        Q_PROPERTY(QColor color READ color WRITE setColor)
        public:
        background_cleaner();

        /// set_color defines the clear color.
        /// The color will be passed to the openGL renderer, therefore it should only be set during qml construction.
        virtual void set_color(QColor color);

        /// color returns the currently used color.
        virtual QColor color() const;

        /// componentComplete is called when all the qml values are bound.
        virtual void componentComplete();

        public slots:

        /// sync adapts the renderer to external changes.
        void sync();

        /// cleanup resets the renderer.
        void cleanup();
    };
}
  • color is the color used to fill the window.

chameleon::background_cleaner is associated with a chameleon::background_cleaner_renderer to handle OpenGL calls.

namespace chameleon {
    class background_cleaner_renderer : public QObject, public QOpenGLFunctions_3_3_Core {
        Q_OBJECT
        public:
        background_cleaner_renderer(QColor color);

        /// set_rendering_area defines the clear area.
        virtual void set_rendering_area(QRectF clear_area, int window_height);

        public slots:

        /// paint sends commands to the GPU.
        void paint();
    };
}
  • clear_area is the rectangle to fill with a color, in screen coordinates.
  • window_height is the total window height (used to convert from Qt coordinates to OpenGL coordinates).

A typical QML instantiation has the following syntax:

BackgroundCleaner {
    color: "#000000" // optional, defaults to "#000000"
}
Clone this wiki locally