changed(0),
matrices_loaded(false),
shdata_applied(0),
- camera(0),
state_stack(1)
{
state_stack.reserve(16);
reset_state();
excluded.clear();
- camera = c;
- if(camera)
- {
- state->modelview_matrix = camera->get_view_matrix();
- standard_shdata.uniform("projection_matrix", camera->get_projection_matrix());
- }
- else
- {
- state->modelview_matrix = MatrixStack::modelview().top();
- standard_shdata.uniform("projection_matrix", MatrixStack::projection().top());
- }
- changed |= MATRIX|STANDARD_SHDATA;
+ if(c)
+ set_camera(*c);
+}
+
+void Renderer::set_camera(const Camera &c)
+{
+ state->camera = &c;
+ standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix());
+ changed |= STANDARD_SHDATA|LEGACY_PROJECTION;
+ set_matrix(state->camera->get_view_matrix());
}
void Renderer::set_matrix(const Matrix &matrix)
if(state_stack.size()==1)
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();
}
shdata_applied = min<unsigned>(shdata_applied, shdata_stack.size());
changed |= MATRIX;
+ if(state->camera!=old_camera)
+ {
+ standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix());
+ changed |= STANDARD_SHDATA|LEGACY_PROJECTION;
+ }
if(state->lighting!=old_lighting)
{
if(state->lighting)
if(!matrices_loaded)
{
MatrixStack::modelview().push();
- if(camera)
- {
- MatrixStack::projection().push();
- camera->apply();
- }
+ MatrixStack::projection().push();
matrices_loaded = true;
}
+ if(changed&LEGACY_PROJECTION)
+ {
+ MatrixStack::projection() = state->camera->get_projection_matrix();
+ changed &= ~LEGACY_PROJECTION;
+ }
+
if(changed&LEGACY_MATRIX)
{
MatrixStack::modelview() = state->modelview_matrix;
Renderer::State::State():
+ camera(0),
texture(0),
texturing(0),
lowest_effect_texunit(TexUnit::get_n_units()),