Skip to content

Commit

Permalink
Prevent drawing on atlas once generated by making it readonly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Quipyowert2 committed Oct 11, 2024
1 parent 37b7208 commit bfee7fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libgag/include/SDLGraphicContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ namespace GAGCore
std::vector <float> texCoords;
unsigned int vbo;
unsigned int texCoordBuffer;
std::unique_ptr<DrawableSurface> atlas = nullptr;
std::unique_ptr<const DrawableSurface> atlas = nullptr;
#endif
Color actColor;

Expand Down
3 changes: 2 additions & 1 deletion libgag/src/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace GAGCore
int tileHeight = images[0]->getH();
int sheetWidth = tileWidth * (static_cast<int>(sqrt(numImages)) + 1);
int sheetHeight = tileHeight * (static_cast<int>(sqrt(numImages)) + 1);
atlas = make_unique<DrawableSurface>(sheetWidth, sheetHeight);
std::unique_ptr<DrawableSurface> atlas = make_unique<DrawableSurface>(sheetWidth, sheetHeight);
int x = 0, y = 0;
for (auto image: images)
{
Expand All @@ -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
Expand Down

0 comments on commit bfee7fe

Please sign in to comment.