Those no longer have any special state of their own and can be set as
ProgramData instead.
{
for(vector<TextureSlot>::const_iterator i=textures.begin(); i!=textures.end(); ++i)
renderer.set_texture(i->tag, i->texture, i->sampler);
{
for(vector<TextureSlot>::const_iterator i=textures.begin(); i!=textures.end(); ++i)
renderer.set_texture(i->tag, i->texture, i->sampler);
- renderer.set_material(material);
renderer.set_shader_program(shprog, shdata.get());
renderer.set_shader_program(shprog, shdata.get());
+ if(material)
+ renderer.add_shader_data(material->get_shader_data());
renderer.set_reverse_winding(back_faces);
}
renderer.set_reverse_winding(back_faces);
}
void Renderer::set_material(const Material *m)
{
void Renderer::set_material(const Material *m)
{
- state->material = m;
- changed |= MATERIAL_SHDATA;
+ if(m)
+ add_shader_data(m->get_shader_data());
}
void Renderer::set_lighting(const Lighting *l)
{
}
void Renderer::set_lighting(const Lighting *l)
{
- state->lighting = l;
- changed |= LIGHTING_SHDATA;
+ if(l)
+ add_shader_data(l->get_shader_data());
}
void Renderer::set_clipping(const Clipping *c)
}
void Renderer::set_clipping(const Clipping *c)
throw stack_underflow("Renderer::pop_state");
const Camera *old_camera = state->camera;
throw stack_underflow("Renderer::pop_state");
const Camera *old_camera = state->camera;
- const Lighting *old_lighting = state->lighting;
const Clipping *old_clipping = state->clipping;
state_stack.pop_back();
state = &state_stack.back();
const Clipping *old_clipping = state->clipping;
state_stack.pop_back();
state = &state_stack.back();
bool camera_changed = (state->camera!=old_camera);
if(camera_changed)
changed |= CAMERA_SHDATA;
bool camera_changed = (state->camera!=old_camera);
if(camera_changed)
changed |= CAMERA_SHDATA;
- if(state->lighting!=old_lighting)
- changed |= LIGHTING_SHDATA;
if(state->clipping!=old_clipping)
changed |= CLIPPING_SHDATA;
}
if(state->clipping!=old_clipping)
changed |= CLIPPING_SHDATA;
}
changed &= ~CAMERA_SHDATA;
}
changed &= ~CAMERA_SHDATA;
}
- if(state->material && ((changed&MATERIAL_SHDATA) || shprog_changed))
- {
- state->material->get_shader_data().apply();
- changed &= ~MATERIAL_SHDATA;
- }
-
- if(state->lighting && ((changed&LIGHTING_SHDATA) || shprog_changed))
- {
- state->lighting->get_shader_data().apply();
- changed &= ~LIGHTING_SHDATA;
- }
-
if(state->clipping && ((changed&CLIPPING_SHDATA) || shprog_changed))
{
state->clipping->get_shader_data().apply();
if(state->clipping && ((changed&CLIPPING_SHDATA) || shprog_changed))
{
state->clipping->get_shader_data().apply();
camera(0),
texture_count(0),
lowest_effect_texunit(TexUnit::get_n_units()),
camera(0),
texture_count(0),
lowest_effect_texunit(TexUnit::get_n_units()),
- material(0),
- lighting(0),
clipping(0),
shprog(0),
shdata_count(0),
clipping(0),
shprog(0),
shdata_count(0),
Matrix model_matrix;
unsigned texture_count;
unsigned lowest_effect_texunit;
Matrix model_matrix;
unsigned texture_count;
unsigned lowest_effect_texunit;
- const Material *material;
- const Lighting *lighting;
const Clipping *clipping;
const Program *shprog;
unsigned shdata_count;
const Clipping *clipping;
const Program *shprog;
unsigned shdata_count;
{
MATRIX = 2,
SHADER_DATA = 16,
{
MATRIX = 2,
SHADER_DATA = 16,
STANDARD_SHDATA = 64,
CAMERA_SHDATA = 128,
STANDARD_SHDATA = 64,
CAMERA_SHDATA = 128,
DEPRECATED void set_texturing(const Texturing *);
DEPRECATED unsigned allocate_effect_texunit();
#pragma GCC diagnostic pop
DEPRECATED void set_texturing(const Texturing *);
DEPRECATED unsigned allocate_effect_texunit();
#pragma GCC diagnostic pop
- void set_material(const Material *);
+ DEPRECATED void set_material(const Material *);
- void set_lighting(const Lighting *);
+ DEPRECATED 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
void set_clipping(const Clipping *);
/** Sets the shader program to use. An initial set of data can be set as
- renderer.set_lighting(i->get_lighting());
+ if (const Lighting *lighting = i->get_lighting())
+ renderer.add_shader_data(lighting->get_shader_data());
renderer.set_clipping(i->get_clipping());
if(const Renderable *renderable = i->get_renderable())
renderer.set_clipping(i->get_clipping());
if(const Renderable *renderable = i->get_renderable())