Computer Graphics and Visualization: Module-1
Computer Graphics and Visualization: Module-1
Module-1
Computer Graphics and OpenGL
Module – 1: Computer Graphics and OpenGL
Graphics
Graphics
Computer Graphics
CG
Classification of CG
Based on Applications
Cartography:
Process control:
Medical imaging :
User interfaces
NonInterlaced
Interlaced display
refreshCRT.
Figure 2: illustrates the delta-delta shadow-mask method, commonly used in color CRT systems.
Flat-Panel Displays
Nonemissive
liquid-crystal device
Plasma panels gas-discharge displays
Figure 3: Basic design of a plasma-panel display device. Figure 4: Basic design of a thin-film electroluminescent display device.
light-emitting diode
Liquid-crystal displays
Random-Scan Displays
Figure 5: A random-scan system draws the component lines of an object in any specified order.
random-scan display
Raster-Scan Systems
Video Controller
Figure 6: Raster systems. Architecture of a raster system with a fixed portion of the system memory reserved for the
frame buffer
display processor,
graphics controller display coprocessor.
scan
conversion.
run-length encoding
cell encoding
Figure 9: Operation of a three-dimensional display system using a vibrating mirror that changes focal length to match
the depths of points in a scene.
Input Devices
Keyboards
keyboard
Mouse Devices
mouse
spaceball,
Joysticks
Joystick
isometric joysticks,
Data Gloves
data glove
Digitizers
digitizer.
Image Scanners
image scanner
Touch Panels
Touch panels
Light Pens
Light pen
Voice Systems
voice system
3 GRAPHICS SOFTWARE
Coordinate Representations
F I G U R E 10 : Coordinate Representations
Object Coordinates
World coordinates
Eye Coordinates:
Clip coordinates
window-to-viewport mapping
Graphics Functions
Attributes:
Geometric transformations:
Viewing transformations:
Input functions
Control operations:
#include<GL/glut.h>
void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 300);
glutInitWindowPosition(50, 100);
glutCreateWindow("An Example OpenGL Program");
glutDisplayFunc(display);
myinit();
glutMainLoop();
}
F I G U R E 11 : A 400 by 300 display window at position (50, 100) relative to the top-left corner of the video
display.
argc argv
mode
glutInitWindowPosition(50, 100)
func
glutDisplayFunc()
F I G U R E 12: The display window and line segment produced by the example program.
FIGURE 1 glOrtho2D
gluOrtho2D
x y
gluOrtho2D
glMatrixMode (GL_PROJECTION);
glLoadIdentity ( );
gluOrtho2D (xmin, xmax, ymin, ymax);
xmin ymin
xmax ymax
glVertex* ( );
glVertex
glBegin (GL_POINTS);
glVertex* ( );
glEnd ( );
glVertex
homogeneous-coordinate
homogeneous parameter h
x y
x y h
glVertex i s f
d
glVertex
glBegin (GL_POINTS);
glVertex2i (50, 100);
glVertex2i (75, 150);
glVertex2i (100, 200);
glEnd ( );
glBegin (GL_POINTS);
glVertex2iv (point1);
glVertex2iv (point2);
glVertex2iv (point3);
glEnd ( );
glBegin (GL_POINTS);
glVertex3f (-78.05, 909.72, 14.60);
glVertex3f (261.91, -5200.67, 188.33);
glEnd ( );
struct
class wcPt2D {
public:
GLfloat x, y;
};
wcPt2D pointPos;
pointPos.x = 120.75;
pointPos.y = 45.30;
glBegin (GL_POINTS);
glVertex2f (pointPos.x, pointPos.y);
glEnd ( );
GL LINES
p1 p5
glBegin (GL_LINES);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);
glEnd ( );
FIGURE 15
GL LINES
GL LINE STRIP
GL LINE LOOP
glBegin (GL_LINE_STRIP);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);
glEnd ( );
GL LINE LOOP closed polyline.
glBegin (GL_LINE_LOOP);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);
glEnd ( );
FIGURE 3-15
glColor glIndex
glBegin glEnd
glLineWidth (width);
width
repeatFactor
pattern
glEnable (GL_LINE_STIPPLE);
glDisable (GL_LINE_STIPPLE);
FIGURE 16
F I G U R E 17: A section of the screen showing a pixel in column xk on the scanline yk to be plotted along a line segment
slope 0<m<1
F I G U R E 18: Vertical distances between pixel position and the line y coordinate at sampling position xk+1
= 2 * dy - dx;
– 4 = 6 -
dy - dx
dy - dx
F I G U R E 19: Midpoint between candidate pixels at sampling position between along circular path
1 10 = -9 + 2(1) + 0 – 0 +1 = -6
2 10 = -6 + 2(2) + 0 – 0 +1 = -1
3 10 = -1 + 2(3) + 0 – 0 +1 = 6
4 9 = 6 + 2(4) + (9*9 – 10*10) – (9 - 10) +1 = -3
5 9 = -3 + 2(5) + 0 – 0 +1 = 8
6 8 = 8 + 2(6) + (8*8 – 9*9) –(8 – 9) +1 = 5
7 7 Algorithm terminate since (
Plot all the generated pixels positions with centre as (xc, yc) = (3, 4)
(x +xc, y+yc) (-x +xc, -y+yc) (-x +xc, y+yc) (x +xc, -y+yc)
(y +xc, x+yc) (-y +xc, -x+yc) (-y +xc, x+yc) (y +xc, -x+yc)
1.
2.
3.
4.
5.
6.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.