class new in Git master
#include <Magnum/Ui/RendererGL.h>
RendererGL OpenGL renderer implementation.
Performs renderer state management for OpenGL layer implementations such as BaseLayerGL or TextLayerGL.
Setting up a renderer instance
If you use one of the UserInterfaceGL constructors taking a style, UserInterfaceGL::
ui.setRendererInstance(Containers::pointer<Ui::RendererGL>());
When AbstractUserInterface::
Use with a compositing framebuffer
By default, the RendererGL instance assumes some framebuffer is bound for drawing and it doesn't touch the binding 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::
class MyApplication: public Platform::Application { … private: Ui::UserInterfaceGL _ui{NoCreate}; }; MyApplication::MyApplication(const Arguments& arguments): Platform::Application{…} { /* 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.