4 * Created on: Oct 21, 2012
10 #include "../sdl/utility.h"
12 using geometry::Vector;
26 void Texture::Render(SDL_Surface *dest, const Vector<int> &from, const Vector<int> &to) const {
28 destRect.x = from.X();
29 destRect.y = from.Y();
30 if (!surface || size == Vector<int>()) {
31 destRect.w = to.X() - from.X();
32 destRect.h = to.Y() - from.Y();
33 SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
38 srcRect.x = offset.X();
39 srcRect.y = offset.Y();
41 for (destRect.y = from.Y(); destRect.y < to.Y(); destRect.y += size.Y()) {
43 destRect.h = size.Y();
44 if (destRect.y + destRect.h > to.Y()) {
45 srcRect.h = to.Y() - destRect.y;
46 destRect.h = to.Y() - destRect.y;
48 for (destRect.x = from.X(); destRect.x < to.X(); destRect.x += size.X()) {
50 destRect.w = size.X();
51 if (destRect.x + destRect.w > to.X()) {
52 srcRect.w = to.X() - destRect.x;
53 destRect.w = to.X() - destRect.x;
55 SDL_BlitSurface(surface, &srcRect, dest, &destRect);