Fundamental drawable unit. More...
#include <drawable.hpp>
Public Types | |
typedef std::shared_ptr< Drawable > | Ptr |
Public Member Functions | |
const GeometryResource::Ptr & | Geometry () |
const MaterialResource::Ptr & | Material () |
virtual void | SetMaterial (const MaterialResource::Ptr &material) |
virtual bool | PreDraw () |
Called by the render engine just before rendering the geometry referenced by this object. More... | |
virtual void | PostDraw () |
Called by the render engine just after rendering the geometry referenced by this object. | |
virtual const AxisAlignedBox & | BoundingBox () |
Called by the render engine to determine the axis-aligned bounding box of the Drawable, in the Drawable's own coordinate frame. | |
Static Public Member Functions | |
static Ptr | Create (const GeometryResource::Ptr &geometry, const MaterialResource::Ptr &material) |
Protected Member Functions | |
Drawable (const GeometryResource::Ptr &geometry, const MaterialResource::Ptr &material) | |
void | BoundingBoxChanged () |
Call this when the bounding box changes. | |
Friends | |
class | DrawNode |
class | GeometryResource |
Fundamental drawable unit.
|
inlinevirtual |
Called by the render engine just before rendering the geometry referenced by this object.
At the time this method is called, the material properties have been loaded into the OpenGL state machine. Specifically, the shader program is bound, all shader uniform variables loaded, and OpenGL behavior adjusted (e.g., depth test, line width, etc.) according to the material settings.
This method provides an opportunity for implementing custom rendering behavior just before the render engine renders the geometry, or to override the render engine completely. To do this, create a subclass of Drawable, override the PreDraw() and/or PostDraw() methods, and add your custom Drawable to a DrawNode instead of a standard Drawable.
If this method returns true (the default), then the render engine draws the referenced geometry. If it returns false, then geometry rendering is skipped.