|
|
@@ -26,6 +26,10 @@ renderer_impl * get_renderer_impl(driver d) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+namespace {
|
|
|
+ const math::matr4 identity4 = math::matrix::identity<float, 4>();
|
|
|
+}
|
|
|
+
|
|
|
direct_renderer::direct_renderer(driver d) : pimpl(::get_renderer_impl(d)) {}
|
|
|
|
|
|
std::shared_ptr<class manager const> direct_renderer::manager() const {
|
|
|
@@ -35,7 +39,7 @@ std::shared_ptr<class manager const> direct_renderer::manager() const {
|
|
|
void direct_renderer::draw(object const & obj) {
|
|
|
std::vector<vertex> verts;
|
|
|
vertices(verts, obj);
|
|
|
- draw(obj.material, math::matr4(), verts);
|
|
|
+ draw(obj.material, identity4, verts);
|
|
|
}
|
|
|
|
|
|
void direct_renderer::draw(identity<material> material,
|
|
|
@@ -48,7 +52,12 @@ void direct_renderer::clear() { pimpl->clear(); }
|
|
|
void direct_renderer::flush() { pimpl->flush(); }
|
|
|
|
|
|
batch_renderer::batch_renderer(renderer * impl, std::size_t batch_size)
|
|
|
- : impl_(impl), batches_(), batch_size_(batch_size), elements_(0) {}
|
|
|
+ : batch_renderer(impl, identity4, batch_size) {}
|
|
|
+
|
|
|
+batch_renderer::batch_renderer(renderer * impl, math::matr4 const & to_world,
|
|
|
+ std::size_t batch_size)
|
|
|
+ : impl_(impl), batches_(), object_to_world_(to_world),
|
|
|
+ batch_size_(batch_size), elements_(0) {}
|
|
|
|
|
|
batch_renderer::~batch_renderer() { flush(); }
|
|
|
|
|
|
@@ -71,7 +80,7 @@ void batch_renderer::draw(identity<material> material, math::matr4 const &,
|
|
|
|
|
|
void batch_renderer::flush() {
|
|
|
write();
|
|
|
- impl_->flush();
|
|
|
+ // impl_->flush();
|
|
|
}
|
|
|
|
|
|
void batch_renderer::check() {
|
|
|
@@ -80,7 +89,7 @@ void batch_renderer::check() {
|
|
|
|
|
|
void batch_renderer::write() {
|
|
|
for (auto & pair : batches_) {
|
|
|
- impl_->draw(pair.first, math::matrix::identity<float, 4>(), pair.second);
|
|
|
+ impl_->draw(pair.first, object_to_world_, pair.second);
|
|
|
}
|
|
|
batches_.clear();
|
|
|
elements_ = 0;
|