Skip to content

Commit

Permalink
added include and use .at for map access due to compiler error
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Hunskaar committed Jul 13, 2026
1 parent 723c60e commit 40a807b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
6 changes: 3 additions & 3 deletions dependencies/subprojects/animationwindow/src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "SDL_surface.h"
#include <SDL_image.h>
#include <unordered_set>
#include <unordered_map>
#include <cstring>

namespace TDT4102 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
21 changes: 4 additions & 17 deletions dependencies/testproject_featuredemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> colors{"red", "gold", "green", "rebecca_purple", "blue"};

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 40a807b

Please sign in to comment.