class new in Git master
#include <Magnum/Ui/RendererGL.h>
RendererGL OpenGL renderer implementation.
Meant to be supplied to AbstractUserInterface::
The renderer expects pre-multiplied blending set up, as shown below. Internally it enables GL::
GL::Renderer::setBlendFunction( GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha);
Use with a compositing framebuffer
By default, the RendererGL instance assumes some framebuffer is bound for drawing and it doesn't touch it in any way. Layers that implement compositing operations however need a framebuffer which can be both drawn into and read from, which is achieved by constructing the renderer with Flag::
Ui::UserInterfaceGL _ui{NoCreate}; … /* Create a renderer with a compositing framebuffer as the first thing */ _ui.setRendererInstance(Containers::pointer<Ui::RendererGL>( Ui::RendererGL::Flag::CompositingFramebuffer)); /* Then add appropriate compositing layers, set a style, etc */ _ui .setSize(…) .setStyle(…) …;
With the flag enabled, the application is then responsible for clearing the compositingFramebuffer() at frame start, drawing all content underneath the UI to it, and ultimately blitting it back to the main / default application framebuffer after the UI is drawn:
void MyApplication::drawEvent() { _ui.renderer().compositingFramebuffer().clear(GL::FramebufferClear::Color); // Render content underneath the UI to the compositing framebuffer here ... _ui.draw(); GL::AbstractFramebuffer::blit( _ui.renderer().compositingFramebuffer(), GL::defaultFramebuffer, GL::defaultFramebuffer.viewport(), GL::FramebufferBlit::Color); swapBuffers(); redraw(); }
Base classes
- class AbstractRenderer new in Git master
- Base for renderer implementations.
Public types
- enum class Flag: UnsignedByte { CompositingFramebuffer = 1 << 0 }
- Renderer flag.
-
using Flags = Containers::
EnumSet<Flag> - Renderer flags.
Constructors, destructors, conversion operators
- RendererGL(Flags flags = {}) explicit
- Constructor.
- RendererGL(const RendererGL&) deleted
- Copying is not allowed.
- RendererGL(RendererGL&&) noexcept
- Move constructor.
Public functions
- auto operator=(const RendererGL&) -> RendererGL& deleted
- Copying is not allowed.
- auto operator=(RendererGL&&) -> RendererGL& noexcept
- Move assignment.
- auto flags() const -> Flags
- Renderer flags.
-
auto compositingFramebuffer() -> GL::
Framebuffer& - Compositing framebuffer instance.
-
auto compositingFramebuffer() const -> const GL::
Framebuffer& -
auto compositingTexture() -> GL::
Texture2D& - Compositing framebuffer texture instance.
-
auto compositingTexture() const -> const GL::
Texture2D&
Enum documentation
enum class Magnum:: Ui:: RendererGL:: Flag: UnsignedByte
Renderer flag.
Enumerators | |
---|---|
CompositingFramebuffer |
Create a framebuffer to be used as a target for drawing all UI contents and a source for compositing operations implemented by various layers. The framebuffer, with a single GL:: Then application is then responsible for clearing the compositingFramebuffer() at frame start, drawing all content underneath the UI to it, and ultimately blitting it back to the main / default application framebuffer after the UI is drawn. |
Typedef documentation
typedef Containers:: EnumSet<Flag> Magnum:: Ui:: RendererGL:: Flags
Renderer flags.
Function documentation
Magnum:: Ui:: RendererGL:: RendererGL(RendererGL&&) noexcept
Move constructor.
Performs a destructive move, i.e. the original object isn't usable afterwards anymore.
GL:: Framebuffer& Magnum:: Ui:: RendererGL:: compositingFramebuffer()
Compositing framebuffer instance.
Available only if the renderer was constructed with Flag::
With a compositing framebuffer enabled, the application is responsible for clearing the framebuffer at frame start, drawing all content underneath the UI to it, and ultimately blitting it back to the main / default application framebuffer after the UI is drawn.
const GL:: Framebuffer& Magnum:: Ui:: RendererGL:: compositingFramebuffer() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
GL:: Texture2D& Magnum:: Ui:: RendererGL:: compositingTexture()
Compositing framebuffer texture instance.
Available only if the renderer was constructed with Flag::
The texture is meant to be accessed inside an AbstractLayer::
const GL:: Texture2D& Magnum:: Ui:: RendererGL:: compositingTexture() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Debug& operator<<(Debug& debug,
RendererGL:: Flag value) new in Git master
Debug output operator.
Debug& operator<<(Debug& debug,
RendererGL:: Flags value) new in Git master
Debug output operator.