class new in Git master
#include <Magnum/Text/GlyphCacheGL.h>
GlyphCacheGL OpenGL glyph cache.
Contains font glyphs rendered into a texture atlas.
Usage
Create the GlyphCacheGL object with sufficient size and then call AbstractFont::
Containers::Pointer<Text::AbstractFont> font = …; font->openFile("font.ttf", 12.0f); Text::GlyphCacheGL cache{PixelFormat::R8Unorm, Vector2i{128}}; font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789?!:;,. ");
See the Renderer class for information about text rendering. The AbstractGlyphCache base class has more information about general glyph cache usage.
Internal texture format
The GL::
If PixelFormat::
While this is abstracted away to not affect common use through image(), processedImage() or setProcessedImage(), code interacting directly with texture() may need to special-case this. In particular, if image processing needs to render to the texture, it may need to choose a different format as luminance usually cannot be rendered to.
Base classes
- class AbstractGlyphCache new in 2019.10
- Base for glyph caches.
Derived classes
- class DistanceFieldGlyphCacheGL new in Git master
- OpenGL glyph cache with distance field rendering.
Constructors, destructors, conversion operators
- GlyphCacheGL(PixelFormat format, const Vector2i& size, const Vector2i& padding = Vector2i{1}) explicit new in Git master
- Constructor.
-
GlyphCacheGL(GL::
TextureFormat internalFormat, const Vector2i& size, const Vector2i& padding = Vector2i{1}) deprecated in Git master explicit - Constructor.
-
GlyphCacheGL(GL::
TextureFormat internalFormat, const Vector2i& size, const Vector2i& processedSize, const Vector2i& padding) deprecated in Git master explicit - Construct with a specific processed size.
- GlyphCacheGL(const Vector2i& size, const Vector2i& padding = Vector2i{1}) deprecated in Git master explicit
- Construct with an implicit format.
- GlyphCacheGL(const Vector2i& size, const Vector2i& processedSize, const Vector2i& padding) deprecated in Git master explicit
- Construct with an implicit format and a specific processed size.
- GlyphCacheGL(NoCreateT) explicit noexcept new in Git master
- Construct without creating the internal state and the OpenGL texture object.
- GlyphCacheGL(PixelFormat format, const Vector2i& size, PixelFormat processedFormat, const Vector2i& processedSize, const Vector2i& padding = Vector2i{1}) protected explicit new in Git master
- Construct with a specific processed format and size.
Public functions
-
auto texture() -> GL::
Texture2D& - Cache texture.
Function documentation
Magnum:: Text:: GlyphCacheGL:: GlyphCacheGL(PixelFormat format,
const Vector2i& 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:: GlyphCacheGL:: GlyphCacheGL(GL:: TextureFormat internalFormat,
const Vector2i& size,
const Vector2i& padding = Vector2i{1}) explicit
Constructor.
Magnum:: Text:: GlyphCacheGL:: GlyphCacheGL(GL:: TextureFormat internalFormat,
const Vector2i& size,
const Vector2i& processedSize,
const Vector2i& padding) explicit
Construct with a specific processed size.
Magnum:: Text:: GlyphCacheGL:: GlyphCacheGL(const Vector2i& size,
const Vector2i& padding = Vector2i{1}) explicit
Construct with an implicit format.
Calls GlyphCacheGL(PixelFormat, const Vector2i&, const Vector2i&) with format
set to PixelFormat::
Magnum:: Text:: GlyphCacheGL:: GlyphCacheGL(const Vector2i& size,
const Vector2i& processedSize,
const Vector2i& padding) explicit
Construct with an implicit format and a specific processed size.
Calls GlyphCacheGL(PixelFormat, const Vector2i&, PixelFormat, const Vector2i&, const Vector2i&) with format
and processedFormat
set to PixelFormat::
Magnum:: Text:: GlyphCacheGL:: GlyphCacheGL(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.
Magnum:: Text:: GlyphCacheGL:: GlyphCacheGL(PixelFormat format,
const Vector2i& size,
PixelFormat processedFormat,
const Vector2i& processedSize,
const Vector2i& padding = Vector2i{1}) explicit protected 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. All glyphs are saved in format
relative to size
and with padding
, although the actual glyph cache texture is in processedFormat
and has processedSize
.
Meant to be only used by subclasses that advertise GlyphCacheFeature::format
, size
and processedFormat
, processedSize
into account.