Universal Graphics & Input
Go to file
Fierelier 3032426c13 Add platform: dos 2024-04-21 22:19:48 +02:00
assets Add preview 2024-04-21 14:23:00 +02:00
src Add platform: dos 2024-04-21 22:19:48 +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 Add platform: dos 2024-04-21 22:19:48 +02:00

README.md

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)
  • 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 -Dunigi_flag_platform_null

Platform: dos

This platform implements DOS (MS-DOS, FreeDOS, etc.), Tested with Open Watcom.

  1. cc src/main.c -Dunigi_flag_platform_dos

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 -Dunigi_flag_platform_sdl1 -lSDL

Advanced configuration

No stdint.h

If no stdint.h is available, one must define unigi_flag_nostdint and also one of 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 unigi_flag_fixedpoint. This uses the external fptc-lib headers.