Tutorial: Interactive Computer Graphics with Allegro
This tutorial assumes you have completed our Basics for Beginners tutorial, or that you have some basic experience with C++.
Displaying a picture on a computer screen requires the picture to be computed first and then the result of this computation delivered to computer's display device.
But, what does it mean to compute a picture? Imagine that we divide the picture by a rectangular mesh into many small squares, so small the eye cannot distinguish each one apart. We could call those small squares – pixels. Each pixel should have a single color.
Most colors can be broken down into three primary color components of our choice. We could choose the red, the green and the blue color to be the primary colors. The intensity of a primary color, also called its brightness, is a quantity that can be represented by a number. Therefore, the color of a pixel can be represented by three numbers; one for intensity of red, one for intensity of green and one for intensity of blue component. As the entire picture is made of pixels, and each pixel can be completely described by three numbers, the picture can be represented by a long sequence of numbers. Thus, computing a picture requires the mentioned sequence of numbers to be computed.
If we turn our attention from pure theory to practical issues of computing a picture, two problems arise. First, one we have been, until now, sending all our results to standard output. Microsoft Windows operating systems do not have any convenient ways to utilize standard output to control the display of pictures. Instead, a program needs to issue some commands directly to the operating system. That turns out to be quite an arduous task as the program needs to fulfill a plethora of technical details, requiring many of lines in the program's source code. The second problem is that some pictures are simple to calculate, but most of them are more complicated.
Both problems can be substantially simplified by using a library designed to assist in computer graphics programming. All we need to do is to install such a library to work with our IDE of choice. The library chosen for this book is called Allegro 4 (allegro is an Italian word meaning 'lively').