The libXbgi Library


   Hopalong

Introduction

This page provides binaries and documentation for libXbgi, an Xlib-based port of old Borland Graphics Interface to X11.

libXbgi is a compatibility library that can be used to port old programs written for Turbo/Borland C to X11, on Linux and other Unix-like systems. 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 with libXbgi.

libXbgi is not as powerful as other graphics libraries such as Allegro or SDL. It's not event-driven, and is not very suitable for games. However, it is extremely simple to use, and it's probably the best choice for teachers and learners of programming. It's pretty fast, too! Programming fractals, cellular automata, geometry, physics models etc. is a breeze with libXbgi.

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

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.

libXbgi is released under a generic free software license; please read License.txt.


Download

The current release of libXbgi is version 364. To compile the library 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.

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


How to Use libXbgi

From the Using.txt file:

To compile a program against libXbgi:

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

Most old programs that use the original BGI library should compile
with no modification. For instance,

  int gd = DETECT, gm;
  initgraph (&gd, &gm, "");

will open a 640x480 window. To specify the window size, you can use
the new X11 driver.

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

#include <conio.h>

if it's present. Alternatively, you may create a dummy (empty) conio.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 are also implemented. Most old programs should compile with no modification. There are a few differences, and a few additions.

Differences

Additions

Issues

If the virtual desktop (when available) is changed, or the window is minimised, its contents are lost. This "bug" is actually a feature, aimed at making libXbgi as fast as possible. For instance, the 'fern.c' test program is about 4 times faster than its GRX equivalent (see below).

The charsize parameter in settextstyle() has no efffect.

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: September 10, 2013