4 * Created on: Oct 21, 2012
10 #include "../sdl/utility.h"
12 using geometry::Vector;
18 const Vector<int> &size,
19 const Vector<int> &offset)
31 void Texture::Render(SDL_Surface *dest, const Vector<int> &from, const Vector<int> &to) const {
33 destRect.x = from.X();
34 destRect.y = from.Y();
35 if (!surface || size == Vector<int>()) {
36 destRect.w = to.X() - from.X();
37 destRect.h = to.Y() - from.Y();
38 SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
43 srcRect.x = offset.X();
44 srcRect.y = offset.Y();
46 for (destRect.y = from.Y(); destRect.y < to.Y(); destRect.y += size.Y()) {
48 destRect.h = size.Y();
49 if (destRect.y + destRect.h > to.Y()) {
50 srcRect.h = to.Y() - destRect.y;
51 destRect.h = to.Y() - destRect.y;
53 for (destRect.x = from.X(); destRect.x < to.X(); destRect.x += size.X()) {
55 destRect.w = size.X();
56 if (destRect.x + destRect.w > to.X()) {
57 srcRect.w = to.X() - destRect.x;
58 destRect.w = to.X() - destRect.x;
60 SDL_BlitSurface(surface, &srcRect, dest, &destRect);