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