From 211d8957a3ae8b46969edb41676ed7e94c56ef32 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Thu, 2 Dec 2021 23:10:32 -0500 Subject: [PATCH] Make Square transformable --- include/simpleengine/shapes/2d/square.h | 6 +++--- src/shapes/2d/square.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/simpleengine/shapes/2d/square.h b/include/simpleengine/shapes/2d/square.h index ce1c207..eb560cf 100644 --- a/include/simpleengine/shapes/2d/square.h +++ b/include/simpleengine/shapes/2d/square.h @@ -14,6 +14,8 @@ #include "../../renderable.h" #include "../../vertex.h" +#include "../../transformable.h" +#include "../../optional.h" #include "../../gfx/vbo.h" #include "../../gfx/vao.h" @@ -23,10 +25,8 @@ #include #include -#include "../../optional.h" - namespace simpleengine::shapes_2d { - class Square : public simpleengine::Renderable { + class Square : public simpleengine::Renderable, public simpleengine::Transformable { private: using super = simpleengine::Renderable; private: diff --git a/src/shapes/2d/square.cpp b/src/shapes/2d/square.cpp index 66d7a39..71345e6 100644 --- a/src/shapes/2d/square.cpp +++ b/src/shapes/2d/square.cpp @@ -39,7 +39,9 @@ namespace simpleengine::shapes_2d { void Square::render(GLFWwindow* target) { shader.use(); - // If theres a texture set, tell the fragment shader that and bind to the texture for drawing. + shader.set_uniform_matrix_4f("transform", transform_matrix, false); + + // When binding to the texture, also tell the shader if the texture is set or not. if (texture.has_value()) { shader.set_uniform_int("texture_is_set", true, false); texture.value().bind();