The libXbgi and SDL_bgi Libraries


   Hopalong

Introduction

This page provides binaries and documentation for libXbgi and SDL_bgi. These are ports of old Borland Graphics Interface, originally written for DOS, to modern systems.

libXbgi is based on Xlib, while SDL_bgi is based on SDL and SDL_gfx. libXbgi is specifically designed to be as compatible as possible with old BGI, while SDL_bgi is more portable and faster.

These compatibility libraries can be used to port old programs written for Turbo/Borland C to Linux, other Unix-like systems, and Windows (SDL_bgi). And, of course, to write new graphics programs with minimal effort: BGI, once extremely popular, was probably the simplest way to implement presentation graphics in C programs. The same ease of programming can be obtained on modern systems. Programming fractals, cellular automata, geometry, physics models etc. is a breeze with libXbgi or SDL_bgi.

libXbgi is part of Ptoc, a Pascal to C converter written by Dr. Konstantin Knizhnik. SDL_bgi was written by Dr. Guido Gonzato.

Documentation and sample BGI programs are available at this address: http://www.cs.colorado.edu/~main/cs1300/doc/bgi/. Nearly all programs can be compiled with libXbgi or SDL_bgi.

libXbgi is released under a generic free software license; please read License.txt. SDL_bgi is licensed under the Zlib license.


Download

libXbgi

The current release of libXbgi is version 364. To compile it from sources, you will need a compiler (gcc or clang are fine) and the X11 development packages; on Ubuntu-like distributions, it's 'libx11-dev' and its depencencies.

SDL_bgi

The current release of SDL_bgi is 1.0.1. To compile it from sources, you will need a compiler (gcc or clang are fine), SDL 1.2 and SDL_gfx1.2. On Ubuntu-like distributions, you will need the package 'libsdl-gfx1.2-dev' and its dependencies.

These packages were built on a Linux Mint 17 box. The DEB packages were obtained via the alien converter.


How to Use libXbgi or SDL_bgi

To compile a program using libXbgi, make sure that it includes the 'graphics.h' header file. Then:

gcc -o program program.c /usr/lib/libXbgi.a -lX11 -lm

To compile a program using SDL_bgi, make sure that it includes the 'SDL_bgi.h' header file. Then:

gcc -o program program.c -lSDL_bgi -lSDL_gfx -lSDL

In most cases, all you have to do to compile an old program is comment out the lines

#include <conio.h>
#include <dos.h>

if they're present. Alternatively, you may create dummy (empty) conio.h and dos.h file, if you wish.

Please consult the enclosed documentation for more information.


Features

Nearly all graphics functions work correctly; basic mouse support and RGB extensions, as described here, are also implemented. Most old programs should compile with no modification.

Please consult the enclosed documentation for more information.

Sample Programs

libXbgi comes with a few demo programs, including a turtle graphics mini library.

Borland BGI demo (slightly modified): borland

This is the output of fern.c, an IFS system: fern

The ubiquitous mandelbrot.c: mandelbrot

Mouse and RGB colours, mousetest.c: mousetest

Turtle graphics, turtledemo.c: turtledemo


Links

Other similar implementations are:


This page is maintained by Guido Gonzato, PhD.

To contact me: guido dot gonzato at gmail dot com

Made with Jed libxbgi at SourceForge.net

Last modified: November 7, 2014