Universal Graphics & Input
Go to file
2024-04-21 14:12:15 +02:00
src Add unigi_float_2int 2024-04-21 14:12:15 +02:00
.gitmodules Initial commit 2024-04-21 13:35:56 +02:00
LICENSE Initial commit 2024-04-21 13:35:56 +02:00
README.md Initial commit 2024-04-21 13:35:56 +02:00

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.

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 (TODO!))
  • 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. It's meant for running a basic test before one makes a proper port.

  1. cc src/main.c -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 -D unigi_flag_platform_sdl1 -l SDL -o unigi.exe

Advanced configuration

Big Endian (TODO!)

If the target is a Big Endian CPU, one must define -D unigi_flag_endian_big.

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.