Termeric is a lightweight terminal graphics engine written in C that provides a simple interface for creating terminal-based graphical applications. It features multi-threaded rendering, performance monitoring, and buffer management.
- Multi-threaded architecture for improved performance
- Raw terminal mode handling for direct input control
- Performance monitoring and statistics
- Vector and buffer utilities for dynamic memory management
- Cross-platform terminal manipulation
- POSIX-compliant operating system
- C compiler with C11 support
- Terminal with ANSI escape sequence support
The project uses standard C headers and POSIX libraries.
To compile:
gcc main.c -o termeric
Termeric is composed of several modular components:
buffer.h
: Implements buffer management for terminal outputengine.h
: Main engine loop and thread managementscreen.h
: Screen manipulation and drawing primitivesinput.h
: Input handling and key mappingtiming.h
: High-precision timing utilitiesvec.h
: Generic vector implementation for dynamic arrays
The engine uses two main threads:
- Render thread: Handles frame rendering
- I/O thread: Manages terminal output
Built-in performance metrics include:
- Average frame time
- Best/worst frame times
- Real-time FPS calculation
- Pixel drawing with custom characters
- Rectangle/square drawing
- Screen clearing and buffer management
Basic example:
#include "engine.h"
#include "input.h"
void render() {
// Your rendering code here
if(get_key() == CTRL_KEY('q')){
engine_close();
}
}
int main() {
engine_init();
return 0;
}
The engine provides several pre-defined special keys:
- Arrow keys
- Page Up/Down
- Escape
- Control key combinations
Drawing operations available:
draw_pixel
: Place a character at specific coordinatesclean_square
: Clear a rectangular areadraw_blank
: Clear entire screen
The engine includes built-in performance monitoring that tracks:
- Frame times
- FPS calculations
- Min/max frame times
- Average performance metrics
Several configurable parameters are available in init.h
:
num_frames
: Number of frame buffers (default: 10)BUF_SIZE
: Buffer size for screen output (default: 8000)debug
: Enable/disable debug mode