namespace Msp {
namespace GL {
-Effect::Effect(const Renderable &r):
+Effect::Effect(Renderable &r):
renderable(r)
{
enabled_passes.insert(Tag());
class Effect: public Renderable
{
protected:
- const Renderable &renderable;
+ Renderable &renderable;
std::set<Tag> enabled_passes;
- Effect(const Renderable &);
+ Effect(Renderable &);
public:
virtual ~Effect() { }
namespace Msp {
namespace GL {
-void InstanceScene::add(const Renderable &r)
+void InstanceScene::add(Renderable &r)
{
renderables[r.get_instance_key()].insert(&r);
}
-void InstanceScene::remove(const Renderable &r)
+void InstanceScene::remove(Renderable &r)
{
InstanceMap::iterator i = renderables.find(r.get_instance_key());
if(i!=renderables.end())
class InstanceScene: public Scene
{
private:
- typedef std::set<const Renderable *> RenderableSet;
+ typedef std::set<Renderable *> RenderableSet;
typedef std::map<long, RenderableSet> InstanceMap;
InstanceMap renderables;
public:
- virtual void add(const Renderable &);
- virtual void remove(const Renderable &);
+ virtual void add(Renderable &);
+ virtual void remove(Renderable &);
virtual void setup_frame() const;
virtual void finish_frame() const;
glDeleteQueries(queries.size(), &queries[0]);
}
-void OccludedScene::add(const Renderable &r)
+void OccludedScene::add(Renderable &r)
{
renderables.insert(&r);
cache_dirty = true;
}
-void OccludedScene::remove(const Renderable &r)
+void OccludedScene::remove(Renderable &r)
{
renderables.erase(&r);
cache_dirty = true;
private:
struct OccludedRenderable
{
- const Renderable *renderable;
+ Renderable *renderable;
const Geometry::BoundingSphere<float, 3> *bounding_sphere;
bool in_frustum;
bool occluder;
OccludedRenderable();
};
- typedef std::set<const Renderable *> RenderableSet;
+ typedef std::set<Renderable *> RenderableSet;
typedef std::vector<OccludedRenderable> OccludedArray;
Mesh bounding_mesh;
OccludedScene();
~OccludedScene();
- virtual void add(const Renderable &);
- virtual void remove(const Renderable &);
+ virtual void add(Renderable &);
+ virtual void remove(Renderable &);
virtual void render(Renderer &, const Tag &) const;
};
namespace Msp {
namespace GL {
-void OrderedScene::add(const Renderable &r)
+void OrderedScene::add(Renderable &r)
{
renderables.push_back(&r);
}
-void OrderedScene::remove(const Renderable &r)
+void OrderedScene::remove(Renderable &r)
{
RenderableList::iterator end = std::remove(renderables.begin(), renderables.end(), &r);
renderables.erase(end, renderables.end());
}
-void OrderedScene::prepend(const Renderable &r)
+void OrderedScene::prepend(Renderable &r)
{
renderables.push_front(&r);
}
-void OrderedScene::insert(unsigned index, const Renderable &r)
+void OrderedScene::insert(unsigned index, Renderable &r)
{
RenderableList::iterator i = renderables.begin();
for(; (i!=renderables.end() && index); ++i, --index) ;
renderables.insert(i, &r);
}
-void OrderedScene::insert_after(const Renderable &after, const Renderable &r)
+void OrderedScene::insert_after(Renderable &after, Renderable &r)
{
RenderableList::iterator i = renderables.begin();
for(; (i!=renderables.end() && *i!=&after); ++i) ;
class OrderedScene: public Scene
{
private:
- typedef std::list<const Renderable *> RenderableList;
+ typedef std::list<Renderable *> RenderableList;
RenderableList renderables;
public:
- virtual void add(const Renderable &);
- virtual void remove(const Renderable &);
- void prepend(const Renderable &);
- void insert(unsigned, const Renderable &);
- void insert_after(const Renderable &, const Renderable &);
+ virtual void add(Renderable &);
+ virtual void remove(Renderable &);
+ void prepend(Renderable &);
+ void insert(unsigned, Renderable &);
+ void insert_after(Renderable &, Renderable &);
virtual void setup_frame() const;
virtual void finish_frame() const;
return passes.back();
}
-void Pipeline::add_renderable(const Renderable &r)
+void Pipeline::add_renderable(Renderable &r)
{
for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
if(i->renderable==&r)
renderables.push_back(&r);
}
-void Pipeline::add_renderable_for_pass(const Renderable &r, const Tag &tag)
+void Pipeline::add_renderable_for_pass(Renderable &r, const Tag &tag)
{
for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
if(i->renderable==&r)
renderables.back().passes.insert(tag);
}
-void Pipeline::remove_renderable(const Renderable &r)
+void Pipeline::remove_renderable(Renderable &r)
{
for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
if(i->renderable==&r)
}
}
-Pipeline::Pass &Pipeline::add_pass(const Tag &tag, const Renderable &r)
+Pipeline::Pass &Pipeline::add_pass(const Tag &tag, Renderable &r)
{
passes.push_back(Pass(tag, &r));
return passes.back();
}
-Pipeline::Pass::Pass(const Tag &t, const Renderable *r):
+Pipeline::Pass::Pass(const Tag &t, Renderable *r):
tag(t),
lighting(0),
depth_test(0),
}
-Pipeline::Slot::Slot(const Renderable *r):
+Pipeline::Slot::Slot(Renderable *r):
renderable(r)
{ }
const DepthTest *depth_test;
const Blend *blend;
const Clipping *clipping;
- const Renderable *renderable;
+ Renderable *renderable;
public:
- Pass(const Tag &, const Renderable *);
+ Pass(const Tag &, Renderable *);
const Tag &get_tag() const { return tag; }
const DepthTest *get_depth_test() const { return depth_test; }
const Blend *get_blend() const { return blend; }
const Clipping *get_clipping() const { return clipping; }
- const Renderable *get_renderable() const { return renderable; }
+ Renderable *get_renderable() const { return renderable; }
};
private:
struct Slot
{
- const Renderable *renderable;
+ Renderable *renderable;
std::set<Tag> passes;
- Slot(const Renderable *);
+ Slot(Renderable *);
};
typedef std::list<Pass> PassList;
// Deprecated
void set_camera(const Camera *);
Pass &add_pass(const Tag &tag);
- void add_renderable(const Renderable &);
- void add_renderable_for_pass(const Renderable &, const Tag &);
- void remove_renderable(const Renderable &);
+ void add_renderable(Renderable &);
+ void add_renderable_for_pass(Renderable &, const Tag &);
+ void remove_renderable(Renderable &);
/** Adds a pass to the pipeline. It's permissible to add the same
Renderable multiple times. */
- Pass &add_pass(const Tag &, const Renderable &);
+ Pass &add_pass(const Tag &, Renderable &);
/** Adds a postprocessor to the pipeline. */
void add_postprocessor(PostProcessor &);
public:
virtual ~Scene();
- virtual void add(const Renderable &) = 0;
- virtual void remove(const Renderable &) = 0;
+ virtual void add(Renderable &) = 0;
+ virtual void remove(Renderable &) = 0;
protected:
bool setup_frustum(const Renderer &) const;
namespace Msp {
namespace GL {
-ShadowMap::ShadowMap(unsigned s, const Renderable &r, const Light &l):
+ShadowMap::ShadowMap(unsigned s, Renderable &r, const Light &l):
Effect(r),
size(s),
light(l),
mutable bool rendered;
public:
- ShadowMap(unsigned, const Renderable &, const Light &);
+ ShadowMap(unsigned, Renderable &, const Light &);
/** Sets the ShadowMap target point and radius. The transformation matrix is
computed so that a sphere with the specified parameters will be completely
namespace Msp {
namespace GL {
-void SimpleScene::add(const Renderable &r)
+void SimpleScene::add(Renderable &r)
{
// Add to cache as well if the cache is valid
if(renderables.insert(&r).second && !cache.empty())
cache.push_back(&r);
}
-void SimpleScene::remove(const Renderable &r)
+void SimpleScene::remove(Renderable &r)
{
renderables.erase(&r);
cache.clear();
class SimpleScene: public Scene
{
private:
- typedef std::set<const Renderable *> RenderableSet;
- typedef std::vector<const Renderable *> RenderableArray;
+ typedef std::set<Renderable *> RenderableSet;
+ typedef std::vector<Renderable *> RenderableArray;
RenderableSet renderables;
mutable RenderableArray cache;
public:
- virtual void add(const Renderable &);
- virtual void remove(const Renderable &);
+ virtual void add(Renderable &);
+ virtual void remove(Renderable &);
private:
void populate_cache() const;
camera = c;
}
-void View::set_content(const Renderable *r)
+void View::set_content(Renderable *r)
{
content = r;
}
Graphics::GLContext &context;
Framebuffer ⌖
Camera *camera;
- const Renderable *content;
+ Renderable *content;
std::list<Camera *> synced_cameras;
public:
float get_aspect() const { return static_cast<float>(get_width())/get_height(); }
void set_camera(Camera *);
- void set_content(const Renderable *);
+ void set_content(Renderable *);
// Deprecated
void synchronize_camera_aspect(Camera &);
reference(FURTHEST)
{ }
-void ZSortedScene::add(const Renderable &r)
+void ZSortedScene::add(Renderable &r)
{
if(renderables.insert(&r).second && !sorted_cache.empty())
sorted_cache.push_back(&r);
}
-void ZSortedScene::remove(const Renderable &r)
+void ZSortedScene::remove(Renderable &r)
{
renderables.erase(&r);
sorted_cache.clear();
}
-ZSortedScene::SortedRenderable::SortedRenderable(const Renderable *r):
+ZSortedScene::SortedRenderable::SortedRenderable(Renderable *r):
renderable(r),
in_frustum(false),
depth(0.0f)
private:
struct SortedRenderable
{
- const Renderable *renderable;
+ Renderable *renderable;
bool in_frustum;
float depth;
- SortedRenderable(const Renderable *);
+ SortedRenderable(Renderable *);
bool operator<(const SortedRenderable &o) const { return depth<o.depth; }
};
- typedef std::set<const Renderable *> RenderableSet;
+ typedef std::set<Renderable *> RenderableSet;
typedef std::vector<SortedRenderable> SortedArray;
RenderableSet renderables;
public:
ZSortedScene();
- virtual void add(const Renderable &);
- virtual void remove(const Renderable &);
+ virtual void add(Renderable &);
+ virtual void remove(Renderable &);
/// Sets the sort order. Default is back to front.
void set_order(SortOrder);