From b6609b0fbc263f4fd93791f3897c5f2840b962f2 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Tue, 3 Dec 2024 09:28:12 +0100 Subject: implemented feedback removed get_width and height --> get_size for both texture and sdlcontext --- src/crepe/api/Texture.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/crepe/api/Texture.cpp') diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp index e43bdaa..c23b91e 100644 --- a/src/crepe/api/Texture.cpp +++ b/src/crepe/api/Texture.cpp @@ -2,6 +2,7 @@ #include "../util/Log.h" #include "Asset.h" +#include "types.h" #include "Texture.h" using namespace crepe; @@ -31,11 +32,7 @@ void Texture::load(const Asset & res) { this->texture = ctx.texture_from_path(res.get_path()); } -int Texture::get_width() const { - if (this->texture == nullptr) return 0; - return SDLContext::get_instance().get_width(*this); -} -int Texture::get_height() const { - if (this->texture == nullptr) return 0; - return SDLContext::get_instance().get_height(*this); +ivec2 Texture::get_size() const { + if (this->texture == nullptr) return {}; + return SDLContext::get_instance().get_size(*this); } -- cgit v1.2.3 From cc821016c8ddce45a1e3f192415f58be237b8a1e Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 3 Dec 2024 11:24:12 +0100 Subject: `make format` --- src/crepe/api/Texture.cpp | 2 +- src/crepe/facade/SDLContext.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/crepe/api/Texture.cpp') diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp index c23b91e..2b56271 100644 --- a/src/crepe/api/Texture.cpp +++ b/src/crepe/api/Texture.cpp @@ -2,8 +2,8 @@ #include "../util/Log.h" #include "Asset.h" -#include "types.h" #include "Texture.h" +#include "types.h" using namespace crepe; using namespace std; diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 8d8a87d..e8be7ca 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -216,8 +216,7 @@ SDLContext::texture_from_path(const std::string & path) { return img_texture; } - -ivec2 SDLContext::get_size(const Texture & ctx){ +ivec2 SDLContext::get_size(const Texture & ctx) { ivec2 size; SDL_QueryTexture(ctx.texture.get(), NULL, NULL, &size.x, &size.y); return size; -- cgit v1.2.3