WinBGIm, anyone?

Every year I get a lot of requests for a working WinBGIm. (Ever since 2005 when I helped that one person...)

Since that time we have newer and better versions of GCC. Not to mention that WinBGIm is currently broken as it is.

So today I created a github project that you can direct people to when they start asking for graphics.h stuff.

https://github.com/Duthomhas/WinBGIm-fixed-sort-of-

I did not write WinBGIm -- I do not maintain it -- all I did was fix it enough to compile under its original constraints:

  * Requires Windows
  * Requires MinGW
  * Only works when compiling for 32-bit
  * Only works for C++ (not C)

I'll be emailing the guys at the University of Colorado in just a few minutes to point them to it too, in case they wish to update their code to the fixed stuff. If they do (and I'm kind of hoping they do) then maybe I'll get less PMs from people trying to get their homework to compile.

Anyway, enjoy. If you want to check it out, there's an old "Kaleidoscope" screen saver I wrote in there, just for the nostalgia.

--Michael
I managed to build the example in VS 2015 CE.
Only change needed was #include "winbgim.h" instead of #include <graphics.h> in example.cpp
"winbgim.h" and "graphics.h" are identical; "graphics.h" is generated by the makefile.

I haven't bothered playing with compiling with MSVC, but I'm glad you got it working.

Perhaps I'll add a MSVC makefile too...
And update the README.md to indicate that it can be done...

Thanks for checking it out!
:O)
You are very welcome. :)
There are quite a few warnings, not sure if you want to fix them.

winthread.cxx(320): warning C4101: 'i': unreferenced local variable
  winbgi.cxx
winbgi.cxx(81): warning C4800: 'BOOL': forcing value to bool 'true' or 'false' (performance warning)
winbgi.cxx(134): warning C4101: 'actual_color': unreferenced local variable
winbgi.cxx(133): warning C4101: 'bgi_color': unreferenced local variable
winbgi.cxx(494): warning C4996: 'sprintf': This function or variable may be unsafe. 
Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. 
See online help for details.
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: see declaration of 'sprintf'
  text.cxx
text.cxx(348): warning C4018: '<': signed/unsigned mismatch
  palette.cxx
  mouse.cxx
  misc.cxx
misc.cxx(595): warning C4838: conversion from 'int' to 'unsigned short' requires a narrowing conversion
misc.cxx(596): warning C4838: conversion from 'int' to 'unsigned short' requires a narrowing conversion
misc.cxx(597): warning C4838: conversion from 'int' to 'unsigned short' requires a narrowing conversion
misc.cxx(598): warning C4838: conversion from 'int' to 'unsigned short' requires a narrowing conversion
misc.cxx(599): warning C4838: conversion from 'int' to 'unsigned short' requires a narrowing conversion
  file.cxx
  example.cpp
  drawing.cxx
drawing.cxx(819): warning C4101: 'tries': unreferenced local variable
drawing.cxx(859): warning C4101: 'answer': unreferenced local variable
drawing.cxx(1110): warning C4996: 'strcat': This function or variable may be unsafe. 
Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(90): note: see declaration of 'strcat'
I have no interest in fixing the code -- I didn't write it. All I've done is make it more easily usable by people being asked to use it in school and the like.

(I have been considering writing a cross-platform replacement for some years now, but it is pretty low on the step-ladder of things I'd like to do someday...)
What exactly is WinBGIm? I see that it's some sort of graphics library but not sure its use.
Last edited on
Back in the days of 16-bit...
Borland created a nice little library to play with graphics modes on your computer. Every video card manufacturer was different, but before that, even, people still had things like CGA and EGA cards. (I had an HGC — a thing of beauty, really.)

Programming each required different code, of course, so if you wanted to ship a program that did graphical stuff you also had to ship “drivers” (plug-ins, really) that understood how to manipulate your video card.

(The same situation exists today, except now card manufacturers understand that they should provide a common interface to their stuff and make installation as painless as possible — as in, plug-n-play.)


Borland's solution for Turbo C / Pascal / Basic was to provide the Borland Graphics Interface, or BGI, which let you query and initialize a graphics mode and then do things like draw lines and circles and text and pictures on the display. The BGI worked by finding an appropriate bgi file: egavga.bgi, for example, and loading it all plug-in style.

The interface to this library, in C at least, was accessible with #include "graphics.h" .


The library was simplistic and not really suited for any serious graphics crunching (as in modern games), but at the time it was still very cool that a programmer had such easy access to doing basic graphics. A lot of games were, in fact, written using it. (Serious game writers usually skipped BGI for their proprietary systems.)

But the simplicity and ease-of-use has made it a classic, and it still has people who like to play with it today. Alas, we live in a very different world than it was 20+ years ago, and the old BGI library is useless on modern hardware without some serious help. (DOSBox, anyone?)


Enter some fellows at the University of Chicago
who wanted to let their students play with the old “graphics.h” library. They wrote a version of it that worked on Windows and compiled with MinGW and called it, predictably, something like “Windows BGI for MinGW”, or “WinBGIm”.


The best way to learn more about it is to play with it. It's actually kind of fun. Download my repo and give it a compile to see some pretty lines and colors. Then explore the documentation and play with it. http://www.cs.colorado.edu/~main/cs1300/doc/bgi/bgi.html

You can find example programs at http://www.programmingsimplified.com/c/graphics.h — all written for the original BGI but still perfectly valid under WinBGIm.

I've written things like BreakOut and SpaceWar clones with it, and a TMNT game, complete with a sprite editor, various DND-style dungeon crawlers, etc. So for me, at least, it is packed full of nostalgia.
Topic archived. No new replies allowed.