PTX Engine
PTX Engine
Section titled “PTX Engine”PTX Engine is the next-generation evolution of ProtoTracer - a header-first C++17 library providing a compact math, geometry, and rendering core designed to run on both microcontrollers and desktop platforms.
Key Improvements Over ProtoTracer
Section titled “Key Improvements Over ProtoTracer”| Feature | ProtoTracer | PTX Engine |
|---|---|---|
| Language Standard | C++11 | C++17 |
| Desktop Support | No | Yes |
| Header-First | No | Yes |
| Runtime Reflection | No | Yes |
| Python Bindings | No | Yes (ctypes) |
| 8-bit AVR Support | No | Yes |
Supported Platforms
Section titled “Supported Platforms”PTX Engine is designed for cross-platform development:
Microcontrollers
Section titled “Microcontrollers”- 32-bit Cortex-M (STM32, Teensy)
- ESP32 (ESP32-S3)
- 8-bit AVR (Arduino UNO, Nano)
Desktop
Section titled “Desktop”- Linux
- Windows
Key Features
Section titled “Key Features”Header-First Design
Section titled “Header-First Design”The entire library is usable as header files, making it easy to integrate into any project without complex build configurations.
Runtime Reflection System
Section titled “Runtime Reflection System”PTX Engine includes a reflection system for runtime discovery and invocation of types and members. This enables:
- Dynamic type introspection
- Runtime method invocation
- Automated serialization
- Binding generation
Python Integration
Section titled “Python Integration”A ctypes-based Python wrapper allows you to:
- Explore reflection metadata
- Test engine functionality from Python
- Rapid prototyping without recompiling
Building the Reflect Library
Section titled “Building the Reflect Library”The reflection system compiles into a shared library:
# From repository rootplatformio run --environment nativereflectlibThe produced shared library will be at:
.pio/build/nativereflectlib/ptx_reflect.soUsing the Python Wrapper
Section titled “Using the Python Wrapper”cd lib/ptx_pythonPYTHONPATH=../../src python3 reflection_demo.py --lib ../../.pio/build/nativereflectlib/ptx_reflect.soOr set the environment variable:
export PTX_C_API_LIB=/full/path/to/ptx_reflect.soPYTHONPATH=../../src python3 reflection_demo.pyCurrent Development Focus
Section titled “Current Development Focus”The project is actively being developed with recent work focusing on:
- Runtime Reflection System - Generator and build scripts for automatic registration
- C ABI Layer - Stable interface for language bindings
- Python Wrapper - ctypes-based exploration of reflection metadata
Project Structure
Section titled “Project Structure”| Directory | Purpose |
|---|---|
engine/ | Core engine code |
bindings/ | Language bindings |
scripts/ | Build and generation scripts |
tests/ | Unit tests |
src/ | Main source and entry points |
Developer Notes
Section titled “Developer Notes”Regenerating Reflection Registry
Section titled “Regenerating Reflection Registry”cmake --build build --target ptx_update_registryThis regenerates:
- Umbrella header (
generated/ptx/ptxall.hpp) - PTX registry cache
Static Utility Pattern
Section titled “Static Utility Pattern”Static utility namespaces (e.g., ptx::Console, ptx::Random, ptx::Time) expose a nested Reflection struct that forwards to their static functions. Follow this pattern for other static-only modules that need runtime access.
Contributing
Section titled “Contributing”See CONTRIBUTING.md in the repository for:
- Coding style guidelines
- Platform-specific guidance
- Pull request process
License
Section titled “License”PTX Engine is released under the AGPL-3.0 license.
Related
Section titled “Related”- ProtoTracer - Current stable version for Protogen projects
- ProtoTracer Helpers - Asset conversion tools