+ pipeline_state.set_framebuffer(state->framebuffer);
+ pipeline_state.set_viewport(state->viewport);
+ pipeline_state.set_scissor(state->scissor);
+
+ bool shprog_changed = (state->shprog!=pipeline_state.get_shader_program());
+ pipeline_state.set_shader_program(state->shprog);
+
+ if(state->vertex_setup)
+ {
+ if(const VertexArray *array = state->vertex_setup->get_vertex_array())
+ array->refresh();
+ if(const VertexArray *array = state->vertex_setup->get_instance_array())
+ array->refresh();
+ }
+ pipeline_state.set_vertex_setup(state->vertex_setup);
+
+ pipeline_state.set_front_face(state->front_face);
+ pipeline_state.set_face_cull(state->face_cull);
+
+ if(state->texture_count<texture_stack.size())
+ flush_textures();
+
+ for(const BoundTexture &t: texture_stack)
+ {
+ int unit = (t.tag.id ? state->shprog->get_uniform_binding(t.tag) : t.unit);
+ if(unit>=0)
+ pipeline_state.set_texture(unit, t.texture, t.sampler);
+ }
+