Simulant
21.12-1292
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
|
Classes | |
struct | BuiltIns |
Public Types | |
typedef std::shared_ptr< Texture > | ptr |
typedef std::vector< uint8_t > | Data |
typedef std::function< void(uint8_t *, uint16_t, uint16_t, TextureFormat)> | MutationFunc |
Public Types inherited from smlt::generic::Identifiable< AssetID > | |
typedef AssetID | id_type |
Public Types inherited from smlt::RefCounted< Texture > | |
typedef std::shared_ptr< Texture > | ptr |
typedef std::weak_ptr< Texture > | wptr |
Public Member Functions | |
Texture (AssetID id, AssetManager *asset_manager, uint16_t width, uint16_t height, TextureFormat format=TEXTURE_FORMAT_RGBA_4UB_8888) | |
TextureFormat | format () const |
void | set_format (TextureFormat format) |
bool | is_paletted_format () const |
uint32_t | palette_size () const |
bool | update_palette (const uint8_t *palette) |
bool | blur (BlurType blur_type, std::size_t radius) |
smlt::optional< Pixel > | pixel (std::size_t x, std::size_t y) |
bool | convert (TextureFormat new_format, const TextureChannelSet &channels=Texture::DEFAULT_SOURCE_CHANNELS) |
void | resize (uint16_t width, uint16_t height, uint32_t data_size) |
void | resize (uint16_t width, uint16_t height) |
void | flip_vertically () |
void | set_source (const smlt::Path &source) |
void | set_texture_filter (TextureFilter filter) |
void | set_free_data_mode (TextureFreeData mode) |
void | set_texture_wrap (TextureWrap wrap_u, TextureWrap wrap_v, TextureWrap wrap_w) |
void | set_texture_wrap_u (TextureWrap wrap_u) |
void | set_texture_wrap_v (TextureWrap wrap_v) |
void | set_texture_wrap_w (TextureWrap wrap_w) |
void | set_auto_upload (bool v=true) |
void | set_mipmap_generation (MipmapGenerate type) |
std::vector< uint8_t > | data_copy () const |
const uint8_t * | data () const |
uint32_t | data_size () const |
void | set_data (const uint8_t *data, std::size_t size) |
void | set_data (const std::vector< uint8_t > &data) |
void | free () |
bool | has_data () const |
void | flush () |
void | mutate_data (MutationFunc func) |
uint16_t | width () const override |
uint16_t | height () const override |
Vec2 | dimensions () const |
bool | is_compressed () const |
uint8_t | channels () const |
void | save_to_file (const Path &filename) |
Path | source () const |
TextureFilter | texture_filter () const |
TextureWrap | wrap_u () const |
TextureWrap | wrap_v () const |
TextureWrap | wrap_w () const |
MipmapGenerate | mipmap_generation () const |
TextureFreeData | free_data_mode () const |
bool | on_init () override |
void | on_clean_up () override |
bool | has_mipmaps () const |
bool | auto_upload () const |
void | _set_renderer_specific_id (const uint32_t id) |
uint32_t | _renderer_specific_id () const |
void | _set_params_clean () |
bool | _data_dirty () const |
void | _set_data_clean () |
bool | _params_dirty () const |
void | _set_has_mipmaps (bool v) |
uint8_t * | _stash_paletted_data () |
Public Member Functions inherited from smlt::Asset | |
Asset (AssetManager *manager) | |
AssetManager & | asset_manager () |
const AssetManager & | asset_manager () const |
int | age () const |
void | set_garbage_collection_method (GarbageCollectMethod method) |
Public Member Functions inherited from smlt::Nameable | |
void | set_name (const std::string &name) |
const std::string & | name () const |
bool | has_name () const |
Public Member Functions inherited from smlt::generic::Identifiable< AssetID > | |
Identifiable (AssetID id) | |
AssetID | id () const |
virtual bool | operator== (const Identifiable< AssetID > &rhs) const |
virtual bool | operator< (const Identifiable< AssetID > &rhs) const |
Public Member Functions inherited from smlt::TwoPhaseConstructed | |
bool | init () |
void | clean_up () |
Public Member Functions inherited from smlt::RenderTarget | |
virtual void | set_clear_every_frame (uint32_t clear_flags=BUFFER_CLEAR_ALL, const smlt::Color &color=smlt::Color::black()) |
virtual uint32_t | clear_every_frame_flags () const |
virtual smlt::Color | clear_every_frame_color () const |
Public Member Functions inherited from smlt::ChainNameable< Texture > | |
Texture * | set_name_and_get (const std::string &name) |
Static Public Member Functions | |
static std::size_t | required_data_size (TextureFormat fmt, uint16_t width, uint16_t height) |
Static Public Member Functions inherited from smlt::RefCounted< Texture > | |
static RefCounted< Texture >::ptr | create (Args &&... args) |
static RefCounted< Texture >::ptr | create () |
Static Public Attributes | |
static const TextureChannelSet | DEFAULT_SOURCE_CHANNELS |
Additional Inherited Members | |
Public Attributes inherited from smlt::Asset | |
Property< generic::DataCarrier Asset::* > | data = {this, &Asset::data_} |
Protected Member Functions inherited from smlt::Asset | |
Asset (const Asset &rhs) | |
Asset & | operator= (const Asset &rhs) |
Protected Member Functions inherited from smlt::RefCounted< Texture > | |
RefCounted (Args &&...) | |
bool smlt::Texture::_data_dirty | ( | ) | const |
INTERNAL: returns true if the data needs re-uploading
bool smlt::Texture::_params_dirty | ( | ) | const |
INTERNAL: returns true if the filters are dirty
void smlt::Texture::_set_data_clean | ( | ) |
INTERNAL: clears the dirty data flag
void smlt::Texture::_set_params_clean | ( | ) |
INTERNAL: Clears the params dirty flag
void smlt::Texture::_set_renderer_specific_id | ( | const uint32_t | id | ) |
This is for storing the GL (or whatever) texture ID
uint8_t * smlt::Texture::_stash_paletted_data | ( | ) |
INTERNAL: copy the current data to the paletted data array
uint8_t smlt::Texture::channels | ( | ) | const |
Returns the number of channels that this texture has
bool smlt::Texture::convert | ( | TextureFormat | new_format, |
const TextureChannelSet & | channels = Texture::DEFAULT_SOURCE_CHANNELS |
||
) |
Convert a texture to a new format and allow manipulating/filling the channels during the conversion
const uint8_t * smlt::Texture::data | ( | ) | const |
Returns the current in-ram data. For paletted texture the data will be prefixed with the palette.
std::vector< uint8_t > smlt::Texture::data_copy | ( | ) | const |
Return a copy of the internal data array
uint32_t smlt::Texture::data_size | ( | ) | const |
Returns the size of the currently allocated data buffer, this will be zero if the data only exists in vram. For paletted texture this will be the size of the data plus the size of the palette.
void smlt::Texture::flip_vertically | ( | ) |
Flip the data buffer vertically. This will have no effect if the data buffer has been wiped after upload
void smlt::Texture::flush | ( | ) |
Flushes texture data / properties to the renderer immediately. This will free ram if the free data mode is set to TEXTURE_FREE_DATA_AFTER_UPLOAD
void smlt::Texture::free | ( | ) |
Clear the data buffer
bool smlt::Texture::has_data | ( | ) | const |
Returns true if the data array isn't empty
bool smlt::Texture::has_mipmaps | ( | ) | const |
Returns true if the format contains mipmap data, or mipmaps have been generated during texture upload
bool smlt::Texture::is_compressed | ( | ) | const |
Returns true if this Texture uses a compressed format
bool smlt::Texture::is_paletted_format | ( | ) | const |
Returns true if this is a paletted texture format
void smlt::Texture::mutate_data | ( | Texture::MutationFunc | func | ) |
Apply a mutation function to the current texture data
|
overridevirtual |
These are overridden to notify the renderer of texture changes
Reimplemented from smlt::TwoPhaseConstructed.
uint32_t smlt::Texture::palette_size | ( | ) | const |
Returns the size in bytes of the palette for paletted textures. Returns 0 if the format is not paletted
|
static |
The required size that data() should be to hold a texture in this format with these dimensions. For non-compressed formats this is usually the width * height * stride. For compressed formats this can vary, and will include any space for things like codebooks. For paletted textures this will return the size of the index data + plus the size of the palette
void smlt::Texture::resize | ( | uint16_t | width, |
uint16_t | height | ||
) |
Change the width and height, automatically resizing the data buffer depending on the bytes_per_pixel of the texel_type
void smlt::Texture::resize | ( | uint16_t | width, |
uint16_t | height, | ||
uint32_t | data_size | ||
) |
Change the width and height, but manually set the data buffer size, mainly used for compressed textures
void smlt::Texture::save_to_file | ( | const Path & | filename | ) |
Save a texture to the specified file. Will only work for uncompressed Textures
void smlt::Texture::set_auto_upload | ( | bool | v = true | ) |
If enabled (default) the texture will be uploaded to the GPU by the renderer. You can disable this if you need just a way to load images from disk for other purposes (e.g. heightmaps)
void smlt::Texture::set_free_data_mode | ( | TextureFreeData | mode | ) |
If set to TEXTURE_FREE_DATA_AFTER_UPLOAD then the data attribute will be wiped after the renderer has uploaded to the GPU.
void smlt::Texture::set_texture_filter | ( | TextureFilter | filter | ) |
Texture filtering and wrapping
void smlt::Texture::set_texture_wrap | ( | TextureWrap | wrap_u, |
TextureWrap | wrap_v, | ||
TextureWrap | wrap_w | ||
) |
Set the texture wrap modes, either together or per-dimension
bool smlt::Texture::update_palette | ( | const uint8_t * | palette | ) |
Changes the current palette. The palette must be sizes correctly based on the format. This will return false if a previous palette and data has not been supplied through set_data() etc.
NOT YET IMPLEMENTED! PATCHES WELCOME!
|
static |