Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
Chronos::Engine::TextureManager Class Reference

This is the texture manager for Chronos. It handles creation, modification, updating and desrtuction of textures. More...

#include <textureManager.hpp>

Collaboration diagram for Chronos::Engine::TextureManager:

Public Member Functions

void init (Chronos::Engine::Device *device, VkCommandPool commandPool)
 Initializes the texture manager.
 
int addTexture (std::string texturePath, std::string textureName)
 Adds a texture to the texture manager.
 
void removeTexture (int textureNo)
 Removes a texture from the texture manager.
 
Chronos::Engine::Texture getTexture (int textureNo)
 Gets the texture from the texture manager.
 
void destroy ()
 Destroys the texture manager.
 

Public Attributes

std::map< int, Chronos::Engine::Texturetextures
 The textures that are managed by this class. They are mapped via texture nos.
 
int nextFreeTextureNo = 0
 

Private Attributes

Chronos::Engine::Devicedevice
 
VkCommandPool commandPool
 

Detailed Description

This is the texture manager for Chronos. It handles creation, modification, updating and desrtuction of textures.

Once created, they can be removed or referenced by their texture number.

Definition at line 41 of file textureManager.hpp.

Member Function Documentation

◆ addTexture()

int Chronos::Engine::TextureManager::addTexture ( std::string  texturePath,
std::string  textureName 
)

Adds a texture to the texture manager.

Parameters
texturePathThe path to the texture(only jpg or png).
textureNameThe name of the texture(must be unique).
Returns
The texutreNoof the texture that was added.

Definition at line 32 of file textureManager.cpp.

34{
35 int textureNo = nextFreeTextureNo++;
36 textures[textureNo].create(*device, commandPool, texturePath, textureName);
37 return textureNo;
38}
std::map< int, Chronos::Engine::Texture > textures
The textures that are managed by this class. They are mapped via texture nos.
Chronos::Engine::Device * device
Here is the caller graph for this function:

◆ destroy()

void Chronos::Engine::TextureManager::destroy ( )

Destroys the texture manager.

Definition at line 46 of file textureManager.cpp.

47{
48 for (auto& texture : textures) {
49 texture.second.destroy();
50 }
51}

◆ getTexture()

Chronos::Engine::Texture Chronos::Engine::TextureManager::getTexture ( int  textureNo)

Gets the texture from the texture manager.

Parameters
textureNoThe textureNo of the texture to get.
Returns
The texture that was requested.

Definition at line 53 of file textureManager.cpp.

55{
56 return textures[textureNo];
57}

◆ init()

void Chronos::Engine::TextureManager::init ( Chronos::Engine::Device device,
VkCommandPool  commandPool 
)

Initializes the texture manager.

Parameters
deviceThe device that has the textures.
commandPoolThe command pool to create the temporary command buffer from.

Definition at line 25 of file textureManager.cpp.

27{
28 this->device = device;
30}

References commandPool, and device.

◆ removeTexture()

void Chronos::Engine::TextureManager::removeTexture ( int  textureNo)

Removes a texture from the texture manager.

Parameters
textureNoThe textureNo of the texture to remove.

Definition at line 40 of file textureManager.cpp.

41{
42 textures[textureNo].destroy();
43 textures.erase(textureNo);
44}

References Chronos::Engine::Device::destroy().

Here is the call graph for this function:

Member Data Documentation

◆ commandPool

VkCommandPool Chronos::Engine::TextureManager::commandPool
private

Definition at line 92 of file textureManager.hpp.

◆ device

Chronos::Engine::Device* Chronos::Engine::TextureManager::device
private

Definition at line 91 of file textureManager.hpp.

◆ nextFreeTextureNo

int Chronos::Engine::TextureManager::nextFreeTextureNo = 0

Definition at line 48 of file textureManager.hpp.

◆ textures

std::map<int, Chronos::Engine::Texture> Chronos::Engine::TextureManager::textures

The textures that are managed by this class. They are mapped via texture nos.

Definition at line 47 of file textureManager.hpp.


The documentation for this class was generated from the following files: