Fixed memory issue.
This commit is contained in:
@@ -22,7 +22,7 @@ CPMAddPackage(
|
||||
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-26.zip
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-O3 -Wall -Wextra")
|
||||
#set(CMAKE_CXX_FLAGS "-O3 -Wall -Wextra")
|
||||
|
||||
file(GLOB_RECURSE HEADERS "include/*.h" "include/*.hpp")
|
||||
file(GLOB_RECURSE SOURCES "src/*.c" "src/*.cpp")
|
||||
|
@@ -9,7 +9,7 @@ namespace Engine {
|
||||
|
||||
class Engine::InstancedTexture {
|
||||
protected:
|
||||
JGL::Texture* texture;
|
||||
JGL::Texture* texture = nullptr;
|
||||
std::vector<const InstancedSprite*> users{};
|
||||
public:
|
||||
[[nodiscard]] size_t ReferenceCount() { return users.size(); }
|
||||
|
@@ -3,13 +3,22 @@
|
||||
|
||||
using namespace Engine;
|
||||
Texture* InstancedSprite::GetTexture() {
|
||||
return Globals::CurrentScene->GetInstancedTexture(this)->GetTexture();
|
||||
auto* itx = Globals::CurrentScene->GetInstancedTexture(this);
|
||||
if (itx)
|
||||
return itx->GetTexture();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Texture* InstancedSprite::GetAlphaMask() {
|
||||
if (Sprite::GetAlphaMask())
|
||||
return Sprite::GetAlphaMask();
|
||||
return Globals::CurrentScene->GetInstancedAlphaMask(this)->GetTexture();
|
||||
|
||||
auto* ita = Globals::CurrentScene->GetInstancedAlphaMask(this);
|
||||
if (ita)
|
||||
return ita->GetTexture();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InstancedSprite::~InstancedSprite() {
|
||||
|
@@ -167,10 +167,10 @@ InstancedTexture* Scene::GetInstancedAlphaMask(const InstancedSprite* user) {
|
||||
if (itx->InUseBy(user))
|
||||
return itx;
|
||||
|
||||
if (!user->GetAlphaMaskFilesystemPath().empty()) {
|
||||
if (!user->GetAlphaMaskFilesystemPath().empty() && !instanced_alpha_masks.empty()) {
|
||||
auto *t = new Texture(user->GetTextureFilesystemPath());
|
||||
auto *itx = new InstancedTexture(t, user);
|
||||
instanced_textures.push_back(itx);
|
||||
instanced_alpha_masks.push_back(itx);
|
||||
return itx;
|
||||
}
|
||||
return nullptr;
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#include <Game/entity/Box.h>
|
||||
#include <Engine/Globals.h>
|
||||
#include <JGL/JGL.h>
|
||||
|
||||
void Game::Box::Update() {
|
||||
if (Globals::Window->IsKeyDown(Keys::W))
|
||||
|
Reference in New Issue
Block a user