]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/Texture.cpp
renamed namespace geometry -> math
[l2e.git] / src / graphics / Texture.cpp
index 6fc8f0e1c3a142aefc65d15d1d5aa538e6d1661f..db45b3d9d13d3d329dd0f13f39276421cfe5fca8 100644 (file)
@@ -1,20 +1,23 @@
-/*
- * Texture.cpp
- *
- *  Created on: Oct 21, 2012
- *      Author: holy
- */
-
 #include "Texture.h"
 
+#include "../loader/Interpreter.h"
+#include "../loader/TypeDescription.h"
 #include "../sdl/utility.h"
 
-using geometry::Vector;
+using math::Vector;
+using loader::FieldDescription;
+using loader::Interpreter;
+using loader::TypeDescription;
 
 namespace graphics {
 
-Texture::Texture()
-: surface(0) {
+Texture::Texture(
+               SDL_Surface *surface,
+               const Vector<int> &size,
+               const Vector<int> &offset)
+: surface(surface)
+, size(size)
+, offset(offset) {
 
 }
 
@@ -57,4 +60,21 @@ void Texture::Render(SDL_Surface *dest, const Vector<int> &from, const Vector<in
        }
 }
 
+
+void Texture::CreateTypeDescription() {
+       Texture t;
+
+       TypeDescription &td(TypeDescription::Create(TYPE_ID, "Texture"));
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(Texture));
+
+       td.AddField("image", FieldDescription(((char *)&t.surface) - ((char *)&t), Interpreter::IMAGE_ID).SetReferenced().SetDescription("image containing the texture"));
+       td.AddField("size", FieldDescription(((char *)&t.size) - ((char *)&t), Interpreter::VECTOR_ID).SetDescription("offset into the image in pixels"));
+       td.AddField("offset", FieldDescription(((char *)&t.offset) - ((char *)&t), Interpreter::VECTOR_ID).SetDescription("size of the texture in pixels"));
+}
+
+void Texture::Construct(void *data) {
+       new (data) Texture;
+}
+
 }