overloads, tutorial 04 init

This commit is contained in:
h4570
2022-08-21 19:44:47 +02:00
parent 409ee294eb
commit 4fa65fc535
25 changed files with 232 additions and 77 deletions
@@ -15,6 +15,7 @@
#include <vector>
#include "./models/texture.hpp"
#include "renderer/3d/mesh/mesh.hpp"
#include "renderer/core/2d/sprite/sprite.hpp"
#include "loaders/texture/base/texture_loader_selector.hpp"
#include <string>
@@ -32,11 +33,14 @@ class TextureRepository {
/**
* Returns single texture.
* nullptr if not found.
* @param t_id
* For 3D: MeshMaterial id.
* For 2D: Sprite id.
*/
Texture* getBySpriteOrMesh(const u32& t_id) const;
Texture* getBySpriteId(const u32& t_id) const;
/**
* Returns single texture.
* nullptr if not found.
*/
Texture* getByMeshMaterialId(const u32& t_id) const;
/**
* Returns single texture.
@@ -50,14 +54,6 @@ class TextureRepository {
*/
const s32 getIndexOf(const u32& t_texId) const;
// ----
// Setters
// ----
// ----
// Other
// ----
/**
* Add unlinked texture.
* @param fullpath Full path to texture file. Example: "host:texture.png"
@@ -81,37 +77,38 @@ class TextureRepository {
/**
* Add linked textures in given path for mesh material names.
*/
void addByMesh(Mesh* mesh, const char* directory, const char* extension);
void addByMesh(const Mesh* mesh, const char* directory,
const char* extension);
/**
* Add linked textures in given path for mesh material names.
*/
inline void addByMesh(Mesh* mesh, const std::string& directory,
inline void addByMesh(const Mesh* mesh, const std::string& directory,
const char* extension) {
addByMesh(mesh, directory.c_str(), extension);
}
/**
* Remove texture from repository.
* Texture is NOT destructed.
* Texture IS destructed.
*/
void removeByIndex(const u32& t_index);
void free(const u32& texId);
void free(const Texture* tex);
void free(const Texture& tex);
void freeBySprite(const Sprite& sprite);
void freeByMesh(const Mesh& mesh);
void freeByMesh(const Mesh* mesh);
/**
* Remove texture from repository.
* Texture is NOT destructed.
* Not recommended.
*/
void removeById(const u32& t_texId);
/**
* Remove texture from repository.
* Texture IS destructed.
*/
void free(const u32& t_texId);
void free(const Texture* t_tex);
void free(const Texture& t_tex);
private:
void removeByIndex(const u32& t_index);
std::vector<Texture*> textures;
TextureLoaderSelector texLoaderSelector;
};