CG Chapter 1-5

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 79

Computer Graphics

Chapter One
Outline
Introduction of CG
Application of CG
Types of CG
Graphics Hardware and software
Architecture of raster system
Graphics software
Introduction
• Computer graphics is one of the most effective and commonly used way to
information in form of graphics object such as pictures, chart ,graphs and
diagram instead of simple text.
• Computer graphics is an art of drawing pictures on computer screens with the
help of programming.
• It is a process of generating , manipulating ,storing and displaying graphics
objects.so we can say that computer graphics makes it possible to express data
in pictorial form. Where graphics objects are presented as a collection of
discrete picture elements.
• Pixel is the smallest screen elements so we generate graph by managing pixel.
• The control is achieved by setting the intensity and colour of pixel which
compose screen.
• It is a tool for storing, manipulating and correlating data.
Cont..
• The process of determining the appropriate pixel for representing picture is
known as rasterization but the process of representing continuous picture is
called as scan conversion.
• There is close relationship between input devices and display devices.
• Graphics device =input devices + display devices
• Display devices also known as output devices
• The most commonly used output devices in a graphics system is a video
monitor.
Advantage
1. High quality graphics display
2. it provide tools for producing picture,
3. produce animation.
1.2 Applications of Computer Graphics

1.User interfaces: It is now a well-established fact that graphical interfaces provide an


attractive and easy interaction between users and computers.
The built-in graphics provided with user interfaces use visual control items
such as buttons, menus, icons, scroll bar etc.,
2. Plotting of graphics and chart: In industry, business, government, and educational
organizations, computer graphics is most commonly used to create 2D and 3D graphs of
mathematical, physical and economic functions in form of histograms, bars and pie-charts.
These graphs and charts are very useful for decision making.
3.Computer-aided drafting and design: the computer–aided drafting uses graphics to
design components and systems electrical, mechanical, electromechanical and electronic
devices such as automobile bodies, structures of building, airplane, and ships, very large scale
integrated chips, optical systems and computer networks.
1.2 Applications of Computer Graphics

4.Entertainment: the applications of computer graphics in entertainment fall into three


categories: computer art, special effects and animations, and games.
5.Simulation and Animation: use of graphics in simulation makes mathematic
models and mechanical systems more realistic and easy to study.
 Animation is a technique to create an illusion of motion through sequences of
images.
6.Process Control: By the use of computer now it is possible to control various
processes in the industry from a remote control room. In such cases, process
systems and processing parameters are shown on the computer with graphic
symbols and identifications.
This makes it easy for operator to monitor and control various processing
parameters at a time
1.2 Applications of Computer Graphics
7. Cartography: Computer graphics is also used to represent
geographic maps, weather maps, oceanographic charts, counter maps,
population density maps and so on.
8. Education and training: computer graphics can be used to generate
models of physical aids.
9. Image processing: Image processing, on the other hands, applies
techniques to modify or interpret existing picture such as photographs
and scanned image.

10. VR and AR is also application area of computer graphics.


11. For Education
1.3 Type of graphics
Type of computer graphics based on way of interaction
1. Interactive(ICG)
• Interactive is active which means two way communication
• User some control over it
• User can make change by giving command by using input device.
• Example playing game.
1. Non interactive(NICG)
• non-interactive is passive which means you can not control like screen saver.
• User does not have any control
• It work based on set of instruction built on it before
• Example computer screen saver
Type of computer graphics based on objects
• Dimension indicates any and all sides of an object, such as height,
length and width, and allows us to measure them.
1. 2D
• 2D only length and height,
• it is flat where x,y coordinate only
2. 3D
• 3D is 2D+width
• life like it take x,y,z coordinate
example 2d Rectangle, triangle
Example 3D Cylinder, sphere, cube.
Type of computer graphics based on the way of drawing
1. Raster build up the pictures by scanning beams of electrons back and forth from top to
bottom and left to right like a kind of instant electronic paintbrush.
• We can draw picture by combining pixel together.
• Pixel picture element is a physical point in a picture.
• simply the smallest addressable element of a picture represented on a screen.
• Bitmap : In computer graphics, a bitmap is a mapping from some domain (for example, a
range of integers) to bits, that is, values which are zero or one.
• So Raster images use bit maps to store information.
2. Vector:-Making use of sequential commands or mathematical statements or programs
which place lines or shapes in a 2-D or 3-D environment is referred to as Vector Graphics.
Type of computer graphics based on role of picture
1. Symbolic They represent a deeper meaning behind the image,
Cares three primary forms ideological, comparative and isomorphic
2.Realist uses the camera and photograph to gather information. It need
technical ability
All computer art is digital, but there are two very different ways of
drawing digital images on a computer screen, known as raster and vector
graphics.
Simple computer graphic programs like Microsoft Paint and Paint Shop
Pro are based on raster graphics, while more sophisticated programs such
as CorelDraw, AutoCAD, and Adobe Illustrator use vector graphics.
Cont…
• Raster graphics: is a way of drawing which use to build up the
pictures by scanning beams of electrons (tiny charged particles inside
atoms, also called cathode rays) back and forth from top to bottom
and left to right like a kind of instant electronic paint brush.
• Raster graphics are simple to use and it's easy to see how programs
that use them do their stuff. If you draw a pixel picture on your
computer screen and you click a button in your graphics package to
"mirror" the image (flip it from left to right or right to left), all the
computer does is reverse the order of the pixels by reversing the
sequence of zeros and ones that represent them.
Cont.…
If you scale an image so it's twice the size, the computer copies each
pixel twice over (so the numbers 10110 become 1100111100) but the
image becomes noticeably more grainy and pixelated in the process.
That's one of the main drawbacks of using raster graphics: they don't
scale up to different sizes very well.
 Another drawback is the amount of memory they require.
Most images you see on your computer screen are raster graphics
Draw back of raster graphics
1. Scaling problem
2. It need high amount of memory
3. Low resolution
Cont…
• Pictures found on the Web and photos you import from your digital
camera are raster graphics.
• Instead of building up a picture out of pixels, you draw it a bit like a
child would by using simple straight and curved lines called vectors
or basic shapes(circles, curves, triangles, and so on) known as
primitives.
• Making use of sequential commands or mathematical statements or
programs which place lines or shapes in a 2-D or 3-D environment is
referred to as Vector Graphics.
• Vector graphics are best for printing since it is composed of a series of
mathematical curves.
4 Graphics hardware and software
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).
CRT display devices are very common in everyday life as well as in computer graphics most
television sets use CRT technology.
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.
Cont…
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.
The operation of CRT can be summarized into the following steps:
1. The electron gun emits a beam of electrons (cathode rays).
2. The electron beam passes through focusing and deflection systems that direct it towards
specified positions on the phosphor-coated screen.
3. When the beam hits the screen, the phosphor emits a small spot of light at each position
contacted by the electron beam.
4. It redraws the picture by directing the electron beam back over the same screen points
quickly.
Cont….
cont
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 color of light perceived at that point in the display.
Cont..
There are two ways (Random scan and Raster scan) by which we can display an object on
the screen.
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, we draw a
picture as a set of primitives.
Random scan devices are also known as vector graphics displays.
a Raster scan device the primitives to be drawn are first converted into a grid of dots.
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.
Cont..
Random scan Raster scan

It has high resolution It has low resolution

Less expensive More expensive

Use beam penetration technology Use shadow mask technology

Mostly for line drawing Suitable to display realistic images


Cont...
GRAPHICS HARDWARE

• Although most graphics monitors are still constructed with CRTs, other technologies are
emerging that may soon replace CRT monitors.

• The term flat-panel display refers to a class of video devices that have reduced volume,
weight, and power requirements compared to a CRT.

• A significant feature of flat-panel displays is that they are thinner than CRTs, and we can
hang them on walls or wear them on our wrists.

• We can separate flat-panel displays into two categories: emissive displays and non
emissive displays.
GRAPHICS HARDWARE

• The emissive displays are devices that convert electrical energy into light.
Plasma panels, and light-emitting diodes are examples of emissive displays.

• Non emissive displays use optical effects to convert sunlight or light from
some other source into graphics patterns. The most important example of a
non emissive flat-panel display is a liquid-crystal device( LCD).

• Liquid crystal refers to the fact that these compounds have a crystalline
arrangement of molecules, yet they flow like a liquid.
Architecture of Raster Graphics Systems
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 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.
The display processor contains dedicated hardware for executing graphics
routines it must be dedicated to a particular set of routines.
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.
Cont.…
• graphics routines are compiled and executed by the CPU just like any
other code.
• For the raster graphics architecture to support software rendering 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.
• The Architecture of a Raster Graphics System with a Display
Processor.
Color CRT Monitors
• To display coloured pictures, combination of phosphorus is
used that emits different coloured light.
• Two different techniques for producing colour displays with a
CRT.
1. Beam Penetration Method
2. Shadow Mask Method
Beam Penetration Method
• Has been an inexpensive way to produce color and used in random-scan monitors.
• Only four colors are possible, and the quality of pictures is not as good as with other methods.
• Two layers of phosphor, usually red and green, are coated onto the inside of the CRT screen.
• Color producting
• speeds, combinations of red and green light are emitted to show two additional colors, orange and
yellow.
• Colours Produced:- Only four colours are produced in beam penetration due to the speed of the singular
electron gun
• It use random method
• Merits(advantage) it is inexpensive technique to produce color in random scan monitors.
• Demerits(disadvantage) it can display only four colors, the quality of
picture produced by this technique is not good as compared to other
techniques'.
Shadow Mask Method
• Commonly used in raster-scan systems (including color TV).
• Produce a much wider range of colors than the beam-penetration using three phosphor color
dots at each pixel position.
• The phosphor dots are in very close groups of three, which give off red, green and blue light
respectively.
Colors Produced:- millions of colors are able to be produced.
Color Dependency:- Millions of colors are produced with the shadow mask method because it
depends on the intensity of the three available electron guns.
Number of Electron Guns Used:- three electron guns are used to produce the millions of
colors.

• It use raster method


3D Display Devices

In recent years the popularity of 3D graphics display devices has been growing, although
currently they are still quite expensive compared with traditional 2D displays.
CRT:-is an evacuated glass tube

LCD:- LCD requires an AC power supply instead of DC, so it is difficult to use it in circuits.
It generally works on flat panel display technology.
Light Emitting Diode (LED): LED is a device which emits when current passes through it.
It is a semiconductor device.
Direct View Storage Tube (DVST):
• Primary Gun: It is used to store the picture information.
• Flood / Secondary Gun: It is used to display a picture on the screen.
CONT…

The aim of 3D 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 3D displays is known as stereoscopy.
3D displays device can be divided into two types:
1. head-mounted displays (HMDs)
2. head-tracked displays (HTDs).
HMD:-HMDs are displays that are mounted on the head of the viewer. Such
devices are common in virtual reality applications.
HTM:-Head tracking enables an application to recognize and identify a user's
head movements.
Graphics Software
We can divide graphics software into two categories:
1. Special-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.
2. General-purpose graphics packages
General-purpose packages are a pre-defined library of routines for drawing graphics
primitives.
• 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.
1.5 OpenGL
Introduction to OpenGL
Aim-to give to practical experience to reinforce the theory behind
computer graphics.
We will be using OpenGL together with the GL Utilities Toolkit
(glut).
• Turbo C++ does not support either of them.
• Dev-C++ environment 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.
• Netbeans support OpenGL by including the OpenGL library.
Cont…

summary of the most important OpenGL family of graphics libraries:

• OpenGL: the core library, it is platform (i.e. hardware system)


independent, but not windows-system independent (code for Windows will
be different to the code for running on the UNIX).
• glut: 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 routines for projections
and rendering complex 3-D objects.
• glui: Contains some extra routines for creating user-interfaces.
Getting Started with OpenGL
• Which header files are required depends upon which library(s) are
being used.
• For example, if we are only using the core OpenGL library then
• #include <GL/gl.h>
• If we also want to use the GL Utilities library, we must add the
following line:
• #include <GL/glu.h>
• For the glui user-interface library we must add:
• #include <GL/glui.h>
• If we want to use the glut library (makes using OpenGL a lot easier)
we do not need to include the OpenGL or glu header files.
• All we need to do is include a single header file for glut:
• #include <GL/glut.h>
CHAPTER 2
GRAPHICS HARDWARE
Introduction
Graphics Primitives
• All graphics packages construct pictures from basic building blocks known as graphics primitives.
• Primitives that describe the geometry, or shape, of these building blocks are known as geometric
primitives.
• Graphics Primitive is a basic object that is essential for the creation or construction of complex
images.
• Graphics is constructed from three basic elements, as opposed to the great variety of graphics
applications.
• The most basic of these elemental structures is the pixel, short for picture element
• A pixel is a point of light. It is just one tiny dot on the raster displays.
• Line, especially straight lines, constitute the, engineering drawings and architectural plans. basic
building block of Line graphs, bar and pie charts, two and three-dimensional graphs of mathematical
functions
• A polygon is a closed area of image bounded by straight or curved lines and filled with one solid
color. Since images are two dimensional, a polygon is a closed planar figure.
OpenGL Point Drawing Primitives
The most basic type of primitive is the point.
Many graphics packages, including OpenGL, provide routines for displaying points.
To draw point, we use the pair of functions glBegin …glEnd.
GL_POINTS to specify how the vertices in between should be interpreted.
glPointSize can be used to set the size of point in pixel. Where The default point size is 1 pixel.
For example, the following code draws three 2D points with a size of 2 pixels.
glPointSize(2.0);
glBegin(GL_POINTS);
glVertex2f(100.0, 200.0);
glVertex2f(150.0, 200.0);
glVertex2f(150.0, 250.0);
glEnd();
Line Drawing Algorithms
Introduction
• Y=mx+c …………………………………………………………………..(1)
• Where m is the slope or gradient of the line, and c is the coordinate at which the line
intercepts the y-axis.
• Given two end-points (x0,y0) and (xend, yend), we can calculate values for m and c as follows.

• …………………………………………………………(2)

• ………………………………………………………………………….(3)

39
Line Drawing Algorithms

• Furthermore, for any given x-interval δx, we can calculate the


corresponding y-interval δy:
• ………………………………….......(4)
• . ……………………………………(5)
• These equations form the basis of the two line-drawing
algorithms described below: the DDA algorithm and Brenham's
algorithm.

40
DDA Line-Drawing Algorithm
 The Digital Differential Analyzer (DDA) algorithm operates by starting at one end-point of the line,
and then using Eqs. (4) and (5) to generate successive pixels until the second end-point is reached.
Therefore, first, we need to assign values for δx and δy.
 In other case, we must make sure that both δx and δy have values less than or equal to one. To ensure
this, we must first check the size of the line gradient. The conditions are:

41
DDA Line-Drawing Algorithm
2.

Once we have computed values for δx and δy, the basic DDA algorithm is:
• Start with
• Find successive pixel positions by adding on (δx, δy) and rounding to the nearest integer, i.e

42
DDA Line-Drawing Algorithm
The Digital Differential Analyser (DDA) algorithm operates by starting at one end-point of the
line, to generate successive pixels until the second end-point is reached. The algorithm for
drawing lines using DDA algorithm have the following five steps which we discus below:
Step 1: Get the input of two end points (X0, Y0) and (X1, Y1).
Step 2: Calculate the difference between the two end points.
dx = X1 - X0
dy = Y1 - Y0
Step 3: Identify the number of steps to put pixel. If dx > dy, then you need more steps in x
coordinate; otherwise in y coordinate.
if |(dx)| > |(dy)|
No_steps = |dx|;
else
No_steps = |dy|;
Cont..
Step 4: Calculate the increment in x coordinate and y coordinate.
Xinc = dx / (float) No_steps;
Yinc = dy / (float) No_steps;
Step 5: Put the pixel by successfully incrementing x and y coordinates accordingly and complete
the drawing of the line.
x = x + Xinc;
y = y + Yinc;
putpixel(Round(x), Round(y));
Note that the actual pixel value used will be calculated by rounding to the nearest integer, but we
keep the real valued location for calculating the next pixel position.
Let us consider an example of applying the DDA algorithm for drawing a straight-line segment given
the following inputs.
Cont..
Step 1: get the inputs x1=15 x0=10 y1=13 y0=10
Step 2: calculate the difference between the two end points
dx= x1-x0=15-10=5
dy= y1-y0=13-10=3
Step3: identify number of steps
dx>dy= 5>3
No_steps=5;
Step 4: calculate the increment
Xinc=dx/No_steps= 5/5=1
Yinc=dy/No_steps=3/5=0.6
Step 5: Using the values, we can now start to plot line points:
Start with (x0,y0) = (10,10) – colour this pixel
Next, (x1,y1) = (10+1,10+0.6) = (11,10.6) – so we colour pixel (11,11)
Cont….
Next, (x2,y2) = (11+1,10.6+0.6) = (12,11.2) – so we colour pixel (12,11)
Next, (x3,y3) = (12+1,11.2+0.6) = (13,11.8) – so we colour pixel (13,12)
Next, (x4,y4) = (13+1,11.8+0.6) = (14,12.4) – so we colour pixel (14,12)
Next, (x5,y5) = (14+1,12.4+0.6) = (15,13) – so we colour pixel (15,13)
We have now reached the end-point (xend, yend), so the algorithm terminates
Cont…
The DDA algorithm is simple and easy to implement, but it does involve floating
point
operations to calculate each new point.
 Floating point operations are time-consuming when compared to integer
operations.
Since line drawing is a very common operation in computer graphics, it would be
nice if we could devise a faster algorithm which uses integer operations only.
Bresenham’s Line-Drawing Algorithm

Bresenham’s line-drawing algorithm provides significant improvements in efficiency over the DDA
algorithm.
These improvements arise from the observation that for any given line, if we know the previous pixel
location, we only have a choice of 2 locations for the next pixel.
This concept is illustrated in Figure 2: given that we know (xk,yk) is a point on the line, we know the
next line point must be either pixel A or pixel B. Therefore we do not need to compute the actual
floating-point location of the ‘true’ line point; we need only make a decision between pixels A and B.
Cont…
Bresenham’s algorithm works as follows.
Plot the start-point of the line (x0,y0)
Compute the first decision variable:
Cont…
OpenGL Line Functions
• We can draw straight-lines in OpenGL using the same glBegin … glEnd
functions that we saw for point-drawing.
• This time we specify that vertices should be interpreted as line end-points
by using the symbolic constant GL_LINES. For example, the following
code
glLineWidth(3.0);
glBegin(GL_LINES);
glVertex2f(100.0, 200.0);
glVertex2f(150.0, 200.0);
glVertex2f(150.0, 250.0);
glVertex2f(200.0, 250.0);
glEnd()
• will draw two separate line segments: one from (100,200) to (150,200) and one from
(150,250) to (200,250).
Cont…
• Two other symbolic constants allow us to draw slightly different types of
straight-line primitive are: GL_LINE_STRIP and GL_LINE_LOOP.
Glint p1[] = {200,100}; Glint p2[] = {50,0}
Glint p3[] = {100,200}; Glint p4[] = {150,0};
Glint p5[] = {0,100};
glBegin(GL_LINES);
glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3);
glVertex2iv(p4);
glVertex2iv(p5);
glEnd();
LINE_STRIP
glBegin(GL_LINE_STRIP);
glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3);
glVertex2iv(p4);
glVertex2iv(p5);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3);
glVertex2iv(p4);
glVertex2iv(p5);
glEnd();
Circle-Drawing Algorithms
• Some graphics packages allow us to draw circle primitives. Before we examine
algorithms for circle-drawing we will consider the mathematical equations of a circle.
• In Cartesian coordinates we can write:
Midpoint Circle-Drawing Algorithm
• The midpoint algorithm takes advantage of the symmetry property of circles to produce a more
efficient algorithm for drawing circles.
• The algorithm works in a similar way to Bresenham’s
• line-drawing algorithm, in that it formulates a decision variable that can be computed using
integer operations only.
Fill-Area Primitives
• The most common type of primitive in 3-D computer graphics is the fill-area primitive.
• The term fill-area primitive refers to any enclosed boundary that can be filled
with a solid colour or pattern.
• Each pair of adjacent vertices is connected in sequence by edges.

• Polygons are the most common form of graphics primitive because they form
the basis of polygonal meshes, which is the most common representation for
3-D graphics objects.
Cont…
Two algorithms or methods used to fill the polygon.
1) Seed Fill Algorithm
A, Flood-fill Algorithm
 Flood-fill algorithm helps to define a region in the boundary, attached to a point in the multi-
dimensional array.
 In flood -fill algorithm, we replace all the associated pixels of the selected color with a fill
color. It fill interior of image
 It provides an easy way to fill color in graphics
B, Boundary-fill Algorithm
 It is also known as the “Edge-fill algorithm.” The boundary fill algorithm is used for area
filling.
 We can perform boundary fill where we want to create an attractive painting.
2, Scan Line Algorithm
 we can fill the polygons through horizontal lines or scan lines.
 The scan-line intersects the edges of the polygon, and the polygon is filled between pairs of the
intersection.

 Inside Outside test


1 odd-even method.
Count even == exterior
Count odd== interior
2. Non zero winding
• +1 right to left and top to bottom
• -1 left to right , bottom to top
• Some examples of polygonal meshes are

Convex and Concave Polygons


We can differentiate between convex and concave polygons:
Convex polygons have all interior angles ≤ 180
Concave polygons have at least one interior angle > 180
Character Primitives
Character primitives can be used to display text characters.
• We can identify two different types of representation for characters: bitmap and stroke (or
outline) representations, Using a bitmap representation (or font), characters are stored as a
grid of pixel values.
• It is a simple representation that allows fast rendering of the character. However, such
representations are not easily scalable.
• we cannot easily generate bold or italic versions of the character.
• Using stroke representations characters are stored using line or curve primitives. To draw the
character we must convert these primitives into pixel values on the display.
• They are much more easily scalable
• Bold and italic characters can be generated using a similar approach.
• The disadvantage of stroke fonts is that they take longer to draw than bitmap fonts.
Cont…
• We can also divide character primitives into serif and sans-serif fonts. Sans-serif fonts have no
accents on the characters, whereas serif fonts do have accents
For example, as shown below,
• Arial and Verdana fonts are examples of sans-serif fonts whereas Times-Roman and Garamond
are serif fonts:

Arial is a sans-serif font


Verdana is a sans-serif font
Times Roman is a serif font
Garamond is a serif font
OpenGL Character Primitive Routines
• OpenGL on its own does not contain any routines dedicated to drawing text characters.
However, the glut library does contain two different routines for drawing individual
characters (not strings).
• Before drawing any character, we must first set the raster position, i.e. where will the
character be drawn.
• After each character is drawn the raster position will be automatically updated ready for
drawing the next character.
• To set the raster position we use the glRasterPos2i routine.
Example glRasterPos2i(x, y : positions the raster at coordinate location (x,y).
• Next, we can display our characters. The routine we use to do this will depend on whether
we want to draw a bitmap or stroke character. For bitmap characters we can write, for
example,
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ‘a’);
Cont…
• This will draw the character ‘a’ in a monospace bitmap font with width 9 and height 15 pixels.
• There are a number of alternative symbolic constants that we can use in place of
GLUT_BITMAP_9_BY_15 to specify different types of bitmap font.
For example,
• GLUT_BITMAP_8_BY_13
• GLUT_BITMAP_9_BY_15
• We can specify proportional bitmap fonts using the following symbolic constants:
• GLUT_BITMAP_TIMES_ROMAN_10
• GLUT_BITMAP_HELVETICA_10
• Alternatively, we can use stroke fonts using the glutStrokeCharacter routine.
example,
glutStrokeCharacter(GLUT_STROKE_ROMAN, ‘a’);
• This will draw the letter ‘a’ using the Roman stroke font, which is a proportional font. We can
specify a monospace stroke font using the following symbolic constant:
• GLUT_STROKE_MONO_ROMAN
7. Aliasing(nickname/surname)
It refers to the introduction of errors into an image as a consequence of the discretisation of the
primitives when plotting on a raster graphics system.
It occur by forcing the primitives to be plotted only at these discrete locations we inevitably
introduce errors. Another name for the effect of aliasing is the “staircase effect”
7.1 Super sampling
It is also known as post filtering
It attempts to compensate for the effects of under sampling (i.e. reduced resolution) by super
sampling (increasing the resolution) before plotting.
To plot an ant aliased line, the basic idea of super sampling is as follows:
• ‘Super sample’ the image (i.e. increase its resolution).
• Plot the line in the super sampled image.
• Count the number of plotted points within each corresponding ‘real’ pixel.
• Plot the ‘real’ pixel with an intensity that is proportional to the count of super sampled pixels.
7.2 Area Sampling
• It is known as area sampling, or pre filtering.
• We determine the location of the primitive (e.g. a straight line) and then compute the area of
overlap of each pixel with the primitive.
• The plotted intensity of each pixel is proportional to this area of overlap.
7.3 Pixel Phasing
• Super sampling and area sampling were both software techniques
• they were algorithms that processed image data to produce anti aliased image data.
• it is not possible to use pixel phasing to perform antialiasing unless you are using a display
monitor that uses it.
• OpenGL Anti-Aliasing Functions
• The OpenGL antialiasing feature can be applied to points, lines or polygons. We enable the
appropriate feature using the glEnable routine. For example:
• glEnable(GL_POINT_SMOOTH)
• glEnable(GL_LINE_SMOOTH)
• glEnable(GL_POLYGON_SMOOTH)
Chapter 3
ATTRIBUTES OF GRAPHICS PRIMITIVES
Introduction
• A parameter that affects the way a primitive is to be displayed is referred to as a attribute parameter.
Some attribute parameters, such as color and size, determine the fundamental characteristics of a
primitive. Other attributes specify how the primitive is to be displayed under special conditions, such
as visibility or detectability within an interactive object-selection program.
Colour Attribute
we defined values for two colour state variables: the drawing colour and the background colour.
We can define colours in two different ways:
• RGB: the colour is defined as the combination of its red, green and blue components.
• RGBA: the colour is defined as the combination of its red, green and blue components together with
an alpha value, which indicates the degree of opacity/transparency of the colour.
• It can often be useful to combine colours of overlapping objects in the scene or of an object with the
background colour which achieve transparency effects and also for antialiasing is known as colour
blending.
• RGBA colour representation is necessary to achieve colour blending.
Direct Storage vs Colour Look-Up Tables
Recall that the frame buffer is used by raster graphics systems to store the image ready for display on
the monitor.
Therefore, for colour displays, the frame buffer must have some way of storing colour values.
Colours stored in form of RGB and RGBA values.
• There are two ways in which graphics packages store colour values in a frame buffer:
1. Direct storage:-
2. The colour values of each pixel are stored directly in the frame buffer
Each pixel in the frame buffer must have 3 (RGB) or 4 (RGBA) values stored. Where the frame buffer
can take up a lot of memory.
For example, suppose we have a screen resolution of 1024x768, and we use 8 bits for each of the
red, green and blue components of the colours stored. The total storage required will be 1024x768x24
bits = 2.4MB.
2. Look-up table:-
They try to reduce the amount of storage required by just storing an index for
each pixel in the frame buffer.
• The actual colours are stored in a separate look-up table, and the index looks up
a colour in this table.
• Therefore, using colour look-up tables we can only have a limited number of different colours in the
scene (the number of rows in the look-up table), but these colours can be chosen from a palette
containing the complete range of colours.
For example, suppose we are using 8 bits for each colour (=24 bits in all), and the look-up
table has 256 rows. In this case the total range of colours we can choose from is 2 24, but we
can only use 256 of these in any one image.

Although colour look-up tables do save storage, they slow down the rasterisation process as
an extra look-up operation is required. They were commonly used in the early days of
computer graphics when memory was expensive, but these days memory is cheaper so most
systems use direct storage.
Cont…
• OpenGL uses direct storage by default, but the programmer can choose to use a colour look-up
table if they wish.
OpenGL Colour Attributes
• we change the current drawing colour using the glColor* function and the current background
colour using the glClearColor function.
• glColor3f(1.0,0.0,0.0); // set drawing colour to red
• glColor4f(0.0,1.0,0.0,0.05); // set drawing colour to semi-
transparent green
• glClearColor(1.0,1.0,1.0,1.0); // set background colour to opaque white
• Before we do any drawing in OpenGL, we must define a frame buffer.
• If we want to do colour drawing then we must specify that we want a colour frame buffer.
• Example glutInitDisplayMode(GLUT_SINGLE,GLUT_RGB)
• In order to store alpha values in the frame buffer we must change the second argument to
GLUT_RGBA.
• To specify that we want to use a colour look-up table we set the second argument equal to
GLUT_INDEX.
Point Attributes
• Points are the simplest type of primitive so the only attributes we can modify
are the colour and size of the point.
• glPointSize(size)
Line Attributes
• Straight-line segment can be displayed with three basic attributes: color, width, and style.
The attributes of line primitives that we can modify include the following:
• Line colour, Line width and Line style (solid/dashed etc)
Line Width
The simplest and most common technique for increasing the width of a line is to plot a line of width 1
pixel, and then add extra pixels in either the horizontal or vertical directions.
Implementation of line-width options depends on the capabilities of the output device. A heavy line
could be display on a video monitor as adjacent parallel line.
•If |m| ≤ 1 plot extra pixels vertically, i.e. same x-coordinate, different y-coordinate, as in Figure
2(a).
•If |m| > 1, plot extra pixels horizontally, i.e. same y-coordinate, different x-coordinate, as in
Figure 2(b).
• Gedeo is a Highland East Cushitic language of the Afro-Asiatic family
spoken in south central Ethiopia. Alternate names for the language
include Derasa, Deresa, Darassa, Geddeo, Derasanya, Darasa. It is
spoken by the Gedeo people, who live in the highland area,
southwest of Dila and east of Lake Abaya.[1]
• The languages has SOV word order. Verbs are marked for person,
number, and gender of subject. Verbs are marked for voice: active,
causative, middle, and passive.
• The New Testament was published in the Gedeo language in 1986,
using the Ethiopian syllabary.
• About: Gedeo language
• An Entity of Type: language, from Named Graph: http://dbpedia.org
, within Data Space: dbpedia.org
• Gedeo is a Highland East Cushitic language of the Afro-Asiatic family
spoken in south central Ethiopia. Alternate names for the language
include Derasa, Deresa, Darassa, Geddeo, Derasanya, Darasa. It is spoken
by the Gedeo people, who live in the highland area, southwest of Dila
and east of Lake Abaya. The languages has SOV word order. Verbs are
marked for person, number, and gender of subject. Verbs are marked for
voice: active, causative, middle, and passive. The New Testament was
published in the Gedeo language in 1986, using the .
•Gedeo is a Highland East Cushitic language of the Afro-Asiatic
family spoken in south central Ethiopia.
•Alternate names for the language include Derasa, Deresa, Darassa,
Geddeo, Derasanya, Darasa.
•It is spoken by the Gedeo people, who live in the highland area,
southwest of Dila and east of Lake Abaya.
• The languages has SOV word order. Verbs are marked for person,
number, and gender of subject.
• Verbs are marked for voice: active, causative, middle, and passive.
•The New Testament was published in the Gedeo language in 1986,
using the . (en)

You might also like