Bind bind_depth_test(i->get_depth_test());
Bind bind_blend(i->get_blend());
renderer.set_lighting(i->get_lighting());
+ renderer.set_clipping(i->get_clipping());
for(vector<Slot>::const_iterator j=renderables.begin(); j!=renderables.end(); ++j)
if(j->passes.empty() || j->passes.count(i->get_tag()))
tag(t),
lighting(0),
depth_test(0),
- blend(0)
+ blend(0),
+ clipping(0)
{ }
void Pipeline::Pass::set_lighting(const Lighting *l)
blend = b;
}
+void Pipeline::Pass::set_clipping(const Clipping *c)
+{
+ clipping =c;
+}
+
Pipeline::Slot::Slot(const Renderable *r):
renderable(r)
class Blend;
class Camera;
+class Clipping;
class DepthTest;
class Lighting;
class PostProcessor;
const Lighting *lighting;
const DepthTest *depth_test;
const Blend *blend;
+ const Clipping *clipping;
public:
Pass(const Tag &);
void set_lighting(const Lighting *);
void set_depth_test(const DepthTest *);
void set_blend(const Blend *);
+ void set_clipping(const Clipping *);
const Lighting *get_lighting() const { return lighting; }
const DepthTest *get_depth_test() const { return depth_test; }
const Blend *get_blend() const { return blend; }
+ const Clipping *get_clipping() const { return clipping; }
};
private:
#include "batch.h"
#include "buffer.h"
#include "camera.h"
+#include "clipping.h"
#include "error.h"
#include "lighting.h"
#include "material.h"
changed |= LIGHTING;
}
+void Renderer::set_clipping(const Clipping *c)
+{
+ state->clipping = c;
+ state->clipping_matrix = mtx_stack.top();
+ if(c)
+ c->update_shader_data(standard_shdata, mtx_stack.top());
+ changed |= CLIPPING;
+}
+
void Renderer::set_shader_program(const Program *p, const ProgramData *d)
{
state->shprog = p;
throw stack_underflow("Renderer::pop_state");
const Lighting *old_lighting = state->lighting;
+ const Clipping *old_clipping = state->clipping;
state_stack.pop_back();
state = &state_stack.back();
if(shdata_stack.size()>state->shdata_count)
state->lighting->update_shader_data(standard_shdata, state->lighting_matrix);
changed |= LIGHTING;
}
+ if(state->clipping!=old_clipping)
+ {
+ if(state->clipping)
+ state->clipping->update_shader_data(standard_shdata, state->clipping_matrix);
+ changed |= CLIPPING;
+ }
}
void Renderer::escape()
}
}
+ if(changed&CLIPPING)
+ {
+ if(state->clipping)
+ {
+ if(legacy_bindings)
+ {
+ MatrixStack::modelview() = state->clipping_matrix;
+ state->clipping->bind(true);
+ changed = (changed&~CLIPPING)|LEGACY_MATRIX;
+ }
+ else
+ state->clipping->bind(false);
+ }
+ else
+ Clipping::unbind();
+ }
+
if(state->shprog)
{
bool shprog_changed = (state->shprog!=Program::current());
lowest_effect_texunit(TexUnit::get_n_units()),
material(0),
lighting(0),
+ clipping(0),
shprog(0),
shdata_count(0),
mesh(0),
class Batch;
class Buffer;
class Camera;
+class Clipping;
class Material;
class Mesh;
class Lighting;
const Material *material;
const Lighting *lighting;
Matrix lighting_matrix;
+ const Clipping *clipping;
+ Matrix clipping_matrix;
const Program *shprog;
unsigned shdata_count;
const Mesh *mesh;
MODERN_MATRIX = 2,
MATRIX = LEGACY_MATRIX|MODERN_MATRIX,
LIGHTING = 4,
- SHADER_DATA = 8
+ CLIPPING = 8,
+ SHADER_DATA = 16
};
MtxStack mtx_stack;
void set_material(const Material *);
void set_lighting(const Lighting *);
+ void set_clipping(const Clipping *);
/** Sets the shader program to use. An initial set of data can be set as
well, with the same semantics as add_shader_data. */