../src/graphics/Gauge.cpp \
../src/graphics/Menu.cpp \
../src/graphics/SimpleAnimation.cpp \
-../src/graphics/Sprite.cpp
+../src/graphics/Sprite.cpp \
+../src/graphics/Texture.cpp
OBJS += \
./src/graphics/Animation.o \
./src/graphics/Gauge.o \
./src/graphics/Menu.o \
./src/graphics/SimpleAnimation.o \
-./src/graphics/Sprite.o
+./src/graphics/Sprite.o \
+./src/graphics/Texture.o
CPP_DEPS += \
./src/graphics/Animation.d \
./src/graphics/Gauge.d \
./src/graphics/Menu.d \
./src/graphics/SimpleAnimation.d \
-./src/graphics/Sprite.d
+./src/graphics/Sprite.d \
+./src/graphics/Texture.d
# Each subdirectory must supply rules for building sources it contributes
../src/graphics/Gauge.cpp \
../src/graphics/Menu.cpp \
../src/graphics/SimpleAnimation.cpp \
-../src/graphics/Sprite.cpp
+../src/graphics/Sprite.cpp \
+../src/graphics/Texture.cpp
OBJS += \
./src/graphics/Animation.o \
./src/graphics/Gauge.o \
./src/graphics/Menu.o \
./src/graphics/SimpleAnimation.o \
-./src/graphics/Sprite.o
+./src/graphics/Sprite.o \
+./src/graphics/Texture.o
CPP_DEPS += \
./src/graphics/Animation.d \
./src/graphics/Gauge.d \
./src/graphics/Menu.d \
./src/graphics/SimpleAnimation.d \
-./src/graphics/Sprite.d
+./src/graphics/Sprite.d \
+./src/graphics/Texture.d
# Each subdirectory must supply rules for building sources it contributes
--- /dev/null
+/*
+ * Texture.cpp
+ *
+ * Created on: Oct 21, 2012
+ * Author: holy
+ */
+
+#include "Texture.h"
+
+#include "../sdl/utility.h"
+
+using geometry::Vector;
+
+namespace graphics {
+
+Texture::Texture()
+: surface(0) {
+
+}
+
+Texture::~Texture() {
+
+}
+
+
+void Texture::Render(SDL_Surface *dest, const Vector<int> &from, const Vector<int> &to) const {
+ SDL_Rect destRect;
+ destRect.x = from.X();
+ destRect.y = from.Y();
+ if (!surface || size == Vector<int>()) {
+ destRect.w = to.X() - from.X();
+ destRect.h = to.Y() - from.Y();
+ SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ return;
+ }
+
+ SDL_Rect srcRect;
+ srcRect.x = offset.X();
+ srcRect.y = offset.Y();
+
+ for (destRect.y = from.Y(); destRect.y < to.Y(); destRect.y += size.Y()) {
+ 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.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;
+ }
+ SDL_BlitSurface(surface, &srcRect, dest, &destRect);
+ }
+ }
+}
+
+}
--- /dev/null
+/*
+ * Texture.h
+ *
+ * Created on: Oct 21, 2012
+ * Author: holy
+ */
+
+#ifndef GRAPHICS_TEXTURE_H_
+#define GRAPHICS_TEXTURE_H_
+
+#include "../geometry/Vector.h"
+
+#include <SDL.h>
+
+namespace graphics {
+
+class Texture {
+
+public:
+ Texture();
+ ~Texture();
+
+public:
+ void Render(SDL_Surface *dest, const geometry::Vector<int> &from, const geometry::Vector<int> &to) const;
+
+public:
+ void SetSurface(SDL_Surface *s) { surface = s; }
+ void SetOffset(const geometry::Vector<int> &o) { offset = o; }
+ void SetSize(const geometry::Vector<int> &s) { size = s; }
+
+private:
+ SDL_Surface *surface;
+ geometry::Vector<int> offset;
+ geometry::Vector<int> size;
+
+};
+
+}
+
+#endif /* GRAPHICS_TEXTURE_H_ */
struct MenuProperties;
class SimpleAnimation;
class Sprite;
+class Texture;
}