Lecture 01

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 68

Course Objectives

 Familiarize the student with the basic concepts of


graphics hardware and software
 Develop computer graphics programs using OpenGL
 Help the students to add 2D and 3D graphics to their
applications
 To be able to write programs to display 2D and 3D
data
 Help the students to follow new topics in computer
graphics field
Textbook
 Computer Graphics with OpenGL (open
graphics library), Third Edition, Donald Hearn
and M. Pauline Baker, Prentice Hall, 2004
ISBN: 0-13-015390-7
Additional Text
 Computer Graphics Using Open GL (2nd Edition)
(Hardcover) by Francis S. Hill
 OpenGL Programming Guide or 'The Red Book'
http://www.rush3d.com/reference/opengl-redbook-
1.1/
 Computer Graphics - Principles and Practice, Second
Edition in C, Foley, van Dam, Feiner, Hughes
 Computer Graphics – Theory into Practice, Jeffrey J.
McConnell
Course Topics
Week Subject
1 Introduction and overview, introduction to OpenGL
2 Output primitives
3 Output primitives (continued)
4 Attributes of Graphics primitives
5 Interactive Input Methods and Graphical User Interfaces
6 Geometric Transformations
7 Viewing
8 3D Object Representation
9 Visible Surface Detection Methods
10 Illumination Models and Surface Rendering Methods
11 Illumination Models and Surface Rendering Methods (continued)
12 Color Models and Color Applications
13 Animation
14 Hierarchical Modeling & Summary
Introduction
 Computer graphics is using computers to
generate and display images
 The course is about how to program a computer
to generate photo-realistic images
People remember
10% of what they read

20% of what they hear

30% of what they see

50% of what they hear and see

80% of what they hear, see


and say

90% of what they hear, see,


say and touch
Computer Graphics Applications
 Graphs and charts
 Computer Aided Design (CAD)
 Virtual Reality Environments
 Data visualizations
 Education & Training
 Computer Art
 Entertainment
 Image processing
 Graphical User Interfaces
Graphs and charts
Graphs and charts
Graphs and charts
Graphs and charts
Computer Aided Design (CAD) or
Computer Aided Drafting & Desing
(CADD)

From www.autodesk.com
Computer Aided Design (CAD)

From www.amabilis.com
Computer Aided Design (CAD)

From www.alibre.com
Computer Aided Design (CAD)

From www.intellicad.org
Virtual Reality Environments

From www.flyit.com
Data visualizations

Plotted with Maxima (maxima.sourceforge.net)


Data visualizations

From molvis.sdsc.edu/dna
Data visualizations

Aerodynamic simulation of the Ferrari F1 car body showing


pressure contours and pathlines (from www.fluent.com)
Education & Training

From www.flyit.com
Computer Art

From www.blender.org
Computer Art

From www.blender.org
Computer Art

From moca.virtual.museum
Entertainment
Entertainment
Entertainment
Entertainment
Entertainment

From www.microsoft.com
Image processing

From www.ph.tn.tudelft.nl
Image processing

From www.wikipedia.org
Graphical User Interfaces
Contents of the Course
 Basic concepts of computer graphics
 Computer graphics hardware and software
 Output primitives
 Basic techniques
 2D and 3D graphics, transformations
 OpenGL
Overview of Graphics Systems
 Video Display Devices
 Raster Scan Systems
 Graphics Workstations and Viewing Devices
 Input Devices
 Hard Copy Devices
 Graphics Networks
 Graphics on the Internet
 Graphics Software
Cathode Ray Tube

Illustration showing the interior of a cathode-ray tube for use in an oscilloscope.


Numbers in the picture indicate: 1.Deflection voltage electrodes 2.Electron gun
3. Electron beam 4.Focusing coil 5.Phosphor-coated inner side of the screen

from wikipedia.org
Cathode Ray Tube

Diagram of a CRT tube


from Hearn and Baker
Raster Scan Display
Color Cathode Ray Tube

Illustration showing the interior of a cathode-ray tube for color televisions and monitors.
Numbers in the picture indicates:
1.Electron guns 2.Electron beams 3. Mask for separating beams for red, green and
blue part of displayed image 4. Phosphor layer with red, green, and blue zones
5.Close-up of the phosphor-coated inner side of the screen from wikipedia.org
Cathode Ray Tube

Aperture grille CRT close-up

from wikipedia.org
Three Dimensional Viewing Devices
 For the display of 3D scenes
 Reflects a CRT image from a vibrating, flexible
mirror
 Allows to walk around an object or scene and
view it from different sides
Stereoscopic and Virtual-Reality
Systems
 Not true 3D images, but provides a 3D effect.
 Uses two views of a scene along the lines of
right and left eye. Gives perception of a scene
depth when right view is seen from right eye and
left scene is seen from left eye (stereoscopic
effect). Display each view at alternate refresh
cycles.
Input Devices
 Input devices
 Keyboards, button boxes, dials
 Mouse devices
 Trackballs and spaceballs
 Joysticks
 Data gloves
 Digitizers
 Image scanners
 Touch panels
 Light pens
 Voice systems
Hard-copy Devices

 Hard-copy devices
 Plotters
 2D moving pen with stationary paper
 1D pen and 1D moving paper

 Printers
 Impact devices
 Inked ribbon
 Non impact devices
 Laser, ink-jet, xerographic, electrostatic, electrothermal.
Graphics Software

 Graphics software
 Special purpose
 For non programmers
 CAD, CAM, painting, animation

 General programming packages


 C, C++, Java, …
 Library of graphics functions (OpenGL)
 Picture components (lines, shapes, …)
 Transformations (color, texture, shading, rotating, …)
Coordinate Representations
 To generate a picture using a programming
package, we first need to give the geometric
descriptions of the objects – location and shape
 For example, a box is specified by the positions
of its corners, a sphere is specified by its center
position and radius
Coordinate Representation
 Cartesian coordinates
 Modeling coordinates (local, master)
in the reference frame of each object
 World coordinates
in the scene reference frame
 Viewing coordinates
view we want of a scene
 Normalized (device) coordinates
normalized between –1 and 1 or 0 and 1
 Device coordinates (screen coordinates)
Coordinate System

(from Donald Hearn and Pauline Baker)


Bicycle Example
Bicycle Example
Coordinate Transformations
 (xmc, ymc, zmc) → (xwc, ywc, zwc) → (xvc, yvc, zvc)
→ (xpc, ypc, zpc) → (xnc, ync, znc) → (xdc, ydc)
Graphics Functions
 Graphics Output Primitives
 Character strings, lines, filled color areas (usually
polygons)
 Basic tools for constructing pictures

 Attributes
 Color, line style, text style, area filling patterns
 Geometric Transformations
 Change size, position or orientation of an object
Graphics Functions
 Viewing Transformations
 Select a view of the scene, type of projection to be
used, location of the view on the video monitor
 Input functions
 Control and process data flow from interactive
devices
 Control operations
 Clear the screen display area, initialize parameters
Introduction to OpenGL
 First part of Silicon Graphics graphics
workstations (formerly GL)
 De facto graphics standard
 Became hardware independent in early 1990s
and named as OpenGL
 Developed especially for 3D scenes
 2D scenes as projections where z-coordinate is
0.
OpenGL (Open Graphics Library)
 Graphics rendering API (Application
Programmer’s Interface)
 A software interface to graphics hardware
 Generation of high-quality color images composed
of geometric and image primitives
 Window system independent

 Operating system independent

 Close to the hardware


 Algorithms and implementations are important
OpenGL and the Windowing
System
 OpenGL is concerned only with rendering
 It is window system independent
 No input functions

 OpenGL must interact with the underlying OS


and windowing system
 Need minimal interface which may be system
dependent
 Done through additional libraries: AGL (Apple), GLX (X-
Window), WGL(Windows)
GLU and GLUT
 GLU (OpenGL Utility Library)
 Part of OpenGL
 Provides NURBS (splines), etc.
 GLUT (OpenGL Utility Toolkit)
 A portable windowing API
 Not officially part of OpenGL
 Extremely useful for helping to create images quickly without
worrying about the underlying windowing system being used
Basic OpenGL Syntax
 Function names are prefixed with gl for core
library, glu for GLU, glut for GLUT library
 glBegin, glClear, gluOrtho2D,glutInit
 Constants
 GL_2D, GL_RGB, GLUT_SINGLE
 Data types
 GLbyte, GLshort, GLint, GLfloat, GLdouble
OpenGL Command Formats

glVertex3fv( v )

Number of Data Type Vector


components b - byte omit “v” for
ub - unsigned byte
2 - (x,y) scalar form
s - short
3 - (x,y,z)
us - unsigned short
4 - (x,y,z,w) glVertex2f( x, y )
i - int
ui - unsigned int
f - float
d - double
Display Window

(from Donald Hearn and Pauline Baker)


Sample Program
#include <GL/glut.h>
// (or others, depending on the system
in use)

void init (void)


{
glClearColor (1.0, 1.0, 1.0, 0.0);
// Set display-window color to white.

glMatrixMode (GL_PROJECTION);
// Set projection parameters.
gluOrtho2D (0.0, 200.0, 0.0,150.0);
}
Sample Program
void lineSegment (void)
{
glClear (GL_COLOR_BUFFER_BIT);
// Clear display window.

glColor3f (1.0, 0.0, 0.0);


// Set line segment color to red.
glBegin (GL_LINES);
glVertex2i (180, 15);
// Specify line-segment geometry.
glVertex2i (10, 145);
glEnd ( );

glFlush ( );
// Process all OpenGL routines as quickly as
possible.
}
Sample Program
void main (int argc, char** argv)
{
glutInit (&argc, argv); // Initialize GLUT.
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
// Set display mode.
glutInitWindowPosition (50, 100);
// Set top-left display-window position.
glutInitWindowSize (400, 300);
// Set display-window width and height.
glutCreateWindow ("An Example OpenGL Program");
// Create display window.
init ( );
// Execute initialization procedure.
glutDisplayFunc (lineSegment);
// Send graphics to display window.
glutMainLoop ( );
// Display everything and wait.
}
Output
Specifying Geometric Primitives
 Primitives are specified using
glBegin( primType );
glVertex…

glEnd();
 primType determines how vertices are combined
Geometric Primitive Types
Geometric Primitive Types
 GL_POINTS : Draws a point at each of the n vertices.
 GL_LINES : Draws a series of unconnected line
segments. Segments are drawn between v0 and v1, between v2
and v3, and so on. If n is odd, the last segment is drawn between
vn-3 and vn-2, and vn-1 is ignored.
 GL_LINE_STRIP : Draws a line segment from v0 to v1, then
from v1 to v2, and so on, finally drawing the segment from vn-2
to vn-1. Thus, a total of n-1 line segments are drawn. Nothing is
drawn unless n is larger than 1. There are no restrictions on the
vertices describing a line strip (or a line loop); the lines can
intersect arbitrarily.
 GL_LINE_LOOP : Same as GL_LINE_STRIP, except that a
final line segment is drawn from vn-1 to v0, completing a loop.
Geometric Primitive Types
 GL_TRIANGLES : Draws a series of triangles (three-
sided polygons) using vertices v0, v1, v2, then v3, v4, v5, and so
on. If n isn't an exact multiple of 3, the final one or two vertices
are ignored.
 GL_TRIANGLE_STRIP : Draws a series of triangles (three-
sided polygons) using vertices v0, v1, v2, then v2, v1, v3 (note
the order), then v2, v3, v4, and so on. The ordering is to ensure
that the triangles are all drawn with the same orientation so that
the strip can correctly form part of a surface. Preserving the
orientation is important for some operations, such as culling.
(See "Reversing and Culling Polygon Faces") n must be at least 3
for anything to be drawn.
 GL_TRIANGLE_FAN :Same as GL_TRIANGLE_STRIP,
except that the vertices are v0, v1, v2, then v0, v2, v3, then v0,
v3, v4, and so on.
Geometric Primitive Types
 GL_QUADS : Draws a series of quadrilaterals
(four-sided polygons) using vertices v0, v1, v2, v3, then v4, v5,
v6, v7, and so on. If n isn't a multiple of 4, the final one, two, or
three vertices are ignored.
 GL_QUAD_STRIP : Draws a series of quadrilaterals
(four-sided polygons) beginning with v0, v1, v3, v2, then v2, v3,
v5, v4, then v4, v5, v7, v6, and so on (see Figure 2-7). n must be
at least 4 before anything is drawn. If n is odd, the final vertex is
ignored.
 GL_POLYGON :Draws a polygon using the points
v0, ... , vn-1 as vertices. n must be at least 3, or nothing is drawn.
In addition, the polygon specified must not intersect itself and
must be convex. If the vertices don't satisfy these conditions, the
results are unpredictable.
Valid and Invalid Polygons

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy