mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-04 11:35:06 +03:00
Shader memory leak fixed and textuer manager RAII
This commit is contained in:
@@ -159,6 +159,8 @@ namespace Nuake
|
||||
if (cs != 0)
|
||||
glDeleteShader(cs);
|
||||
|
||||
Source = {};
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
@@ -204,6 +206,9 @@ namespace Nuake
|
||||
std::cout << message << std::endl;
|
||||
// Delete invalid shader
|
||||
glDeleteShader(id);
|
||||
|
||||
delete[] message;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,10 +72,6 @@ namespace Nuake
|
||||
std::string displacementPath;
|
||||
|
||||
Ref<Material> newMaterial = CreateRef<Material>(j["albedo"]);
|
||||
//if (j.contains("albedo"))
|
||||
// newMaterial = new Material(albedoPath);
|
||||
//else
|
||||
// newMaterial = new Material(glm::vec3(1, 1, 1));
|
||||
newMaterial->SetName(matName);
|
||||
|
||||
if (j.contains("normal"))
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user