ori_sky 8625c52ee9
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m51s
Implement optimizations for 2D text rendering (#23)
The following patches are included:

## J2D: Rewrite text rendering

This patch rewrites text rendering for `J2D::DrawString` to now construct
a texture atlas for all ASCII-range glyphs in the FT font face, instead
of constructing a texture for every glyph.

This improves text rendering performance for several reasons:

1. Binding textures is relatively expensive as the GPU is required to do
   a context switch for internal data like texture parameters, and also
   cannot optimize for accesses to the same texture across draw calls.
   This patch removes the need to call `glBindTexture` more than once per
   call to `J2D::DrawString`.
2. As a consequence of the above, all glyphs for a given string can now
   be rendered in a single call to `glDrawArrays`. This is done by storing
   the cached texture coordinates on `CachedGlyph` and constructing a full
   array of vertices and texture coordinates for the entire string at
   once, resulting in only /one/ set of client-to-device attribute
   uploads and only one draw call, instead of being required to upload
   attribute data for each glyph separately.

## FontCache: Use map for efficient glyph lookup

This patch updates `CachedFont` to now use an `std::map` for cached glyphs,
instead of an `std::vector`. `std::map` allows O(log n) lookup, whereas
`std::vector` only allows O(n) lookup.

Note: `std::unordered_map` technically has better lookup complexity here,
with amortized O(1) lookup. However, hashmaps have a higher inherent
overhead than red-black trees so this would only be viable when going
above around 1000 entries, which should never happen here for ASCII
glyphs.

Co-authored-by: Ori Sky Farrell <ori.sky.farrell+git@gmail.com>
Reviewed-on: #23
Co-authored-by: ori_sky <redacted@ori.mx>
Co-committed-by: ori_sky <redacted@ori.mx>
2024-07-15 11:38:20 -04:00
2024-07-05 05:31:25 -04:00
2024-01-19 14:23:02 -05:00
2024-01-18 23:28:11 -05:00
2024-07-12 13:14:24 -04:00
2024-07-10 15:17:37 -04:00

Josh Graphics Library

Yet Another C++ Rendering Toolkit

Static Badge

Goals

  • Provide single-function-calls to render various graphics primitives in 2D and 3D.
  • Integrated directly with our other toolkits (ReWindow, J3ML)
  • Quick Rendering of Debug Text, Geometric Widgets, Textures, and so forth.

Non-Goals

  • Full Rendering Engine
  • OpenGL/Vulkan Wrapper
  • Asset Loading & Management

Features

  • Modern C++ (20)
  • Little-to-no overhead
  • No hand-holding
  • No-frills, straight up just renders shapes and text.
  • Integrates right into an existing OpenGL rendering system.

Usage

Install instructions and code samples coming soon ™️ !

Documentation

Documentation is (sic: will be) automatically generated from latest commit and is hosted at https://doc.redacted.cc/jgl .

Contributing

Contributions to JGL are welcome! If you find a bug, have a feature request, or would like to contribute code, please submit an issue or pull request to our repository!

License

JGL is licensed under the Public Domain. See the LICENSE file for details.

Acknowledgements

JGL is developed and maintained by Josh O'Leary @ Co from Redacted Software and contributors. Special thanks to Redacted.

Description
No description provided
Readme 4.2 MiB
Prerelease-2 Latest
2024-02-20 04:46:32 -05:00
Languages
C++ 79.3%
C 19.7%
GLSL 0.8%
CMake 0.2%