aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Render.hpp
diff options
context:
space:
mode:
authorAndy Belle-Isle <drumsetmonkey@gmail.com>2019-10-07 18:35:47 -0400
committerAndy Belle-Isle <drumsetmonkey@gmail.com>2019-10-07 18:35:47 -0400
commit5f53889d4357d8dba6e726ed38358eca96dbeb47 (patch)
tree8d82a65d007f7bf69dcd650c95bc3ee1463a3002 /src/components/Render.hpp
parent1b63e00b6b08133f5ee37ed90043eee0f67942fd (diff)
Added ability to change rendering offsets and sizes
Diffstat (limited to 'src/components/Render.hpp')
-rw-r--r--src/components/Render.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/components/Render.hpp b/src/components/Render.hpp
index 81ca591..a9af51a 100644
--- a/src/components/Render.hpp
+++ b/src/components/Render.hpp
@@ -28,6 +28,12 @@ public:
Texture normal;
bool visible;
bool flipX = false;
+ glm::vec2 corners[4] = {
+ glm::vec2(-0.5, -0.5), // lower left
+ glm::vec2( 0.5, -0.5), // lower right
+ glm::vec2(-0.5, 0.5), // upper left
+ glm::vec2( 0.5, 0.5) // upper right
+ };
Render(std::string _file) :
texture(_file), visible(true) {}
@@ -46,6 +52,19 @@ public:
this->normal = Texture(tab.get<std::string>("normal"));
if (tab["flipx"].get_type() == sol::type::boolean)
this->flipX = tab["flipx"];
+
+ if (tab["offset"].get_type() == sol::type::table) {
+ sol::table offset = tab["offset"];
+ if (offset["ll"] == sol::type::table)
+ corners[0] = Script::to<glm::vec2>(offset["ll"]);
+ if (offset["lr"] == sol::type::table)
+ corners[1] = Script::to<glm::vec2>(offset["lr"]);
+ if (offset["ul"] == sol::type::table)
+ corners[2] = Script::to<glm::vec2>(offset["ul"]);
+ if (offset["ur"] == sol::type::table)
+ corners[3] = Script::to<glm::vec2>(offset["ur"]);
+ }
+
} else {
throw std::string(
"Render component table formatted incorrectly"