From 40a807b25d7539a9b8a1f4206e1415e42c46cb5d Mon Sep 17 00:00:00 2001 From: Joakim Hunskaar Date: Mon, 13 Jul 2026 18:24:05 +0200 Subject: [PATCH] added include and use .at for map access due to compiler error --- .../subprojects/animationwindow/src/Image.cpp | 6 +++--- dependencies/testproject_featuredemo.cpp | 21 ++++--------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/dependencies/subprojects/animationwindow/src/Image.cpp b/dependencies/subprojects/animationwindow/src/Image.cpp index 9e2b702..7f89472 100644 --- a/dependencies/subprojects/animationwindow/src/Image.cpp +++ b/dependencies/subprojects/animationwindow/src/Image.cpp @@ -2,6 +2,7 @@ #include "SDL_surface.h" #include #include +#include #include namespace TDT4102 { @@ -208,7 +209,6 @@ void TDT4102::Image::reset() { surface = nullptr; } - TDT4102::ImageCache TDT4102::Image::cache = TDT4102::ImageCache{}; SDL_Texture *TDT4102::ImageCache::insert(SDL_Renderer *renderer, SDL_Surface *surface, const std::filesystem::path &filePath) { @@ -235,14 +235,14 @@ bool TDT4102::ImageCache::isSurfaceCached(SDL_Surface *surface) const { SDL_Surface *TDT4102::ImageCache::getSurface(const std::filesystem::path &path) const { if ( pathToTexture.contains(path) ) { - return pathToTexture[path].first; + return pathToTexture.at(path).first; } return nullptr; } SDL_Texture *TDT4102::ImageCache::getTexture(const std::filesystem::path &path) const { if ( pathToTexture.contains(path) ) { - return pathToTexture[path].second; + return pathToTexture.at(path).second; } return nullptr; } diff --git a/dependencies/testproject_featuredemo.cpp b/dependencies/testproject_featuredemo.cpp index 024af56..48ad471 100644 --- a/dependencies/testproject_featuredemo.cpp +++ b/dependencies/testproject_featuredemo.cpp @@ -121,12 +121,9 @@ int main(int argc, char* argv[]) { int x = 10; int y = 10; - // TDT4102::Image image("res/unknown.jpg"); - // image.width = 100; - // image.height = 100; - // // TDT4102::Image image("res/unknown.jpg"); - // // image.width = 100; - // // image.height = 100; + TDT4102::Image image("res/unknown.jpg"); + image.width = 100; + image.height = 100; std::vector colors{"red", "gold", "green", "rebecca_purple", "blue"}; @@ -160,17 +157,7 @@ int main(int argc, char* argv[]) { // window.draw_text({mousePosition.x, mousePosition.y + 100}, std::to_string(mousePosition.x) + ", " + std::to_string(mousePosition.y)); // window.draw_text({mousePosition.x, mousePosition.y + 200}, std::to_string(mousePosition.x) + ", " + std::to_string(mousePosition.y), TDT4102::Color::brown, 70, TDT4102::Font::courier_bold_italic); // window.draw_arc({500, 500}, mousePosition.x, mousePosition.y, 190, 350, TDT4102::Color::orange); - // window.draw_image(mousePosition, image); - // if (rb.isSelected()) { - // std::cout << "Checked\n"; - // } else { - // std::cout << "Not checked\n"; - // } - - // window.draw_text({mousePosition.x, mousePosition.y + 100}, std::to_string(mousePosition.x) + ", " + std::to_string(mousePosition.y)); - // window.draw_text({mousePosition.x, mousePosition.y + 200}, std::to_string(mousePosition.x) + ", " + std::to_string(mousePosition.y), TDT4102::Color::brown, 70, TDT4102::Font::courier_bold_italic); - // window.draw_arc({500, 500}, mousePosition.x, mousePosition.y, 190, 350, TDT4102::Color::orange); - // window.draw_image(mousePosition, image); + window.draw_image(mousePosition, image); // if (rb.isSelected()) { // std::cout << "Checked\n"; // } else {