unigi/README.md
2024-04-21 16:11:32 +02:00

37 lines
2.1 KiB
Markdown

# unigi
unigi (Universal Graphics & Input) is a collection of headers, that implement a cross-platform API for drawing to the screen (framebuffer or window), and taking inputs (keyboard, mouse, joypad).
This is achieved through platforms (See `src/platform`), which act as the translation layer for different targets. The idea is to minimize the amount of work it takes to port graphical applications.
The pixel format and screen coordinates are standardized, however, the HID inputs are not. It is best to make button layouts for each platform.
<img src="assets/preview.png" title="Preview">
# Features
* Highly compatible with compilers (C89, simple preprocessors)
* No `make` required, entirely configurable from your compiler, or a header file (`src/config/user.h`)
* Supports wide range of hardware (16-bit+, little/big endian)
* Standardized 16-bit color format (RRRRGGGGBBBBAAAA, effectively 12-bit on most platforms)
* Implements API for floats, letting you pick between fixed point or actual float numbers
* Decent performance (Though some performance is sacrificed to standardize the interface. On DOS, it targets 30 fps on i586-class CPUs)
# How to build
## Preparation
1. `git clone "https://git.lumen.sh/Fierelier/unigi"`
2. `git submodule update --init --recursive` (optional, required for fixed point math)
## Platform: null
This platform has a very simple implementation, that is essentially a no-op for any possible target. It's meant for running a basic test before one makes a proper port.
1. `cc src/main.c -O2 -D unigi_flag_platform_null -o unigi.exe`
## Platform: sdl1
This platform implements the highly compatible SDL 1.2, which runs on all sorts of versions of Linux and Windows, as well as big endian CPUs.
1. `cc src/main.c -O2 -D unigi_flag_platform_sdl1 -l SDL -o unigi.exe`
## Advanced configuration
### No stdint.h
If no stdint.h is available, one must define `-D unigi_flag_nostdint` and also one of `-D unigi_flag_alu_*bit` (`*` = 8, 16, 32, 64), depending on how wide the ALU of the target CPU is.
### Fixed point numbers
If fixed point is wished instead of float, one can define `-D unigi_flag_fixedpoint`. This uses the external fptc-lib headers.