cache

std::shared_ptr<Texture> kn::cache::load(const std::string &name, const std::string &path)

Load a texture file.

Parameters:
  • name – The name of the texture.

  • path – The path to the texture file.

Returns:

The texture pointer.

std::shared_ptr<Texture> kn::cache::create(const std::string &name, const math::Vec2 &size, Color color)

Create a solid texture.

Parameters:
  • name – The name of the texture.

  • size – The size of the texture.

  • color – The color of the texture.

Returns:

The texture pointer.

std::shared_ptr<Texture> kn::cache::move(const std::string &name, std::shared_ptr<Texture> texture)

Move an existing texture.

Note

This function is recommended for loading fonts.

Parameters:
  • name – The name of the texture.

  • texture – The texture to move.

Returns:

The texture pointer.

const std::map<std::string, std::shared_ptr<Texture>> &kn::cache::getCache()

Get the const reference to the texture cache.

Returns:

The texture cache.

void kn::cache::unload(const std::string &name)

Unload a texture from cache.

Parameters:

name – The name of the texture.

void kn::cache::unloadAll()

Unload all textures from cache.

Note

This method is called in the destructor.

std::shared_ptr<Texture> kn::cache::getTexture(const std::string &name)

Get a texture pointer from cache.

Parameters:

name – The name of the texture.

Returns:

The texture pointer.