Chapter 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Chapter One: Introduction to Computer Graphics

Computer Graphics
Chapter One: Introduction to Computer Graphics
1. Introduction
The term computer graphics has been used in a broad sense to describe "almost everything on
computers that is not text or sound". Typically, the term computer graphics refers to several
different things:
 The representation and manipulation of image data by a computer
 The various technologies used to create and manipulate images
 The images so produced, and
 The sub-field of computer science which studies methods for digitally synthesizing
and manipulating visual content, see study of computer graphics
The study of computer graphics is a sub-field of computer science which studies methods for
digitally synthesizing and manipulating visual content. Although the term often refers to three
dimensional computer graphics, it also encompasses two-dimensional graphics and image
processing.
As an academic discipline, computer graphics studies the manipulation of visual and
geometric information using computational techniques. It focuses on the mathematical and
computational foundations of image generation and processing rather than purely aesthetic
issues. Computer graphics is often differentiated from the field of visualization, although the
two fields have many similarities.
Initial Development of Computer Graphics
The advance in computer graphics was to come from one MIT student, Ivan Sutherland. In
1961 Sutherland created another computer drawing program called Sketchpad. Using a light
pen, Sketchpad allowed one to draw simple shapes on the computer screen, save them and
even recall them later. The light pen itself had a small photoelectric cell in its tip. This cell
emitted an electronic pulse whenever it was placed in front of a computer screen and the
screen's electron gun fired directly at it. By simply timing the electronic pulse with the current
location of the electron gun, it was easy to pinpoint exactly where the pen was on the screen at
any given moment. Once that was determined, the computer could then draw a cursor at that
location.
Sutherland seemed to find the perfect solution for many of the graphics problems he faced.
Even today, many standards of computer graphics interfaces got their start with this early
Sketchpad program. One example of this is in drawing constraints. If one wants to draw a
square for example, s/he doesn't have to worry about drawing four lines perfectly to form the
edges of the box. One can simply specify that s/he wants to draw a box, and then specify the
location and size of the box. The software will then construct a perfect box, with the right
dimensions and at the right location.
Another example is that Sutherland's software modeled objects - not just a picture of objects.
In other words, with a model of a car, one could change the size of the tires without affecting
the rest of the car. It could stretch the body of the car without deforming the tires.
These early computer graphics were Vector graphics, composed of thin lines whereas modern
day graphics are Raster based using pixels. The difference between vector graphics and raster
graphics can be illustrated with a shipwrecked sailor. He creates an SOS sign in the sand by
arranging rocks in the shape of the letters "SOS." He also has some brightly colored rope,
1
Chapter One: Introduction to Computer Graphics

with which he makes a second "SOS" sign by arranging the rope in the shapes of the letters.
The rock SOS sign is similar to raster graphics. Every pixel has to be individually accounted
for. The rope SOS sign is equivalent to vector graphics. The computer simply sets the starting
point and ending point for the line and perhaps bends it a little between the two end points.
The disadvantages to vector files are that they cannot represent continuous tone images and
they are limited in the number of colors available. Raster formats on the other hand work well
for continuous tone images and can reproduce as many colors as needed.
Also in 1961 another student at MIT, Steve Russell, created the first video game, Spacewar.
Written for the DEC PDP-1, Spacewar was an instant success and copies started flowing to
other PDP-1 owners and eventually even DEC got a copy. The engineers at DEC used it as a
diagnostic program on every new PDP-1 before shipping it. The sales force picked up on this
quickly enough and when installing new units, would run the world's first video game for
their new customers.
E. E. Zajac, a scientist at Bell Telephone Laboratory (BTL), created a film called "Simulation
of a two-giro gravity attitude control system" in 1963. In this computer generated film, Zajac
showed how the attitude of a satellite could be altered as it orbits the Earth. He created the
animation on an IBM 7090 mainframe computer. Also at BTL, Ken Knowlton, Frank Sindon
and Michael Noll started working in the computer graphics field. Sindon created a film called
Force, Mass and Motion illustrating Newton's laws of motion in operation. Around the same
time, other scientists were creating computer graphics to illustrate their research. At Lawrence
Radiation Laboratory, Nelson Max created the films, "Flow of a Viscous Fluid" and
"Propagation of Shock Waves in a Solid Form." Boeing Aircraft created a film called
"Vibration of an Aircraft."
It wasn't long before major corporations started taking an interest in computer graphics. TRW,
Lockheed-Georgia, General Electric and Sperry Rand are among the many companies that
were getting started in computer graphics by the mid 1960's. IBM was quk2ick to respond to
this interest by releasing the IBM 2250 graphics terminal, the first commercially available
graphics computer.
A student by the name of Edwin Catmull started at the University of Utah in 1970 and signed
up for Sutherland's computer graphics class. Catmull had just come from The Boeing
Company and had been working on his degree in physics. Growing up on Disney, Catmull
loved animation yet quickly discovered that he didn't have the talent for drawing. Now
Catmull (along with many others) saw computers as the natural progression of animation and
they wanted to be part of the revolution. The first animation that Catmull saw was his own.
He created an animation of his hand opening and closing. It became one of his goals to
produce a feature length motion picture using computer graphics. In the same class, Fred
Parke created an animation of his wife's face. Because of Evan's and Sutherland's presence,
UU was gaining quite a reputation as the place to be for computer graphics research so
Catmull went there to learn 3D animation.
As the UU computer graphics laboratory was attracting people from all over, John Warnock
was one of those early pioneers; he would later found Adobe Systems and create a revolution
in the publishing world with his PostScript page description language. Tom Stockham led the
image processing group at UU which worked closely with the computer graphics lab. Jim
Clark was also there; he would later found Silicon Graphics, Inc.

2
Chapter One: Introduction to Computer Graphics

The first major advance in 3D computer graphics was created at UU by these early pioneers,
the hidden-surface algorithm. In order to draw a representation of a 3D object on the screen,
the computer must determine which surfaces are "behind" the object from the viewer's
perspective, and thus should be "hidden" when the computer creates (or renders) the image.
Image types
2D computer graphics
2D computer graphics are the computer-based generation of digital images—mostly from two
dimensional models, such as 2D geometric models, text, and digital images, and by
techniques specific to them.
2D computer graphics are mainly used in applications that were originally developed upon
traditional printing and drawing technologies, such as typography, cartography, technical
drawing, advertising, etc... In those applications, the two-dimensional image is not just a
representation of a real world object, but an independent artifact with added semantic value;
two dimensional models are therefore preferred, because they give more direct control of the
image than 3D computer graphics, whose approach is more akin to photography than to
typography.
Pixel art
Pixel art is a form of digital art, created through the use of raster graphics software, where
images are edited on the pixel level. Graphics in most old (or relatively limited) computer and
video games, graphing calculator games, and many mobile phone games are mostly pixel art.
Vector graphics
Vector graphics formats are complementary to raster graphics, which is the representation of
images as an array of pixels, as it is typically used for the representation of photographic
images. Vector graphics consists in encoding information about shapes and colors that
comprise the image, which can allow for more flexibility in rendering. There are instances
when working with vector tools and formats is best practice and instances when working with
raster tools and formats is best practice. There are times when both formats come together. An
understanding of the advantages and limitations of each technology and the relationship
between them is most likely to result in efficient and effective use of tools.

3
Chapter One: Introduction to Computer Graphics

3D computer graphics
3D computer graphics in contrast to 2D computer graphics are graphics that use a three-
dimensional representation of geometric data that is stored in the computer for the purposes of
performing calculations and rendering 2D images. Such images may be for later display or for
real-time viewing.
Despite these differences, 3D computer graphics rely on many of the same algorithms as 2D
computer vector graphics in the wire frame model and 2D computer raster graphics in the
final rendered display. In computer graphics software, the distinction between 2D and 3D is
occasionally blurred; 2D applications may use 3D techniques to achieve effects such as
lighting, and primarily 3D may use 2D rendering techniques.
3D computer graphics are often referred to as 3D models. Apart from the rendered graphic,
the model is contained within the graphical data file. However, there are differences. A 3D
model is the mathematical representation of any three-dimensional object. A model is not
technically a graphic until it is visually displayed. Due to 3D printing, 3D models are not
confined to virtual space. A model can be displayed visually as a two dimensional image
through a process called 3D rendering, or used in non-graphical computer simulations and
calculations. There are some 3D computer graphics software for users to create 3D images.
Computer animation
Computer animation is the art of creating moving images via the use of computers. It is a
subfield of computer graphics and animation. Increasingly it is created by means of 3D
computer graphics, though 2D computer graphics are still widely used for stylistic, low
bandwidth, and faster real-time rendering needs. Sometimes the target of the animation is the
computer itself, but sometimes the target is another medium, such as film. It is also referred to
as CGI (Computer generated imagery or computer-generated imaging), especially when used
in films.
Virtual entities may contain and be controlled by assorted attributes, such as transform values
(location, orientation, and scale) stored in an object's transformation matrix. Animation is the
change of an attribute over time. Multiple methods of achieving animation exist; the
rudimentary form is based on the creation and editing of keyframes, each storing a value at a
given time, per attribute to be animated. The 2D/3D graphics software will interpolate
between keyframes, creating an editable curve of a value mapped over time, resulting in
animation. Other methods of animation include procedural and expression-based techniques:
the former consolidates related elements of animated entities into sets of attributes, useful for
creating particle effects and crowd simulations; the latter allows an evaluated result returned
from a user-defined logical expression, coupled with mathematics, to automate animation in a
predictable way (convenient for controlling bone behavior beyond what a hierarchy offers in
skeletal system set up).
To create the illusion of movement, an image is displayed on the computer screen then
quickly replaced by a new image that is similar to the previous image, but shifted slightly.
This technique is identical to the illusion of movement in television and motion pictures.

4
Chapter One: Introduction to Computer Graphics

Basics
Images are typically produced by optical devices; such as cameras, mirrors, lenses, telescopes,
microscopes, etc. and natural objects and phenomena, such as the human eye or water
surfaces.
A digital image is a representation of a two-dimensional image in binary format as a sequence
of ones and zeros. Digital images include both vector images and raster images, but raster
images are more commonly used.
Pixel
In digital imaging, a pixel (or picture element) is a single point in a raster image. Pixels are
normally arranged in a regular 2-dimensional grid, and are often represented using dots or
squares. Each pixel is a sample of an original image, where more samples typically provide a
more accurate representation of the original.
The intensity of each pixel is variable; in color systems, each pixel has typically three
components such as red, green, and blue.

More image from the book


Graphics

5
Chapter One: Introduction to Computer Graphics

Graphics are visual presentations on some surface, such as a wall, canvas, computer screen,
paper, or stone to brand, inform, illustrate, or entertain. Examples are photographs, drawings,
line art, graphs, diagrams, typography, numbers, symbols, geometric designs, maps,
engineering drawings, or other images. Graphics often combine text, illustration, and color.
Graphic design may consist of the deliberate selection, creation, or arrangement of
typography alone, as in a brochure, flier, poster, web site, or book without any other element.
Clarity or effective communication may be the objective, association with other cultural
elements may be sought, or merely, the creation of a distinctive style.
Applications of computer graphics
Today, computers and computer-generated images touch many aspects of daily life. Computer
imagery is found on television, in newspapers, for example in weather reports, or for example
in all kinds of medical investigation and surgical procedures. A well-constructed graph can
present complex statistics in a form that is easier to understand and interpret. In the media
"such graphs are used to illustrate papers, reports, thesis", and other presentation material.
The development of computer graphics has made computers easier to interact with, and
better for understanding and interpreting many types of data. Developments in computer
graphics have had a profound impact on many types of media and have revolutionized
animation, movies and the video game industry.
The following are lists of fields in which computer graphics play very important role.
 Computational biology  Infographics
 Computational physics  Information visualization
 Computer-aided design  Rational drug design
 Computer simulation  Scientific visualization
 Digital art  Video Games
 Education  Virtual reality
 Graphic design  Web design

Before we look in any more detail at how computers can generate graphical images, let us
consider why we would want to do this. Since the early days of computing, the field of
computer graphics has become a very popular one because of its wide range of applications.
The following sections summarise the main categories of application.

Graphs and Charts: Graphs and charts have long been used for visualising data. They are
particularly widely used for visualising relationships and trends in scientific, mathematical,
financial and economic data. Although, in principle, we do not need advanced graphics
algorithms to display graphs and charts, many modern visualisation packages use 3-D effects
such as shadowing to make the graph/chart more visually appealing. For example, Figure
shows a range of graphs and charts produced by the free Fusion Charts Lite package
(http://www.infosoftglobal.com/FusionCharts/Lite). Commercial packages are also available
and include Microsoft Excel.

6
Chapter One: Introduction to Computer Graphics

(a) (b)

(c) (d)

Figure - Computer Graphics used for Graphs and Charts

Computer-Aided Design: Computer-Aided Design (CAD) and Computer-Aided Drafting


and Design (CADD) involve using a computer application to enable designers to construct
and visualise 3-D models. They are commonly used in fields such as architecture, engineering
and circuit design. For example, Error! Reference source not found. shows two screenshots
from CAD applications being used for architecture. One of the most common CAD
applications is AutoCAD.
Computer-Aided Manufacturing (CAM) is a similar concept to CAD, except that the design
application is linked to the manufacturing process, i.e. the application will directly control, via
a hardware communication link, the machine that manufactures the object being designed.

7
Chapter One: Introduction to Computer Graphics

(a) (b)

Figure - Computer Graphics used for Computer-Aided Design (CAD)


Data Visualisation: We already discussed how graphics can be used for visualising data in the
form of graphs and charts. More complex, often multidimensional, datasets can also be
visualised using graphics techniques. In this case, it is often difficult to visualise such datasets
without computer graphics. These complex datasets are particularly common in science
(scientific visualisation) and business (business visualisation).
For example, figure below (a) shows a three-dimensional medical dataset of a patient. Here
we use computer graphics to visualise the paths of blood vessels inside the patient’s head.
Figure below (b) shows an image generated from data acquired by the Hubble Space
Telescope. This image of a distant galaxy is allowing us to visualise a four-dimensional
dataset – three dimensions are combined as the red, green and blue components of an optical
image, and the fourth (an X-ray image) is displayed as overlaid contour plots. Figure (c)
shows another medical dataset, this time acquired using a Magnetic Resonance Imaging
(MRI) scanner. Computer graphics allow us to visualise this three-dimensional dataset as
three slices through the 3-D volume. Finally, figure below (d) shows the use of colour to
visualise altitude in a map of the United States.

(a) (b)

8
Chapter One: Introduction to Computer Graphics

(c) (d)

Figure - Computer Graphics used for Visualisation of Complex Datasets


Virtual Reality and Augmented Reality: Virtual Reality (VR) allows users to be immersed
in a computer generated world, and to interact with it as if they were interacting with the real
world. Typically, the user will wear special hardware such as the VR-headset shown in Figure
below (a). This allows the computer to completely control the visual information received by
the user, so if realistic computer-generated images such as that shown in Figure below (b) are
displayed in the headset in stereo (i.e. different images for the left and right eyes) the user will
have a sense of physical immersion in the virtual world. In addition, other specialised
hardware such as VR-gloves can be used to interact with the ‘objects’ in the virtual world.
An alternative way of experiencing virtual reality is by using a CAVE (which stands for Cave
Automatic Virtual Environment). An example of this is shown in Figure below (c). Here, the
user stands inside a cubicle which has images projected onto the walls and ceiling. Often there
will also be a means of ‘moving’ in the virtual world such as pressure pads. Augmented
Reality (AR) combines a computer-generated virtual world with the real world. In AR,
computer-generated images are overlaid onto a user’s view of the real world.
For example, Figure below (d) shows an AR system used for surgery, in which computer-
generated images of hidden features such as blood vessels and tumours are overlaid on the
surgeon’s view of the patient through a surgical microscope.

9
Chapter One: Introduction to Computer Graphics

(a) (b)

(c) (d)

Figure - Computer Graphics used for Virtual Reality and Augmented Reality

Education and Training: Computer graphics can be very beneficial in education and
training. For example, Figure below (a) shows a screenshot from some educational software
that teaches students about human anatomy. Graphics are used to help students visualise the
appearance and location of different organs inside the body.
Another common application of computer graphics is in training. In many jobs it is difficult
for workers to get direct experience of the environment that they are expected to work in. This
may be because the environment is inaccessible (e.g. space), dangerous (e.g. bomb disposal),
expensive (e.g. flying aircraft) or high-risk (e.g. surgery). Computer graphics, combined with
specialised hardware, can be used to simulate the working environment, so that workers can
gain the skills required for their work. For example, Figure below (b) shows a picture of a
truck-driving simulator used by the German army to train their drivers in emergency
situations; Figure below (c) shows a helicopter simulator; and Figure below (d) shows a
screenshot from a simulator for laser eye surgery.

10
Chapter One: Introduction to Computer Graphics

(a) (b)

(c) (d)
Figure - Computer Graphics used for Education and Training

Graphical User Interfaces: Another possibility that has been opened up by the
improvements in computer graphics technology is in the area of user interfaces. Figure below
shows the difference in visual appeal between an old text-based user interface and a modern
windows-based user interface. And the difference is not just in visual appeal: modern user
interfaces have made multitasking (doing several things at once) much easier and applications
such as word-processors have become much more powerful.

(a) (b)

Figure - Text-Based and Graphical User Interfaces

11
Chapter One: Introduction to Computer Graphics

Entertainment: The applications of computer graphics in entertainment fall into three


categories: computer art, special effects and animations, and games. A number of artists have
taken advantage of the possibilities offered by computer graphics in producing works of art.
For example, Error! Reference source not found.below (a) shows a frame from an animated
artwork by William Latham.
Computer-generated images (CGI) have been widely used in the entertainment industry for
producing special effects for films, and also for producing completely computer-generated
films. Error! Reference source not found.below (b) shows a frame from the film Final
Fantasy: the Spirits Within, which featured 100% computer-generated images. For
applications such as this, highly realistic images can be produced off-line, i.e. we do not need
to generate the images in real-time, they need only be generated once, frame-by-frame, and
then combined into the desired animated sequence.
For computer games, images must be generated in real-time in response to user actions.
Therefore the graphics in games can be less realistic, since the emphasis is on speed of
generation rather than realism. Error! Reference source not found.below (c) and (d) show
screenshots from the popular computer game Doom.

(a) (b)

(c) (d)

Figure - Computer Graphics used in the Entertainment Industry

12
Chapter One: Introduction to Computer Graphics

Graphics Display Devices


Any computer-generated image must be displayed in some form. The most common graphics
display device is the video monitor, and the most common technology for video monitors is
the Cathode Ray Tube (CRT). Now we will examine the technology behind CRT displays,
and how they can be used to display images.

CRT Displays
CRT display devices are very common in everyday life as well as in computer graphics: most
television sets use CRT technology. Figure illustrates the basic operation of a CRT display.
Beams of electrons are generated by electron guns and fired at a screen consisting of
thousands of tiny phosphor dots. When a beam hits a phosphor dot it emits light with
brightness proportional to the strength of the beam. Therefore pictures can be drawn on the
display by directing the electron beam to particular parts of the screen. The beam is directed
to different parts of the screen by passing it through a magnetic field. The strength and
direction of this field, generated by the deflection yoke, determines the degree of deflection of
the beam on its way to the screen.
To achieve a colour display, CRT devices have three electron beams, and on the screen the
phosphor dots are in groups of three, which give off red, green and blue light respectively.
Because the three dots are very close together the light given off by the phosphor dots is
combined, and the relative brightness’s of the red, green and blue components determines the
colour of light perceived at that point in the display.

Figure- A Cathode Ray Tube Display Device

1. Random Scan Devices


CRT displays can work in one of two ways: random scan devices or raster scan devices. In a
random scan device the CRT beam is only directed to areas of the screen where parts of the
picture are to be drawn. If a part of the screen is blank the electron beam will never be
directed at it. In this case, we draw a picture as a set of primitives, for example lines or curves
(see Figure ). For this reason, random scan devices are also known as vector graphics
displays.

13
Chapter One: Introduction to Computer Graphics

Random scan displays are not so common for CRT devices, although some early video games
did use random scan technology. These days random scan is only really used by some hard-
copy plotters.

2. Raster Scan Devices


In a raster scan device the primitives to be drawn are first converted into a grid of dots (see
Figure below). The brightness’s of these dots are stored in a data structure known as a frame
buffer. The CRT electron beam then sweeps across the screen line-by-line, visiting every
location on the screen, but it is only switched on when the frame buffer indicates that a dot is
to be displayed at that location.
Raster scan CRT devices are the most common type of graphics display device in use today,
although recently LCD (Liquid Crystal Display) devices have been growing in popularity. In
this course, though, we will concentrate on the details of raster scan devices.

Figure - Random Scan and Raster Scan CRT Displays


Before we proceed, we must introduce some important terminology used when discussing
raster scan devices (see Figure below). Whilst the frame buffer stores the image data ready for
display, the actual display itself is known as the raster. The raster is a grid of phosphor dots
on the display screen. Each of these dots is known as a picture cell, or pixel for short. Each
row of pixels in the raster is known as a scan-line. The number of pixels in a scan-line is
known as the x-resolution of the raster, and the number of scan-lines is known as the y-
resolution. Finally, the ratio of the y-resolution to the x-resolution (or sometimes the other
way around) is known as the aspect ratio of the display.

14
Chapter One: Introduction to Computer Graphics

Figure - Raster Scan Terminology


We discussed that for colour CRT displays there are three electron beams: one for red light,
one for green light and one for blue light. To ensure that these three beams precisely hit the
appropriate phosphor dots on the display, after the beams have been deflected by the
deflection yoke they pass through a mask containing many tiny holes – one hole for each
pixel in the raster. This mask is known as the shadow mask. Because the three electron beams
originated from slightly different locations (from three separate electron guns), if they all pass
through the same hole in the shadow mask they will impact the screen at slightly different
locations: the locations of the red, green and blue phosphor dots.

Figure - The Shadow Mask in a Raster Scan CRT Display


The phosphor dots on a CRT display device only emit light for a very brief period of time
after the electron beam has moved on (the length of time that the phosphor emits light is
known as its persistence). Therefore to give the impression of a permanent image on the
screen the raster must be continually updated. Raster scan systems perform this continual

15
Chapter One: Introduction to Computer Graphics

update by ‘sweeping’ the electron beams across the raster scan-line by scan-line, starting from
the top and working towards the bottom. When the last scan-line is completed we start again
from the top.
The number of times that the entire raster is refreshed (i.e. drawn) each second is known as
the refresh rate of the device. For the display to appear persistent and not to flicker the
display must update often enough so that we cannot perceive a gap between frames. In other
words, we must refresh the raster when the persistence of the phosphor dots is beginning to
wear off. In practise, if the refresh rate is more than 24 frames per second (f/s) the display will
appear reasonably smooth and persistent.
Modern graphics displays have high refresh rates, typically in the region of 60 f/s. However,
early graphics systems tended to have refresh rates of about 30 f/s. Consequently, some
flicker was noticeable. To overcome this, a technique known as interlaced scanning was
employed. Using interlaced scanning alternate scan-lines are updated in each raster refresh.
For example, in the first refresh only odd numbered scan-lines may be refreshed, then on the
next refresh only even-numbered scan-lines, and so on (see Figurebelow). Because this
technique effectively doubles the screen refresh rate, it has the effect of reducing flicker for
displays with low refresh rates. Interlaced scanning was common in the early days of
computer graphics, but these days displays have better refresh rates so it is not so common.

The following are the specifications of some common video formats that have been (and still
are) used in computer graphics:
 VGA: resolution 640x480, 60 f/s refresh rate, non-interlaced scanning.
 PAL: resolution 625x480, 25 f/s refresh rate, interlaced scanning
 NTSC: resolution 525x480, 30 f/s refresh rate, interlaced scanning

Figure- Interlaced Scanning for Raster Scan Displays

i. Frame Buffers
Frame buffers are used by raster scan display devices to store the pixel values of the image
that will be displayed on the raster. It is a 2-D array of data values, with each data value
corresponding to a pixel in the image. The number of bits used to store the value for each
pixel is known as the bit-planes or depth of the frame buffer. For example, a 640x480x8
frame buffer has a resolution of 640x480 and a depth of 8 bits; a 1280x1024x24 frame buffer

16
Chapter One: Introduction to Computer Graphics

has a resolution of 1280x1024 and a depth of 24 bits. For colour displays we need to store a
value for each component of the colour (red, green and blue), so the bit-planes will typically
be a multiple of 3 (e.g. 8 bit-planes each for red, green and blue makes a total of 24 bit-
planes).

ii. Architecture of Raster Graphics Systems


Now we are in a position to examine the basic architecture of raster graphics systems, i.e.
what components are required, and how do they interact? Most (non-graphics) processing will
occur in the CPU of the computer, which uses the system bus to communicate with the system
memory and peripheral devices. When graphics routines are to be executed, instead of being
executed by the CPU they are passed straight to the display processor, which contains
dedicated hardware for drawing graphics primitives. The display processor writes the image
data into the frame buffer, which is a reserved portion of the display processor memory.
Finally the video controller reads the data in the frame buffer and uses it to control the
electron beams in the CRT display.
The display processor is also known by a variety of other names: graphics controller, display
coprocessor, graphics accelerator and video card are all terms used to refer to the display
processor.

Since the display processor contains dedicated hardware for executing graphics routines it
must be dedicated to a particular set of routines. In other words, display processors will only
be able to handle the graphics processing if the routines used are from a particular graphics
package. This is known as hardware rendering. Most commercial video cards will support
hardware rendering for the OpenGL graphics package, and many PC video cards will also
support hardware rendering for DirectX. Hardware rendering is much faster than the
alternative, software rendering, in which graphics routines are compiled and executed by the
CPU just like any other code. For the raster graphics architecture to support software
rendering the block-diagram shown in Figurebelow would need to be modified so that the
frame buffer was connected directly to the system bus in order that it could be updated by the
CPU.

17
Chapter One: Introduction to Computer Graphics

Figure- The Architecture of a Raster Graphics System with a Display Processor

3-D Display Devices


In recent years the popularity of 3-D graphics display devices has been growing, although
currently they are still quite expensive compared with traditional 2-D displays. The aim of 3-
D display devices is to provide a stereo pair of images, one to each eye of the viewer, so that
the viewer can perceive the depth of objects in the scene as well as their position. The process
of generating such 3-D displays is known as stereoscopy.

3-D displays can be divided into two types: head-mounted displays (HMDs) and head-tracked
displays (HTDs). HMDs are displays that are mounted on the head of the viewer. For
example, Figure below shows a HMD – the device fits on the head of the user and displays
separate images to the left and right eyes, producing a sense of stereo immersion. Such
devices are common in virtual reality applications. Normally a tracking device will be used to
track the location of the display device so that the images presented to the user can be updated
accordingly – giving the impression that the viewer is able to ‘move’ through the virtual
world.

18
Chapter One: Introduction to Computer Graphics

Figure - A Virtual Reality Headset

Whereas with a HMD the display moves with the viewer’s head, with a HTD the display
remains stationary, but the head of the viewer is tracked so that the images presented in the
display can be updated. The difficulty with HTDs is how to ensure that the left and right eyes
of the viewer receive separate stereo images to give a 3-D depth effect. A number of
technologies exist to achieve this aim. For example, the display can use polarised light filters
to give off alternate vertically and horizontally polarised images; the viewer then wears
special glasses with polarised filters to ensure that, for example, the left eye receives the
vertically polarised images and the right eye receives the horizontally polarised images. An
alternative technique is to use colour filters: the display draws a left-eye image in, for
example, blue, and a right eye image in green; then the viewer wears glasses with colour
filters to achieve the stereo effect. Other technologies also exist.

Graphics Input/Output Devices


Data glove: A data glove is an interactive device, resembling a glove worn on the hand,
which facilitates tactile sensing and fine-motion control in robotics and virtual reality.

 Tactile sensing involves simulation of the sense of human touch and includes the
ability to perceive pressure, linear force, torque, temperature, and surface texture.

 Fine-motion control involves the use of sensors to detect the movements of the user's
hand and fingers, and the translation of these motions into signals that can be used by
a virtual hand (for example, in gaming ) or a robotic hand (for example, in remote-
control surgery).

19
Chapter One: Introduction to Computer Graphics

Figure – Input devices

Graphics Software
To generate graphical images like those we have seen above, we need some type of graphics
software. We can divide graphics software into two categories:
 Special-purpose graphics packages
 General-purpose graphics packages
Special-purpose packages are designed for a specific purpose. For example a drawing package
such as the Paint accessory in Microsoft Windows is an example of a special-purpose
graphics package: it is designed to allow users to draw simple pictures consisting of lines,
curves and other basic components. Another example is CAD packages such as AutoCAD:
these are designed to allow users to build and visualise 3-D models. Special-purpose graphics
packages tend to be used mostly by end-users, not programmers or computer professionals. In
other words, you do not need to know about computer graphics theory to use them. Other
examples of special-purpose packages are the drawing applications Adobe Photoshop, Xara
and GIMP; the 3-D modelling applications 3-D Studio Max and Design Works; and the
visualisation software Fusion Charts and Microsoft Excel.
General-purpose packages are a pre-defined library of routines for drawing graphics
primitives. They are used by computer programmers to add graphical capability to their
programs. They provide a lot more flexibility than special-purpose packages but they require
technical knowledge of computer graphics and programming and so are not suitable for end-
users. Examples of general-purpose graphics packages are the standard low-level graphics
library OpenGL, the Microsoft equivalent DirectX and the higher-level library OpenInventor.
We can also think of scene description languages as a type of general-purpose graphics
package. Scene description languages are languages that can be used to define 3-D models of
scenes. Special viewing software is required to view and often interact with the scene. The
most common example of a scene description language is VRML, the Virtual Reality
Modelling Language.

20
Chapter One: Introduction to Computer Graphics

Introduction to OpenGL
Now we will introduce the OpenGL graphics package. This part of the course is aimed to give
you practical experience to reinforce the theory behind computer graphics. Code examples
will be given in C++, and you are expected to experiment with the OpenGL routines that are
introduced throughout the course.

In this course we will be using OpenGL together with the GL Utilities Toolkit (glut). You
should make sure that you have access to a C++ development environment that supports these
two libraries. Note that Turbo C++ does not support either of them. Two possibilities are:

 The free Dev-C++ environment (www.bloodshed.net) has OpenGL built-in and glut
can be easily added on as a separate package.

 Microsoft Visual C++ also has OpenGL built-in but not glut. The glut library is
available as a free download from http://www.xmission.com/~nate/glut.html.
Installation is fairly straightforward.

The examples and exercise solutions given in this course were coded with Dev-C++, but the
same source code should compile with Visual C++. Also, if you use Dev-C++, it comes with
a very useful OpenGL help file that you can use as a reference for different OpenGL routines
(it will be found in the Docs/OpenGL folder inside the Dev-C++ installation folder).

OpenGL is based on the GL graphics package developed by the graphics hardware


manufacturer Silicon Graphics. GL was a popular package but it was specific to Silicon
Graphics systems, i.e. code written using GL would only run on Silicon Graphics hardware.
In an attempt to overcome this limitation, OpenGL was developed in the early 1990’s as a free
platform-independent version of GL. The package was developed, and is still maintained, by a
consortium of graphics companies.

Although OpenGL is the core library that contains the majority of the functionality, there are
a number of associated libraries that are also useful. The following is a summary of the most
important of the OpenGL family of graphics libraries:

 OpenGL: the core library, it is platform (i.e. hardware system) independent, but not
windows-system independent (i.e. the code for running on Microsoft Windows will be
different to the code for running on the UNIX environments X-Windows or Gnome).

21
Chapter One: Introduction to Computer Graphics

 glut: The GL Utilities Toolkit, it contains some extra routines for drawing 3-D objects
and other primitives. Using glut with OpenGL enables us to write windows-system
independent code.
 glu: The OpenGL Utilities, it contains some extra k2routines for projections and
rendering complex 3-D objects.
 glui: Contains some extra routines for creating user-interfaces.

Every routine provided by OpenGL or one of the associated libraries listed above follows the
same basic rule of syntax:

 The prefix of the function name is either gl, glu, or glut, depending on which of these
three libraries the routine is from.
 The main part of the function name indicates the purpose of the function.
 The suffix of the function name indicates the number and type of arguments expected
by the function. For example, the suffix 3f indicates that 3 floating point arguments are
expected.
For example, the function glVertex2i is an OpenGL routine that takes 2 integer arguments and
defines a vertex.

Some function arguments can be supplied as predefined symbolic constants. These are
basically identifiers that have been defined using the C++ #define statement. These symbolic
constants are always in capital letters, and have the same prefix convention as function names.
For example, GL_RGB, GL_POLYGON and GLUT_SINGLE are all symbolic constants used
by OpenGL and its associated libraries.

Finally, OpenGL has a number of built-in data types to help make it into a platform-
independent package. For example, the C++ int data type may be stored as a 16-bit number on
some platforms but as a 32-bit number on others. Therefore if we use these standard C++ data
types with OpenGL routines the resultant code will not be platform-independent. OpenGL
provides its own data types to overcome this limitation. Mostly, they have the same names as
C++ data types but with the prefix GL attached. For example, GLshort, GLint, GLfloat and
GLdouble are all built-in OpenGL data types. Although you will find that your OpenGL code
will still work on your computer if you do not use these data types, it will not be as portable to
other platforms so it is recommended that you do use them.

22

You might also like