namespace
TextureToolsTexture tools.
Tools for generating, compressing and optimizing textures.
This library is built if MAGNUM_WITH_TEXTURETOOLS
is enabled when building Magnum. To use this library with CMake, request the TextureTools
component of the Magnum
package in CMake and link to the Magnum::TextureTools
target:
find_package(Magnum REQUIRED TextureTools) # ... target_link_libraries(your-app PRIVATE Magnum::TextureTools)
Note that functionality depending on GL APIs is available only if Magnum is built with both MAGNUM_WITH_GL
and MAGNUM_TARGET_GL
enabled (which is done by default).
Additional utilities are built separately. See the magnum-distancefieldconverter utility documentation, Downloading and building and Usage with CMake for more information.
Classes
- class DistanceField
- Create a signed distance field.
Functions
-
auto atlas(const Vector2i& atlasSize,
const std::
vector<Vector2i>& sizes, const Vector2i& padding = Vector2i()) -> std:: vector<Range2Di> - Pack textures into texture atlas.
-
auto atlasArrayPowerOfTwo(const Vector2i& layerSize,
Containers::
StridedArrayView1D<const Vector2i> sizes) -> Containers:: Pair<Int, Containers:: Array<Vector3i>> new in Git master - Pack square power-of-two textures into a texture atlas array.
-
auto atlasArrayPowerOfTwo(const Vector2i& layerSize,
std::
initializer_list<Vector2i> sizes) -> Containers:: Pair<Int, Containers:: Array<Vector3i>> new in Git master -
void distanceField(GL::
Texture2D& input, GL:: Texture2D& output, const Range2Di& rectangle, Int radius, const Vector2i& imageSize = Vector2i{}) deprecated in 2019.01 - Create a signed distance field.
Function documentation
std:: vector<Range2Di> Magnum:: TextureTools:: atlas(const Vector2i& atlasSize,
const std:: vector<Vector2i>& sizes,
const Vector2i& padding = Vector2i())
#include <Magnum/TextureTools/Atlas.h>
Pack textures into texture atlas.
Parameters | |
---|---|
atlasSize | Size of resulting atlas |
sizes | Sizes of all textures in the atlas |
padding | Padding around each texture |
Packs many small textures into one larger. If the textures cannot be packed into required size, empty vector is returned.
Padding is added twice to each size and the atlas is laid out so the padding don't overlap. Returned sizes are the same as original sizes, i.e. without the padding.
Containers:: Pair<Int, Containers:: Array<Vector3i>> Magnum:: TextureTools:: atlasArrayPowerOfTwo(const Vector2i& layerSize,
Containers:: StridedArrayView1D<const Vector2i> sizes) new in Git master
#include <Magnum/TextureTools/Atlas.h>
Pack square power-of-two textures into a texture atlas array.
Parameters | |
---|---|
layerSize | Size of the texture layer |
sizes | Sizes of all textures in the atlas |
Returns | Total layer count and offsets of all textures in the atlas, with the Z coordinate being the layer index |
Both layerSize
and all items in sizes
are expected to be non-zero, square and power-of-two. With such constraints the packing is optimal with no wasted space in all but the last layer. Setting layerSize
to the size of the largest texture in the set will lead to the least wasted space in the last layer.
The algorithm first sorts the textures by size using std::
Containers:: Pair<Int, Containers:: Array<Vector3i>> Magnum:: TextureTools:: atlasArrayPowerOfTwo(const Vector2i& layerSize,
std:: initializer_list<Vector2i> sizes) new in Git master
#include <Magnum/TextureTools/Atlas.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: TextureTools:: distanceField(GL:: Texture2D& input,
GL:: Texture2D& output,
const Range2Di& rectangle,
Int radius,
const Vector2i& imageSize = Vector2i{})
Create a signed distance field.