10

We have an introductory course to Computer Graphics this semester in college. There is no recommended way on how to go about the Lab exercises. Most of the students are resorting to Turbo C and the inbuilt graphics.h header file.

I'm a little apprehensive about this, Turbo C is a thing of the 70's and to learn stuff on it seems pointless to me. I can set up the graphics.h for Bloodshed Dev-C++ compiler too or maybe the libgraph on linux systems.

Are there some alternatives to the Borland graphics.h ? I'm looking for relatively modern solutions that are relatively simple in the sense that they don't add too much boilerplate code etc and yet implement the same functionality.

To give a little more information about the tasks that we'd be doing, We'll be implementing basic Graphics Algorithms like the DDA algorithm, Bresenham's Algorithms, Scan Conversion etc. So I need to be able to plot pixels on the screen, I don't need a really high level library that can draw the primitives like lines and circles on its own. If it can its great but to learn I should be able to plot raw pixels on the screen.

Juraj Blaho
  • 13,301
  • 7
  • 50
  • 96
nikhil
  • 8,925
  • 21
  • 62
  • 102

5 Answers5

10

Allegro or SDL libraries may be for you.

I would also suggest not to use Bloodshed Dev-C++ as it is also a little outdated. You may use MS VC++ Express or Code::Blocks which are both free.

Juraj Blaho
  • 13,301
  • 7
  • 50
  • 96
4

Take a look at Cinder. It's a C++ library designed for 'creative coding' and looks pretty simple to use while still being powerful (check the examples).

You could also try SFML. It has quite a following and you'll have a large community behind you should you have any trouble.

0

SDL is your best bet. I could not get graphics.h to work with Dev C++ as newer versions of Windows are incompatible with it. Another graphics library that might work is GLFW, if all you want is to draw windows and UI stuff.

TRex22
  • 47
  • 7
0

If you are looking for "modern" and "not much boilerplate" why not JavaScript? It will run directly in the browser and you can either use a <canvas> element or bundle up a setPixel DOM function in a script you supply to your students.

Here's a link you can look at: http://www.codeproject.com/KB/scripting/javascriptlinedrawing.aspx.

And a SO question: Bresenham algorithm in Javascript.

If you are committed to C++, there is always OpenGL but there is, I suppose a bit more of a learning curve. In the old days there was BGI, and GRX for DJGPP (anyone remember that?). I don't know of many device-independent libraries for writing pixels to the screen (GDI and Xlib are too OS-specific). In the Perl/Python/Tcl world there is Tk, which is O.S. independent.

Personally I like JavaScript for low-level graphics algorithms -- no setup! -- but if you are not tied to C++ it might be worth a look. But if you don't have time to teach JavaScript then perhaps some of your students can implement some algorithms for extra credit.

Community
  • 1
  • 1
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
  • Unfortunately we are tied to C++ so JavaScript won't work for us. – nikhil Aug 01 '11 at 05:51
  • 1
    I kinda figured, but thought I would plug it anyway. I've dabbled in Tk for Perl a while back.... there is port to C++: http://cpptk.sourceforge.net/. – Ray Toal Aug 01 '11 at 06:00
-1

https://easyx.cn/

this library is API compatible with BGI(Borland Graphics Interface, which means it uses "graphics.h") for Visual Studio.

Accellular
  • 11
  • 2