Module - 1 - CG Notes
Module - 1 - CG Notes
● The primary components of an electron gun in a CRT are the heated metal cathode and a
control grid (Fig.2).
● A coil of wire called the filament is heated by current inside the cylindrical cathode
structure. This causes electrons to be "boiled off" the hot cathode surface.
● The free negatively charged electrons are then accelerated towards the phosphor coating
by a high positive voltage. The accelerating voltage can be generated with a positively
charged metal coating on the in- side of the CRT envelope near the phosphor screen, or an
accelerating anode can be used.
● As the electrons would repel each other, and the beam would spread out as it approaches
the screen, a focusing system in a CRT is needed to converge the electron beam into a
small spot as it strikes the phosphor. Focusing is accomplished with either electric or
magnetic fields.
● In electrostatic focusing system, the electron beam passes through a positively charged
metal cylinder that forms an electrostatic lens, as shown in Fig. 3. The action of the
electrostatic lens focuses the electron beam at the center of the screen, in exactly the same
way that an optical lens focuses a beam of light at a particular focal distance. Similar lens
focusing effects can be accomplished with a magnetic field set up by a coil mounted
around the outside of the CRT envelope.
● The electron beam is swept across the screen one row at a time from top to bottom. Each
row is referred as a scanline. As it moves across each row, the beam intensity is turned on
and off to create a pattern of illuminated spots.
● The refreshing rate, called the frame rate, is normally 60 to 80 frames per second, or
described as 60 Hz to 80 Hz.
● Picture definition is stored in a memory area called the refresh buffer or frame buffer.
Each complete scanning of a screen is normally called a frame. This memory area holds
the set of color values(intensity values) for the screen points. Each screen point is called a
pixel (picture element).
● These stored color values are then retrieved from the refresh buffer and used to control the
intensity of the electron beam as it moves from spot to spot across the screen. In this way,
the picture is “painted” on the screen one scan line at a time, as demonstrated in Figure
above.
● At the end of each scan line, the electron beam returns to the left side of the screen to
begin displaying the next scan line. The return to the left of the screen, after refreshing
each scan line, is called the horizontal retrace of the electron beam.
● At the end of each frame(once per each refresh cycle), the electron beam returns to the
upper-left corner of the screen (called as vertical retrace) to begin the next frame.
● On black and white systems, the frame buffer storing the values of the pixels is called a
bitmap. Each entry in the bitmap is a 1-bit data which determine the on (1) and off (0) of
the intensity of the pixel.
● On color systems, the frame buffer storing the values of the pixels is called a pixmap
(Though nowadays many graphics libraries name it as bitmap too). Each entry in the
pixmap occupies a number of bits to represent the color of the pixel.
● On some raster-scan systems, each frame is displayed in two passes using an interlaced
refresh procedure. In the first pass, the beam sweeps across every other scan line from
top to bottom. After the vertical retrace, the beam then sweeps out the remaining scan
lines(as shown in below figure).
● Interlacing of the scan lines in this way allows us to see the entire screen displayed in half
the time that it would have taken to sweep across all the lines at once from top to bottom.
This technique is primarily used with slower refresh rates.
● The three electron beams are deflected and focused as a group onto the shadow mask,
which contains a series of holes aligned with the phosphor-dot patterns. When the three
beams pass through a hole 'in the shadow mask, they activate a dot triangle, which appears
as a small color spot on the screen.
● The phosphor dots in the triangles are arranged so that each electron beam can activate
only its corresponding color dot when it passes through the shadow mask.
● We obtain color variations in a shadow-mask CRT by varying the intensity levels of the
three electron beams. By turning off the red and green guns, we get only the color coming
from the blue phosphor.
● Other combinations of beam intensities produce a small light spot for each pixel position,
since our eyes tend to merge the three colors into one composite. The color we see
depends on the amount of excitation of the red, green, and blue phosphors.
● A white (or gray) area is the result of activating all three dots with equal intensity. Yellow
is produced with the green and red dots only, magenta is produced with the blue and red
dots, and cyan shows up when blue and green are activated equally.
Flat-Panel Displays:
● The term flat panel display refers to a class of video device that have reduced volume ,
weight and power requirement 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.
● Current uses for flat-panel displays include small TV monitors, calculators, pocket video
games, laptop computers, armrest viewing of movies on airlines, as advertisement boards
in elevators, and as graphics displays in applications requiring rugged, portable monitors.
● We can separate flat-panel displays into two categories:
1. Emissive displays
2. Non Emissive displays.
● The emissive displays (or emitters) are devices that convert electrical energy into light.
Plasma panels, thin-film electroluminescent displays, and light-emitting diodes are
examples of emissive displays.
● Nonemmissive displays (or nonemitters) use optical effects to convert sunlight or light
from some other source into graphics patterns. The most important example of a
nonemissive flat-panel display is a liquid-crystal device.
Plasma Panel display:
● Plasma panels, also called gas-discharge displays, are constructed by filling the region
between two glass plates with a mixture of gases that usually includes neon. A series of
vertical conducting ribbons is placed on one glass panel, and a set of horizontal
conducting ribbons is built into the other glass panel as in the below figure.
● Firing voltages applied to an intersecting pair of horizontal and vertical conductors cause
the gas at the intersection of the two conductors to break down into a glowing plasma of
electrons and ions.
Thin-film electroluminescent display:
● Thin-film electroluminescent displays are similar in construction to plasma panels. The
difference is that the region between the glass plates is filled with a phosphor, such as zinc
sulfide doped with manganese, instead of a gas as shown in the below figure.
● When a sufficiently high voltage is applied to a pair of crossing electrodes, the phosphor
becomes a conductor in the area of the intersection of the two electrodes. Electrical energy
is absorbed by the manganese atoms, which then release the energy as a spot of light
similar to the glowing plasma effect in a plasma panel.
Fig 2: Architecture of a raster system with a fixed portion of the system memory reserved for
the frame buffer.
● Since the screen must be refreshed at a rate of at least 60 frames per second, the simple
procedure illustrated in Figure 3 may not be accommodated by typical RAM chips if the
cycle time is too slow. To speed up pixel processing, video controllers can retrieve multiple
pixel values from the refresh buffer on each pass. The multiple pixel intensities are then
stored in a separate register and used to control the CRT beam intensity for a group of
adjacent pixels. When that group of pixels has been processed, the next block of pixel values
is retrieved from the frame buffer.
Raster Scan Display Processor:
----------o---------------o---------------o---------------o---------------o---------------o---------------o----------
Introduction to OpenGL
Init() Function:
● Using RGB color values, we set the background color for the display window to be white,
with the OpenGL function:
glClearColor (1.0, 1.0, 1.0, 0.0);
● The first three arguments in this function set the red, green, and blue component colors to the
value 1.0, giving us a white background color for the display window. If, instead of 1.0, we
set each of the component colors to 0.0, we would get a black background. And if all three of
these components were set to the same intermediate value between 0.0 and 1.0, we would get
some shade of gray. The fourth parameter in the glClearColor function is called the alpha
value for the specified color. glClearColor command assigns a color to the display window, it
does not put the display window on the screen.
● Also in the program we need to tell OpenGL how we want to “project” our picture onto the
display window. We can set the projection type (mode) and other viewing parameters that we
need with the following two functions:
glMatrixMode (GL_PROJECTION);
gluOrtho2D (0.0, 200.0, 0.0, 150.0);
● The above statements specify that an orthogonal projection is to be used to map the contents
of a 2D rectangular area of world coordinates to the screen, and that the x-coordinate values
within this rectangle range from 0.0 to 200.0 with y-coordinate values ranging from 0.0 to
150.0. Whatever objects we define within this world-coordinate rectangle will be shown
within the display window. Anything outside this coordinate range will not be displayed.
OpenGL Point Functions: To specify the geometry of a point, we simply give a coordinate position
in the world reference frame.
For point plotting, the argument of the glBegin function is the symbolic constant GL POINTS. Thus,
the form for an OpenGL specification of a point position is
glBegin (GL_POINTS);
glVertex* ( );
glEnd ( );
In the below example, three equally spaced points are plotted along a
two dimensional, straight-line path as shown in the figure.
Coordinates are given as integer pairs:
glBegin (GL_POINTS) //Primitive to draw is a point
glVertex2i (50, 100); //position of the point
glVertex2i (75, 150); //position of the point
glVertex2i (100, 200); //position of the point
glEnd ( );
The above code would puts three points on screen at world coordinates (50,100) (75,150) and
(100,200).
OpenGL Line Functions:
1) GL_LINES: A set of straight-line segments between each successive pair of endpoints in a
list is generated using the primitive line constant GL_LINES.
For example, if we have five 2D coordinate positions, then
the following code could generate the display shown below:
glBegin (GL_LINES);
glVertex2iv (10,10);
glVertex2iv (20,10);
glVertex2iv (20,20);
glVertex2iv (10,20);
glEnd ( );
Here we obtain one line segment between the first and
second coordinate positions and another line segment
between the third and fourth positions. In case, the number of specified endpoints is odd, the
last coordinate position is ignored.
GL_TRIANGLE_STRIP: In the triangle strip, after the first triangle, each additional vertex is
combined with the previous two vertices to define a new
triangle.
glBegin(GL_TRIANGLES);
glVertex2i(10,10);
glVertex2i(10,20);
glVertex2i(20,10);
glVertex2i(20,20);
glVertex2i(30,10);
glVertex2i(30,20);
glVertex2i(40,10);
glVertex2i(40,20);
glEnd();
GL_TRIANGLE_FAN: A triangle fan is based on one fixed point. The next two points determine
the first triangle, and subsequent triangles are formed from one new point, the previous point, and the
first (fixed) point.
1
xk+1 = xk + m
● The DDA algorithm is a faster method for calculating pixel positions. However, The
accumulation of round-off error in successive additions of the floating-point increment can
cause the calculated pixel positions to drift away from the true line path for long line
segments.
● The rounding operations and floating-point arithmetic in this procedure are still
time-consuming. This disadvantage can be overcome by reducing the calculations to only
integer values.
The above equation can result in a real number as the m = △y/△x can lead
to a floating point number.
We can obtain a decision parameter pk with integer calculations by
multiplying △x in the above equation.
● The sign of pk is the same as the sign of (dlower − dupper ) hence, If the pixel
at y k is closer to to the line path than the pixel at y k+1 (that is dlower < dupper )
then decision parameter pk is negative. In this case we plot the lower pixel;
otherwise, we plot the upper pixel.
● Coordinate changes along the line occur in unit steps in either the x or y
direction. Therefore, we can obtain the values of successive decision
parameters using incremental integer calculations.
● Hence at step k + 1 he decision parameter can be calculated as,
The above tests are performed for the mid positions between pixels near the circle path at each
sampling step.
Consider the below figure which shows the midpoint between the two candidate pixels at sampling
position xk + 1.
● Assume that we have just plotted the pixel at as shown in the above picture. Next we
● To decide on this we make use of the mid-point between these pixels, which is
and apply the circle function on the midpoint.
● If , this midpoint is inside the circle and hence the pixel at is closer to
the circle boundary and we select it as next pixel to draw.
● Otherwise, the mid-point position is outside or on the circle boundary, and we select the pixel
● Subtracting we get,
● The initial decision parameter is obtained by evaluating the circle function at the start
position
● Using the above matrices, the 2D translation equation in the matrix form can be given as,
Rotation:
● A rotation transformation of an object can be obtained by specifying a rotation axis and a
rotation angle. All points of the object are then transformed to new positions by rotating
the points through the specified angle about the rotation axis.
● A two-dimensional rotation of an object is obtained by repositioning the object along a
circular path in the xy plane. In this case, we are rotating the object about a rotation axis
that is perpendicular to the xy plane (parallel to the coordinate z axis).
● Consider a point position P in the co-ordinate system where P=(x,y) as shown in the below
figure.
● In this figure, r is the constant distance of the point from the origin; angle ϕ is the original
angular position of the point from the horizontal (x-axis). The (x, y) coordinates can be
represented as,
● We can express the above equations as a single matrix equation by using the following
column vectors:
● Using the above matrices, the 2D translation equation in the matrix form can be given as,
Scaling:
● Scaling is applied on an object to alter its size. A simple two dimensional scaling
operation is performed by multiplying object positions (x, y) by scaling factors and to
produce the transformed coordinates (x1, y1):
● Scaling factor Sx scales an object in the x direction, while Sy
scales in the y direction.