43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "assets/data/texture_data.hpp"
|
|
#include "assets/data_stores/texture_store.hpp"
|
|
#include "opengl/handles/texture_handle.hpp"
|
|
#include <vector>
|
|
|
|
#include "assets/data_stores.hpp"
|
|
#include "opengl/metadata/texture_metadata.hpp"
|
|
#include "opengl/resource_management/resource_manager.hpp"
|
|
|
|
namespace zgl
|
|
{
|
|
class texture_manager
|
|
{
|
|
public:
|
|
using store_type = assets::texture_store;
|
|
using store_id_type = store_type::id_type;
|
|
using metadata_type = texture_metadata;
|
|
using handle_type = texture_handle;
|
|
using resource_manager_type = resource_manager<store_id_type, metadata_type>;
|
|
using entry_type = std::pair<handle_type, metadata_type>;
|
|
|
|
static constexpr std::size_t min_garbage_collection_count = 4;
|
|
|
|
void process(const store_type& textures);
|
|
|
|
std::optional<entry_type> get_handle(store_id_type id);
|
|
|
|
void collect_garbage(bool force = false);
|
|
|
|
protected:
|
|
resource_manager_type m_resource_manager;
|
|
|
|
private:
|
|
std::vector<std::pair<store_id_type, const assets::texture_data&>> m_texture_buffer;
|
|
std::vector<GLuint> m_texture_id_buffer;
|
|
};
|
|
|
|
}
|