summaryrefslogtreecommitdiff
path: root/src/vk
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-05-29 10:54:59 -0300
committerFrederico Linhares <fred@linhares.blue>2023-05-29 16:04:16 -0300
commit7f7515f22517509fb93ee1615c72006dca6abb03 (patch)
tree2799565116c209ff057809494e4b9eb0e90ec279 /src/vk
parentb8614162cdbb3817a7a58ceadf8b6b0d05fae952 (diff)
refa Sprite receives floats instead of Vector4D
* lib/menu.rb: Uses the new interface for Sprite. * src/sprite.cpp (Sprite#new, Sprite#draw): By requiring a Vector4D as an argument, sometimes the code calling a Sprite method needs to instantiate a Vector4D and use the stance once. The functions now require four float variables to eliminate this unnecessary instantiation.
Diffstat (limited to 'src/vk')
-rw-r--r--src/vk/sprite.cpp11
-rw-r--r--src/vk/sprite.hpp2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/vk/sprite.cpp b/src/vk/sprite.cpp
index bc9cb57..069bf6a 100644
--- a/src/vk/sprite.cpp
+++ b/src/vk/sprite.cpp
@@ -28,12 +28,12 @@ namespace
struct SpriteBuilder
{
VK::Sprite *sprite;
- glm::vec4 rect;
+ glm::vec4 &rect;
- SpriteBuilder(VK::Sprite *sprite, glm::vec4 rect);
+ SpriteBuilder(VK::Sprite *sprite, glm::vec4 &rect);
};
-SpriteBuilder::SpriteBuilder(VK::Sprite *sprite, glm::vec4 rect):
+SpriteBuilder::SpriteBuilder(VK::Sprite *sprite, glm::vec4 &rect):
sprite{sprite},
rect{rect}
{
@@ -172,7 +172,7 @@ static const CommandChain loader{
namespace VK
{
-Sprite::Sprite(std::shared_ptr<Texture> texture, glm::vec4 rect):
+Sprite::Sprite(std::shared_ptr<Texture> texture, glm::vec4 &rect):
texture{texture}
{
SpriteBuilder sprite_builder(this, rect);
@@ -181,7 +181,8 @@ Sprite::Sprite(std::shared_ptr<Texture> texture, glm::vec4 rect):
Sprite::~Sprite()
{
- SpriteBuilder sprite_builder(this, glm::vec4());
+ glm::vec4 vector_4d{};
+ SpriteBuilder sprite_builder(this, vector_4d);
loader.revert(&sprite_builder);
}
diff --git a/src/vk/sprite.hpp b/src/vk/sprite.hpp
index e053bba..5934501 100644
--- a/src/vk/sprite.hpp
+++ b/src/vk/sprite.hpp
@@ -44,7 +44,7 @@ struct Sprite
std::shared_ptr<Texture> texture;
- Sprite(std::shared_ptr<Texture> texture, glm::vec4 rect);
+ Sprite(std::shared_ptr<Texture> texture, glm::vec4 &rect);
~Sprite();
};