template<class AllocationPolicy>
texture_atlas_t class
customizable container class for for textures
texture_
Public types
- using allocation_hint_t = typename AllocationPolicy::allocation_hint_t
- key hint type for allocation in specific places
- using key_storage_t = typename AllocationPolicy::key_storage_t
- key storage type
- using key_t = typename AllocationPolicy::key_t
- key type to reference entries
Constructors, destructors, conversion operators
-
template<class... Args>texture_atlas_t(Args && ... args) explicit
- constructor
-
texture_atlas_t(texture_
atlas_ t&& mov) defaulted noexcept - move constructor
-
texture_atlas_t(const texture_
atlas_ t& cpy) deleted - copy constructor
Public functions
-
auto at(const key_
t key) -> entry_ t - bounds checked access to entries
-
auto at(const key_
t key) const -> const entry_ t - bounds checked access to entries
-
auto bind_to_texture_slot() const -> texture_
atlas_ slot_ t<AllocationPolicy> - bind textures of the texture atlas next free texture units
-
auto contains(const key_
t key) const -> bool - check if a given key is contained in the atlas
-
auto declaration(const std::
string_view name) const -> std:: string - get declaration for shader compilation
-
auto dynamic_fetch(const std::
string_view name, const std:: string_view key, const std:: string_view uv) const -> std:: string - return string to fetch a texel inside shader code
-
auto dynamic_fetch(const std::
string_view name, const std:: string_view key, const glm::vec2 uv) const -> std:: string - return string to fetch a texel inside shader code
- auto empty() const -> bool
- check if atlas is empty
-
void erase(const key_
t key) - erase entry from the texture atlas
-
void erase(const entry_
t entry) - erase entry from the texture atlas
-
auto fetch(const std::
string_view name, const key_ t key, const std:: string_view uv) const -> std:: string - return string to fetch a texel inside shader code
-
auto fetch(const std::
string_view name, const key_ t key, const glm::vec2 uv) const -> std:: string - return string to fetch a texel inside shader code
-
auto get(const key_
t key) -> entry_ t - access to entries
-
auto get(const key_
t key) const -> const entry_ t - access to entries
-
auto insert() -> entry_
t - insert element into atlas
-
auto insert(const allocation_
hint_ t allocation_hint) -> entry_ t - insert element into atlas
-
template<class PixelFormat>auto insert(const image_
t<PixelFormat>& image) -> entry_ t - insert element into atlas
-
template<class PixelFormat>auto insert(const allocation_
hint_ t allocation_hint, const image_ t<PixelFormat>& image) -> entry_ t - insert element into atlas
-
auto keys() const -> key_
storage_ t - get the key range of the texture atlas
- auto max_size() const -> size_t
- maximum size of the texture atlas
-
auto operator=(texture_
atlas_ t&& mov) -> texture_ atlas_ t& defaulted noexcept - move assignment operator
-
auto operator=(const texture_
atlas_ t& cpy) -> texture_ atlas_ t& deleted - copy assignment operator
-
auto operator[](const key_
t key) -> entry_ t - random access operator
- auto size() const -> size_t
- size of texture atlas
Function documentation
template<class AllocationPolicy>
template<class... Args>
glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: texture_atlas_t(Args && ... args) explicit
template<class... Args>
constructor
Parameters | |
---|---|
args | [in] paramets that will be passed to the AllocationPolicy on construction |
This is the constructor for texture_
template<class AllocationPolicy>
glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: texture_atlas_t(texture_ atlas_ t&& mov) defaulted noexcept
move constructor
texture_
template<class AllocationPolicy>
glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: texture_atlas_t(const texture_ atlas_ t& cpy) deleted
copy constructor
texture_
template<class AllocationPolicy>
entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: at(const key_ t key)
bounds checked access to entries
Parameters | |
---|---|
key | [in] key of texture that shall be accessed |
Returns | texture_ |
This member function allows access to entries in the atlas. The function will check if the requested key is contained in the atlas before access. If the key does not exist an exception is thrown.
template<class AllocationPolicy>
const entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: at(const key_ t key) const
bounds checked access to entries
Parameters | |
---|---|
key | [in] key of texture that shall be accessed |
Returns | texture_ |
This member function allows access to entries in the atlas. The function will check if the requested key is contained in the atlas before access. If the key does not exist an exception is thrown.
template<class AllocationPolicy>
texture_ atlas_ slot_ t<AllocationPolicy> glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: bind_to_texture_slot() const
bind textures of the texture atlas next free texture units
Returns | texture_ |
---|
This function will bind the textures to the next free texture units. If there are no more free texture unit to bind to, the function will throw a std::
template<class AllocationPolicy>
bool glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: contains(const key_ t key) const
check if a given key is contained in the atlas
Parameters | |
---|---|
key | [in] key that shall be checked |
Returns | true if key is contained, false if not. |
Check whether a given key is contained in the texture atlas.
template<class AllocationPolicy>
std:: string glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: declaration(const std:: string_view name) const
get declaration for shader compilation
Parameters | |
---|---|
name | [in] binding name of textur atlas in the shader code |
Returns | std:: |
This function will return a GLSL declaration of zero, one or more texture samplers, that are necessary to fetch the pixel data from the texture entries in this texture atlas. The name parameter is used to specify the binding name of the shader atlas. Analog to texture_
template<class AllocationPolicy>
std:: string glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: dynamic_fetch(const std:: string_view name,
const std:: string_view key,
const std:: string_view uv) const
return string to fetch a texel inside shader code
Parameters | |
---|---|
name | [in] name of the texture_ |
key | [in] either the name of a shader variable or a fixed value |
uv | [in] either name of a shader variable of type vec2 or a vec2 value |
Returns | std:: |
This function is basically the same as the normal fetch with the main difference, that a std::
template<class AllocationPolicy>
std:: string glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: dynamic_fetch(const std:: string_view name,
const std:: string_view key,
const glm::vec2 uv) const
return string to fetch a texel inside shader code
Parameters | |
---|---|
name | [in] name of the texture_ |
key | [in] either the name of a shader variable or a fixed value |
uv | [in] value for the uv coordinates that shall be fetched in the shader |
This function is basically the same as the normal fetch with the main difference, that a std::
template<class AllocationPolicy>
bool glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: empty() const
check if atlas is empty
Returns | True, if no textures are contained in the atlas. False otherwise. |
---|
This function if there are textures existant in this atlas. It's equivalent to the size() == 0.
template<class AllocationPolicy>
void glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: erase(const key_ t key)
erase entry from the texture atlas
Parameters | |
---|---|
key | [in] key of element that should be erased |
Erase an element with a given key from the texture atlas. This function will throw an exception, if the key is not contained in the atlas. texture_
template<class AllocationPolicy>
void glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: erase(const entry_ t entry)
erase entry from the texture atlas
Parameters | |
---|---|
entry | [in] entry that shall be erased |
Erase an element with a given key from the texture atlas. This function will throw an exception, if the entry is invalid. The texture_
template<class AllocationPolicy>
std:: string glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: fetch(const std:: string_view name,
const key_ t key,
const std:: string_view uv) const
return string to fetch a texel inside shader code
Parameters | |
---|---|
name | [in] name of the texture_ |
key | [in] key of the texture entry that shall be fetched |
uv | [in] either name of a shader variable of type vec2 or a vec2 value |
Returns | std:: |
This function will generate shader code, that can be used to fetch pixel values from a texture atlas.
template<class AllocationPolicy>
std:: string glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: fetch(const std:: string_view name,
const key_ t key,
const glm::vec2 uv) const
return string to fetch a texel inside shader code
Parameters | |
---|---|
name | [in] name of the texture_ |
key | [in] key of the texture entry that shall be fetched |
uv | [in] value for the uv coordinates that shall be fetched in the shader |
Returns | std:: |
This function will generate shader code, that can be used to fetch pixel values from a texture atlas.
template<class AllocationPolicy>
entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: get(const key_ t key)
access to entries
Parameters | |
---|---|
key | [in] key of texture that shall be accessed |
Returns | texture_ |
This member function allows access to entries in the atlas. The function will NOT check if the requested key is contained in the atlas before access. If the key does not exist, the returned texture_
template<class AllocationPolicy>
const entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: get(const key_ t key) const
access to entries
Parameters | |
---|---|
key | [in] key of texture that shall be accessed |
Returns | texture_ |
This member function allows access to entries in the atlas. The function will NOT check if the requested key is contained in the atlas before access. If the key does not exist, the returned texture_
template<class AllocationPolicy>
entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: insert()
insert element into atlas
Returns | texture_ |
---|
This member function will insert a new entry into the texture atlas.
template<class AllocationPolicy>
entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: insert(const allocation_ hint_ t allocation_hint)
insert element into atlas
Parameters | |
---|---|
allocation_hint | [in] allocation hint |
Returns | texture_ |
This member function will insert a new entry into the texture atlas. Depending on the AllocationPolicy the allocation_hint parameter might or might not be ignored. Trying to allocate a key, that is already taken or invalid keys will throw an exception.
template<class AllocationPolicy>
template<class PixelFormat>
entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: insert(const image_ t<PixelFormat>& image)
template<class PixelFormat>
insert element into atlas
Parameters | |
---|---|
image | [in] pixel data for the inserted texture |
Returns | texture_ |
This member function will insert a new entry into the texture atlas. The entry will allocate a texture on construction and copy over the pixel data from image.
template<class AllocationPolicy>
template<class PixelFormat>
entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: insert(const allocation_ hint_ t allocation_hint,
const image_ t<PixelFormat>& image)
template<class PixelFormat>
insert element into atlas
Parameters | |
---|---|
allocation_hint | [in] allocation hint |
image | [in] pixel data for the inserted texture |
Returns | texture_ |
This member function will insert a new entry into the texture atlas. This overload is a combination of the allocation_hint overload and the image_
template<class AllocationPolicy>
key_ storage_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: keys() const
get the key range of the texture atlas
Returns | key range |
---|
This member function will return an iteratable range of key_t with all keys, that are contained in the texture atlas.
template<class AllocationPolicy>
size_t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: max_size() const
maximum size of the texture atlas
Returns | theoretical maximum of entries into a single instance of the texture atlas |
---|
This function will return a theoretical maximum number of entries to the atlas. Depending on the allocation policy provided it might or might not be possible to use the full amount of max_
template<class AllocationPolicy>
texture_ atlas_ t& glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: operator=(texture_ atlas_ t&& mov) defaulted noexcept
move assignment operator
texture_
template<class AllocationPolicy>
texture_ atlas_ t& glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: operator=(const texture_ atlas_ t& cpy) deleted
copy assignment operator
texture_
template<class AllocationPolicy>
entry_ t glpp:: core:: object:: texture_atlas_t<AllocationPolicy>:: operator[](const key_ t key)
random access operator
Parameters | |
---|---|
key | [in] key of texture that shall be accessed |
Returns | texture_ |
This operator takes a key_t key and returns a texture_