| 1 | // SuperTux |
| 2 | // Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com> |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | #include "video/surface_batch.hpp" |
| 18 | |
| 19 | #include "math/rectf.hpp" |
| 20 | #include "video/surface.hpp" |
| 21 | |
| 22 | SurfaceBatch::SurfaceBatch(const SurfacePtr& surface) : |
| 23 | m_surface(surface), |
| 24 | m_srcrects(), |
| 25 | m_dstrects(), |
| 26 | m_angles() |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | void |
| 31 | SurfaceBatch::draw(const Vector& pos, float angle) |
| 32 | { |
| 33 | m_srcrects.emplace_back(Rectf(0, 0, |
| 34 | static_cast<float>(m_surface->get_width()), |
| 35 | static_cast<float>(m_surface->get_height()))); |
| 36 | m_dstrects.emplace_back(Rectf(pos, |
| 37 | Sizef(static_cast<float>(m_surface->get_width()), |
| 38 | static_cast<float>(m_surface->get_height())))); |
| 39 | m_angles.emplace_back(angle); |
| 40 | } |
| 41 | |
| 42 | void |
| 43 | SurfaceBatch::draw(const Rectf& dstrect, float angle) |
| 44 | { |
| 45 | m_srcrects.emplace_back(Rectf(0, 0, |
| 46 | static_cast<float>(m_surface->get_width()), |
| 47 | static_cast<float>(m_surface->get_height()))); |
| 48 | m_dstrects.emplace_back(dstrect); |
| 49 | m_angles.emplace_back(angle); |
| 50 | } |
| 51 | |
| 52 | void |
| 53 | SurfaceBatch::draw(const Rectf& srcrect, const Rectf& dstrect, float angle) |
| 54 | { |
| 55 | m_srcrects.emplace_back(srcrect); |
| 56 | m_dstrects.emplace_back(dstrect); |
| 57 | m_angles.emplace_back(angle); |
| 58 | } |
| 59 | |
| 60 | /* EOF */ |
| 61 | |