Shader memory leak fixed and textuer manager RAII

This commit is contained in:
Antoine Pilote
2023-10-02 01:35:34 -04:00
parent 4aed490d5c
commit fd0f9a5a3f
3 changed files with 15 additions and 15 deletions

View File

@@ -19,24 +19,23 @@ namespace Nuake
void TextureManager::LoadStaticTextures()
{
using namespace StaticResources;
m_Registry.emplace(Resources_Gizmos_bone_png_path, new Texture(Resources_Gizmos_bone_png, Resources_Gizmos_bone_png_len));
m_Registry.emplace(Resources_Gizmos_camera_png_path, new Texture(Resources_Gizmos_camera_png, Resources_Gizmos_camera_png_len));
m_Registry.emplace(Resources_Gizmos_light_png_path, new Texture(Resources_Gizmos_light_png, Resources_Gizmos_light_png_len));
m_Registry.emplace(Resources_Gizmos_player_png_path, new Texture(Resources_Gizmos_player_png, Resources_Gizmos_player_png_len));
m_Registry.emplace(Resources_Gizmos_bone_png_path, CreateRef<Texture>(Resources_Gizmos_bone_png, Resources_Gizmos_bone_png_len));
m_Registry.emplace(Resources_Gizmos_camera_png_path, CreateRef<Texture>(Resources_Gizmos_camera_png, Resources_Gizmos_camera_png_len));
m_Registry.emplace(Resources_Gizmos_light_png_path, CreateRef<Texture>(Resources_Gizmos_light_png, Resources_Gizmos_light_png_len));
m_Registry.emplace(Resources_Gizmos_player_png_path, CreateRef<Texture>(Resources_Gizmos_player_png, Resources_Gizmos_player_png_len));
m_Registry.emplace(Resources_Images_nuake_logo_png_path, new Texture(Resources_Images_nuake_logo_png, Resources_Images_nuake_logo_png_len));
m_Registry.emplace(Resources_Images_logo_white_png_path, new Texture(Resources_Images_logo_white_png, Resources_Images_logo_white_png_len));
m_Registry.emplace(Resources_Images_logo_png_path, new Texture(Resources_Images_logo_png, Resources_Images_logo_png_len));
m_Registry.emplace(Resources_Images_nuake_logo_png_path, CreateRef<Texture>(Resources_Images_nuake_logo_png, Resources_Images_nuake_logo_png_len));
m_Registry.emplace(Resources_Images_logo_white_png_path, CreateRef<Texture>(Resources_Images_logo_white_png, Resources_Images_logo_white_png_len));
m_Registry.emplace(Resources_Images_logo_png_path, CreateRef<Texture>(Resources_Images_logo_png, Resources_Images_logo_png_len));
unsigned char whitePixel[] = { 255, 255, 255, 255 };
m_Registry.emplace("Resources/Textures/Default.png", new Texture({1, 1}, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, &whitePixel));
m_Registry.emplace("Resources/Textures/Default.png", CreateRef<Texture>(Vector2( 1, 1 ), GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, &whitePixel));
m_Registry.emplace("default", new Texture({ 1, 1 }, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, &whitePixel));
unsigned char normalPixel[] = { 128, 128, 255, 255 };
m_Registry.emplace("Resources/Textures/DefaultNormal.png", new Texture({ 1, 1 }, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, &whitePixel));
m_Registry.emplace("Resources/Textures/DefaultNormal.png", CreateRef<Texture>(Vector2(1, 1), GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, &whitePixel));
// Icons
m_Registry.emplace(Resources_Images_folder_icon_png_path, new Texture(Resources_Images_folder_icon_png, Resources_Images_folder_icon_png_len));
m_Registry.emplace(Resources_Images_folder_icon_png_path, CreateRef<Texture>(Resources_Images_folder_icon_png, Resources_Images_folder_icon_png_len));
}
Ref<Texture> TextureManager::GetTexture(const std::string path)