X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FTexture.cpp;h=97094bc5209c9ba34456ca4aeb7997f5487d8d40;hb=ce1e9a11c89c83356d797c8225369b711513a4da;hp=db45b3d9d13d3d329dd0f13f39276421cfe5fca8;hpb=7582af9fc5f909ef38509c0421e9dbea3c005764;p=l2e.git diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp index db45b3d..97094bc 100644 --- a/src/graphics/Texture.cpp +++ b/src/graphics/Texture.cpp @@ -40,21 +40,38 @@ void Texture::Render(SDL_Surface *dest, const Vector &from, const Vector total = to - from; + const Vector over = total % size; + const Vector target = from + (total - over); + + for (destRect.y = from.Y(); destRect.y < target.Y(); destRect.y += size.Y()) { + for (destRect.x = from.X(); destRect.x < target.X(); destRect.x += size.X()) { + SDL_BlitSurface(surface, &srcRect, dest, &destRect); + } + } + if (over.X() > 0) { + destRect.x = target.X(); + srcRect.w = over.X(); srcRect.h = size.Y(); - destRect.h = size.Y(); - if (destRect.y + destRect.h > to.Y()) { - srcRect.h = to.Y() - destRect.y; - destRect.h = to.Y() - destRect.y; + for (destRect.y = from.Y(); destRect.y < target.Y(); destRect.y += size.Y()) { + SDL_BlitSurface(surface, &srcRect, dest, &destRect); + } + } + if (over.Y() > 0) { + destRect.y = target.Y(); + srcRect.w = size.X(); + srcRect.h = over.Y(); + for (destRect.x = from.X(); destRect.x < target.X(); destRect.x += size.X()) { + SDL_BlitSurface(surface, &srcRect, dest, &destRect); } - for (destRect.x = from.X(); destRect.x < to.X(); destRect.x += size.X()) { - srcRect.w = size.X(); - destRect.w = size.X(); - if (destRect.x + destRect.w > to.X()) { - srcRect.w = to.X() - destRect.x; - destRect.w = to.X() - destRect.x; - } + if (over.X() > 0) { + srcRect.w = over.X(); + srcRect.h = over.Y(); + destRect.x = target.X(); + destRect.y = target.Y(); SDL_BlitSurface(surface, &srcRect, dest, &destRect); } }