Subclass this to add content in the scene and draw things. More...
#include <sceneview/renderer.hpp>
Public Slots | |
void | SetEnabled (bool enabled) |
Signals | |
void | EnableChanged (bool enabled) |
Public Member Functions | |
Renderer (const QString &name, QObject *parent=0) | |
Construct a new renderer with the specified name. | |
Renderer (const Renderer &)=delete | |
Renderer & | operator= (const Renderer &)=delete |
const QString & | Name () const |
Retrieve the renderer name. | |
Viewport * | GetViewport () |
Retrieve the viewport that manages this renderer. | |
Scene::Ptr | GetScene () |
Retrieve the Scene graph used by the Sceneview rendering engine. | |
ResourceManager::Ptr | GetResources () |
Retrieve the ResourceManager for the scene. | |
GroupNode * | GetBaseNode () |
Retrieve the group node assigned to this renderer. More... | |
virtual void | InitializeGL () |
Override to acquire OpenGL resources required by the Renderer. More... | |
virtual void | RenderBegin () |
Called at the start of rendering, just before the scene is rendered. More... | |
virtual void | RenderEnd () |
Called at the end of rendering, just after the scene has finished rendering. More... | |
virtual void | ShutdownGL () |
Override this to release any OpenGL resources acquired by the renderer. More... | |
virtual QWidget * | GetWidget () |
Override this to provide a custom UI for your renderer. | |
bool | Enabled () const |
virtual QVariant | SaveState () |
Called by the viewport to save the renderer state. More... | |
virtual void | LoadState (const QVariant &val) |
Called by the viewport to restore the renderer state. More... | |
Protected Member Functions | |
virtual void | OnEnableChanged (bool enabled) |
Friends | |
class | Viewport |
Subclass this to add content in the scene and draw things.
The primary way to add content into a scene and draw using Sceneview is to create subclasses of Renderer and add them to a Viewport.
There are two ways to draw using a subclass of Renderer:
The Renderer class provides a few mechanisms to support using the Sceneview rendering engine.
If you want to bypass the Sceneview rendering engine, you can issue direct calls to OpenGL by overriding RenderBegin() and RenderEnd().
Once each render cycle, the following happens:
When a renderer is first created, there is no guarantee that the OpenGL context has been created or activated. The first time this is guaranteed is when InitializeGL() is called.
Similarly, the OpenGL context may be gone by the time the Renderer destructor is called. Instead of releasing OpenGL resources in the object destructor, do so by overriding ShutdownGL().
If you want to save the state of your renderer across sessions, you can override SaveState() and LoadState() to return a QVariant that will be used whenever the Viewer itself is saving / loading state.
|
inline |
If the renderer is disabled, then RenderBegin() and RenderEnd() are not called during the render cycle. Additinally, the renderer's base node visibility is automatically set to match wheter or not the renderer is enabled.
GroupNode* sv::Renderer::GetBaseNode | ( | ) |
Retrieve the group node assigned to this renderer.
The visibility of the base node is automatically toggled when the renderer is enabled or disabled. Thus, any nodes that the renderer creates that have the base node as an ancestor have their visibility automatically managed by the base node.
|
inlinevirtual |
Override to acquire OpenGL resources required by the Renderer.
At the time this method is invoked, the following are true:
It is guaranteed that this method will be called exactly once, and before any call to RenderBegin().
Reimplemented in sv::GridRenderer.
|
inlinevirtual |
Called by the viewport to restore the renderer state.
If your renderer has any adjustable settings that you want to persist across sessions, then load them from the passed in QVariant here.
|
inlinevirtual |
Called at the start of rendering, just before the scene is rendered.
When this method is called, the following are true:
In other words, the matrix stack is setup such that you can render in "world" coordinates.
You can issue legacy fixed-function OpenGL commands (e.g., glColor3f(), glBegin(), glVertex3f(), etc. calls)
You can also use your own vertex and fragment shaders.
Reimplemented in sv::GridRenderer.
|
inlinevirtual |
Called at the end of rendering, just after the scene has finished rendering.
This method has the same guarantees as RenderBegin().
|
inlinevirtual |
Called by the viewport to save the renderer state.
If your renderer has any adjustable settings that you want to persist, then save them into the returned QVariant.
|
inlinevirtual |
Override this to release any OpenGL resources acquired by the renderer.
This method is called when the rendering engine is shutting down, just before the OpenGL context is destroyed.