class new in Git master
#include <Magnum/Text/GlyphCacheGL.h>
GlyphCacheArrayGL OpenGL array glyph cache.
Implementation of an AbstractGlyphCache backed by a GL::
Containers::Pointer<Text::AbstractFont> font = …; Text::GlyphCacheArrayGL cache{PixelFormat::R8Unorm, {256, 256, 8}}; if(!font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789?!:;,. ")) Fatal{} << "Glyph cache too small to fit all characters";
Assuming a RendererGL is used with this cache for rendering the text, its mesh() can be then drawn using Shaders::
Text::RendererGL renderer{cache}; … Shaders::VectorGL2D shader{Shaders::VectorGL2D::Configuration{} .setFlags(Shaders::VectorGL2D::Flag::TextureArrays) }; shader … .bindVectorTexture(cache.texture()) .draw(renderer.mesh());
Base classes
- class AbstractGlyphCache new in 2019.10
- Base for glyph caches.
Constructors, destructors, conversion operators
- GlyphCacheArrayGL(PixelFormat format, const Vector3i& size, const Vector2i& padding = Vector2i{1}) explicit new in Git master
- Constructor.
- GlyphCacheArrayGL(PixelFormat format, const Vector3i& size, PixelFormat processedFormat, const Vector2i& processedSize, const Vector2i& padding = Vector2i{1}) explicit new in Git master
- Construct with a specific processed format and size.
- GlyphCacheArrayGL(NoCreateT) explicit noexcept new in Git master
- Construct without creating the internal state and the OpenGL texture object.
Public functions
-
auto texture() -> GL::
Texture2DArray& - Cache texture.
Function documentation
Magnum:: Text:: GlyphCacheArrayGL:: GlyphCacheArrayGL(PixelFormat format,
const Vector3i& size,
const Vector2i& padding = Vector2i{1}) explicit new in Git master
Constructor.
Parameters | |
---|---|
format | Source image format |
size | Source image size size in pixels |
padding | Padding around every glyph in pixels |
The size
is expected to be non-zero. If the implementation advertises GlyphCacheFeature::format
and size
, use AbstractGlyphCache(PixelFormat, const Vector3i&, PixelFormat, const Vector2i&, const Vector2i&) to specify different values.
Magnum:: Text:: GlyphCacheArrayGL:: GlyphCacheArrayGL(PixelFormat format,
const Vector3i& size,
PixelFormat processedFormat,
const Vector2i& processedSize,
const Vector2i& padding = Vector2i{1}) explicit new in Git master
Construct with a specific processed format and size.
Parameters | |
---|---|
format | Source image format |
size | Source image size size in pixels |
processedFormat | Processed image format |
processedSize | Processed glyph cache texture size in pixels |
padding | Padding around every glyph in pixels. See Glyph padding for more information about the default. |
The size
and processedSize
is expected to be non-zero, depth of processed size is implicitly the same as in size
. All glyphs are saved in format
relative to size
and with padding
, although the actual glyph cache texture is in processedFormat
and has processedSize
.
Magnum:: Text:: GlyphCacheArrayGL:: GlyphCacheArrayGL(NoCreateT) explicit noexcept new in Git master
Construct without creating the internal state and the OpenGL texture object.
The constructed instance is equivalent to moved-from state, i.e. no APIs can be safely called on the object. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.
This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active. However note that this is a low-level and a potentially dangerous API, see the documentation of NoCreate for alternatives.