About the library
TGX is a tiny but full featured C++ library for drawing 2D and 3D graphics onto a memory framebuffer. The library runs on both microprocessor and microcontollers but specifically targets 'powerful' 32 bits MCUs such as ESP32, RP2040, Teensy 3/4...
Features
- Hardware agnostic: the library simply draws on a memory framebuffer.
- Optimized RAM usage and no dynamic allocation.
- No external dependency (and no STL): just include the .h and .cpp files to your project and your are set!
- Library in Arduino friendly format.
- Mutiple color formats supported:
RGB565
, RGB24
, RGB32
, RGB64
, RGBf
, HSV
Image
class that encapsulates a buffer and allows the creation of sub-images for clipping any drawing operations.
- Extensive 2D API:
- Methods for converting, blittings, copying and resizing sprites with high quality (bilinear filtering, sub-pixel precision).
- Methods for drawing lines, polylines, polygons, triangles, rectangles, rounded rectangles, quads, circles, arcs, ellipses, Bezier curve and splines !
- Methods for drawing Text with support for multiple font formats.
- All drawings operations support alpha-blending.
- Most drawing methods come in two flavours: a 'fast' method and a 'high quality' which is slower but draws using anti-aliasing and sub-pixel precision.
- Extensive 3D API.
- Optimized 'pixel perfect' triangle rasterizer with adjustable sub-pixel precision.
- Depth buffer testing (selectable 16 bits or 32 bits precision).
- Multiple drawing modes: wireframe (selectable low/high quality) and solid (i.e. with shaders).
- Flat and Gouraud Shading.
- Phong lightning's model with separate ambient/diffuse/specular color components.
- Per object material properties.
- Perspective-correct texture mapping with selectable point sampling/bilinear filtering and multiple wrapping modes.
- Perspective and orthographic projections.
- Optional backface culling.
- Tile rasterization: it is possible to render the viewport in multiple passes to save RAM.
- Templates classes for all the needed maths:
Vec2
, Vec3
, Vec4
(vectors), Mat4
(4x4 matrix) and Box2
, Box3
(boxes).
- Optimized mesh data format: meshes and textures can be read directly from flash memory to save RAM.
- Python scripts for easy conversion of texture images and 3D meshes (in Wavefront's .obj format) into C files.
Getting started
- Installation
- Using the 2D API.
- Using the 3D API.
- Note
- Do not forget to look at the examples located in
\examples
subfolder of the library !
References
Basic classes (2D graphics)
Additional classes specific to drawing 3D graphics