Class Texture#

Inheritance Relationships#

Base Type#

Derived Type#

Class Documentation#

class Texture : public Karana::Core::Base#

Class for a texture image.

See Scene layer for more discussion on the scene layer.

Subclassed by Karana::Scene::GrayscaleTexture

Public Functions

Texture(std::string_view name, const TextureData &data_in)#

Texture constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.

Parameters:
  • name – The Texture’s name.

  • data_in – Input data to create the Texture.

~Texture()#

Destructor for Texture.

void writeToFile(const std::filesystem::path &filename)#

Write the texture to a file.

Parameters:

filename – The name of the file to write to.

std::vector<unsigned char> writeToPngMem() const#

Write the texture to a png stream.

Returns:

The png stream as an std::vector of unsigned char*

const TextureData &getData() const#

Get the texture data associated with the Texture.

Returns:

The texture data associated with the Texture.

virtual void setData(const TextureData &data)#

Set the texture data associated with the Texture.

Parameters:

data – The data to set the Texture data to.

virtual void setData(TextureData &&data)#

Set the texture data associated with the Texture.

Parameters:

data – The data to set the Texture data to.

Public Static Functions

static kc::ks_ptr<Texture> create(std::string_view name, const TextureData &data)#

Create a Texture instance.

Parameters:
  • name – The Texture’s name.

  • data – The data for the texture.

Returns:

A ks_ptr to the Texture.

static kc::ks_ptr<Texture> create(std::string_view name, unsigned char *buffer, int len)#

Create a Texture instance.

Parameters:
  • name – The Texture’s name.

  • buffer – A buffer holding a compressed image format.

  • len – The length of the buffer.

Returns:

A ks_ptr to the Texture.

static kc::ks_ptr<Texture> lookupOrCreateTexture(const std::filesystem::path &filename)#

Create a texture from a file name. This caches the texture so that future versions created with the same file name just return a pointer to the same texture.

Parameters:

filename – The name of the file.

Returns:

A ks_ptr to the Texture.

Protected Attributes

TextureData _data#

Holds the data for the texture.