From bfee7fe4aecd859cd7880f42d485a718b224d2f2 Mon Sep 17 00:00:00 2001 From: Nathan Mills <38995150+Quipyowert2@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:55:33 -0700 Subject: [PATCH] Prevent drawing on atlas once generated by making it readonly. --- libgag/include/SDLGraphicContext.h | 2 +- libgag/src/Sprite.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libgag/include/SDLGraphicContext.h b/libgag/include/SDLGraphicContext.h index cc6ad107..2c42a2fb 100644 --- a/libgag/include/SDLGraphicContext.h +++ b/libgag/include/SDLGraphicContext.h @@ -440,7 +440,7 @@ namespace GAGCore std::vector texCoords; unsigned int vbo; unsigned int texCoordBuffer; - std::unique_ptr atlas = nullptr; + std::unique_ptr atlas = nullptr; #endif Color actColor; diff --git a/libgag/src/Sprite.cpp b/libgag/src/Sprite.cpp index ffbec675..6cdef83a 100644 --- a/libgag/src/Sprite.cpp +++ b/libgag/src/Sprite.cpp @@ -134,7 +134,7 @@ namespace GAGCore int tileHeight = images[0]->getH(); int sheetWidth = tileWidth * (static_cast(sqrt(numImages)) + 1); int sheetHeight = tileHeight * (static_cast(sqrt(numImages)) + 1); - atlas = make_unique(sheetWidth, sheetHeight); + std::unique_ptr atlas = make_unique(sheetWidth, sheetHeight); int x = 0, y = 0; for (auto image: images) { @@ -158,6 +158,7 @@ namespace GAGCore image->sprite = this; image->setRes(sheetWidth, sheetHeight); } + this->atlas = std::move(atlas); glGenBuffers(1, &vbo); glGenBuffers(1, &texCoordBuffer); #endif