|
|
|||
![]() |
Department of Engineering |
| University of Cambridge > Engineering Department > computing help |
Some options (like Visual BASIC) lock you into using a particular language and a particular type of machine.
Any sufficiently useful graphics library is also likely to be complicated too - people don't usually bother going to all the trouble of producing a platform-independant graphics library just to do simple lines and dots.
The trouble with the older languages (Fortran, C++ etc) is that they have no graphics. Before you start wondering how to add graphics to the language you know, it may be worth considering new languages. Maybe matlab can do the whole job. Or maybe it's time to consider java. On the Teaching System you can run a Java demo by typing
java -jar ~tpl/javadir/Java2Demo.jar
We'll first consider drawing lines and dots, etc (not buttons, menus, etc).
X is too low-level for simple use. The vogle graphics library is layered on top of the X library. Until 2006 it was used by undergraduates here when they learnt C++. It supports 3D coordinate systems and animation (you can fling wire-frames around in 3D, for example). It can be used from Fortran, C, C++ etc and can run with X Windows, MS Windows, etc. It's easy to use, but ancient.
plotutils is a GNU product with support for X (i.e. it will run on any machine that supports X)
Some CUED groups use OpenGL. It's free and works with many languages (C++, Fortran, Python, Perl, Java, etc). As with X, you need to write many line of code even to draw a line. The OpenGL Utility Kit (GLUT) makes it considerably easier to learn about and explore OpenGL programming. It's designed for constructing small to medium sized OpenGL programs. There's a local introduction to Using GLUT. But even that's not simple enough for undergraduate use, so we provide a simplified version for the first years, called GLUE.
Drawing anything from scratch is a struggle. Matlab can be used like a graphics library from fortran, C, and C++, letting you do in a few lines what would otherwise take hundreds.
Another option is the Visualization ToolKit (VTK).
Blender is one of several free programs that deals with Rigging, Animation, modeling, Rendering, Shading, and game creation. Yafray is a free raytracer that can be used as a plug-in to Blender.
The Graphical User Interfaces (GUI - pronounced "goo-ee") can make or break a program, and can be a significant proportion of the code. The principles behind many GUI systems are similar. I'll talk about Motif. Motif is built on top of the X library. It has Widgets of 2 main types: simple widgets like buttons, text labels, etc, and container widgets that group and align other widgets. The Widgets can respond to Events like button presses, etc. The idea is that you specify the features of the widgets (color, text size, etc) and how you'd like them organised (button1 to the left of button2, etc) and Motif does the rest, coping with window-resizing etc. The Widgets can have callbacks - routines that are called when particular events happen.
One particular type of Widget is a Drawing Area widget (sometimes called a canvas) - an area in which graphics (using Xlib routines for example) can be drawn.
A number of options exist for creating GUIs. The best way is to use a GUI creator that lets you draw the kind of application you want to write and then creates the source code you need. Matlab's guide does this for matlab programs. Some other programs give you a choice of types of source code to produce. The final appearance is unlikely to be exactly the same in each case though. Indeed, you may prefer them to look different - people running your program on Windows might expect a program with the look'n'feel of other Windows programs.
If you don't have a GUI creator you can use
On our Installing C++ compilers page we show how to install C++ compilers with support for openGL and GLUT on Macs, Windows, and Linux.
Within CUED, activity seems to be focussing around 2 main styles of work
| | computing help | Graphics | |