![Page 1: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/1.jpg)
Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to
Computer Graphics
Prof Emmanuel Agu
Computer Science Dept.Worcester Polytechnic Institute (WPI)
![Page 2: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/2.jpg)
What is Computer Graphics (CG)?
Computer graphics: algorithms, mathematics, data structures ..… that computer uses to generate PRETTY PICTURES
Techniques (e.g. draw a line, polygon) evolved over years Built into programmable libraries
Computer‐Generated!Not a picture!
![Page 3: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/3.jpg)
Photorealistic Vs Real‐Time Graphics
• Photo‐realistic: E.g ray tracingslow: may take days to render
• Real Time graphics: Milliseconds to render (30 FPS)But lower image quality
This ClassNot this Class
![Page 4: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/4.jpg)
Uses of Computer Graphics Entertainment: games
Courtesy: Super Mario Galaxy 2
Courtesy: Final Fantasy XIV
![Page 5: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/5.jpg)
Uses of Computer Graphics movies, TV, books, magazines
Courtesy: Shrek
Courtesy: Spiderman
![Page 6: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/6.jpg)
Uses of Computer Graphics Image processing:
alter images, remove noise, super‐impose images
Original Image Sobel Filter
![Page 7: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/7.jpg)
Uses of Computer Graphics Process monitoring:
Layout of large systems or plants
Courtesy:
Dataviews.de
![Page 8: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/8.jpg)
Uses of Computer Graphics Display simulations:
flight simulators, virtual worlds
Courtesy: Evans and Sutherland
![Page 9: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/9.jpg)
Uses of Computer Graphics Computer‐aided design:
architecture, electric circuit design
Courtesy:
cadalog.com
![Page 10: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/10.jpg)
Uses of Computer Graphics Displaying Mathematical Functions
E.g., Mathematica®
![Page 11: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/11.jpg)
Uses of Computer Graphics Scientific analysis and visualization:
molecular biology, weather, matlab, Mandelbrot set
Courtesy:
Human Brain Project, Denmark
![Page 12: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/12.jpg)
2D Vs. 3D 2‐Dimensional
Flat Only (x,y) color values on screen Objects no notion of distance from viewer
3‐Dimensional (x,y,z) values on screen Objects have distances from viewer
• This class covers both 2D & 3D!• Also interaction: Clicking, dragging
![Page 13: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/13.jpg)
About This Course Computer Graphics has many aspects
Computer Scientists create graphics tools (e.g. Maya, photoshop) Artists use CG tools/packages to create pretty pictures
![Page 14: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/14.jpg)
About This Course Most hobbyists follow artist path. Not much math! This Course: Computer Graphics for computer scientists!!! Teaches concepts, uses OpenGL as concrete example Course is NOT
just about programming OpenGL a comprehensive course in OpenGL. (Only parts of OpenGL covered) about using packages like Maya, Photoshop
![Page 15: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/15.jpg)
About This Course Class is concerned with:
How to build graphics tools Underlying mathematics Underlying data structures Underlying algorithms
This course is a lot of work. Requires: Lots of coding in C/C++ Shader programming Lots of math, linear algebra, matrices
We shall combine: Programmer’s view: Program OpenGL APIs Under the hood: Learn OpenGL internals (graphics algorithms, math,
implementation)
![Page 16: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/16.jpg)
Syllabus Summary
2 Exams (50%), 5 Projects (50%) Projects:
Develop OpenGL/GLSL code on any platform, must port to Zoolab machine May discuss projects but turn in individual projects
Class website: http://web.cs.wpi.edu/~emmanuel/courses/cs543/f13/
Text: Interactive Computer Graphics: A Top‐Down Approach with Shader‐based OpenGL by
Angel and Shreiner (6th edition), 2012
Cheating: Immediate ‘F’ in the course Advice:
Come to class Read the text Understand concepts before coding
![Page 17: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/17.jpg)
Elements of 2D Graphics Polylines Text Filled regions Raster images (pictures)
![Page 18: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/18.jpg)
Elements of 2D Graphics Polyline: connected sequence of straight lines Straight lines connect vertices (corners)
blow-up
vertex
![Page 19: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/19.jpg)
Polyline Attributes
Color Thickness Stippling of edges (dash pattern)
![Page 20: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/20.jpg)
Text Devices have:
text mode graphics mode.
Graphics mode: Text is drawn
Text mode: Text not drawn uses character generator
Text attributes: Font, color, size, spacing, and orientation
Outlined text
Shadow Text
SMALL CAPS
Little Text
Rotated Text
Big Text
![Page 21: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/21.jpg)
Filled Regions
Filled region: shape filled with some color or pattern Example: polygons
A
DC
B
![Page 22: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/22.jpg)
Raster Images
Raster image (picture) is made up of 2D matrix of small cells (pixels, for “picture elements”), in different colors or grayscale.
(Right: magnified image showing pixels.)
![Page 23: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/23.jpg)
Computer Graphics Tools Require hardware and software tools Hardware tools
Output devices: Video monitors, printers Input devices: Mouse/trackball, pen/drawing tablet, keyboard Graphics cards/accelerators (GPUs)
Software tools (low level) Operating system Editor Compiler Debugger Graphics Library (OpenGL)
![Page 24: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/24.jpg)
Graphics Processing Unit (GPU)
OpenGL implemented in hardware => FAST!! Programmable: as shaders Located either on PC motherboard (Intel) or Separate
graphics card (Nvidia or ATI)
On PC motherboard On separate PCI express card
![Page 25: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/25.jpg)
Computer Graphics Libraries Functions to draw line, circle, image, etc Previously device‐dependent
Different OS => different graphics library Tedious! Difficult to port (e.g. move program Windows to Linux) Error Prone
Now device‐independent libraries APIs: OpenGL, DirectX Working OpenGL program minimal changes to move from Windows to
Linux, etc
![Page 26: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/26.jpg)
OpenGL Basics
OpenGL’s function is Rendering (or drawing) Rendering? – Convert geometric/mathematical object
descriptions into images OpenGL can render:
2D and 3D Geometric primitives (lines, dots, etc) Bitmap images (pictures, .bmp, .jpg, etc)
OpenGL Program OpenGL
![Page 27: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/27.jpg)
GL Utility Toolkit (GLUT) OpenGL does NOTmanage drawing window
OpenGL Window system independent Concerned only with drawing (2D, 3D, images, etc) No window management (create, resize, etc), very portable
GLUT: Minimal window management Interfaces with different windowing systems Easy porting between windowing systems. Fast prototyping
GLUT
OpenGL
![Page 28: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/28.jpg)
GL Utility Toolkit (GLUT) No bells and whistles
No sliders No dialog boxes No elaborate menus, etc
To add bells and whistles, use system’s API or GLUI: X window system Apple: AGL Microsoft :WGL, etc
GLUT(minimal)
Slider Dialog box
![Page 29: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/29.jpg)
OpenGL Basics Low‐level graphics rendering API
Maximal portability Display device independent (Monitor type, etc)
Operating system independent (Unix, Windows, etc)
Window system independent based (Windows, X, etc)
OpenGL programs behave same on different devices, OS
![Page 30: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/30.jpg)
Simplified OpenGL Pipeline Vertices go in, sequence of steps (vertex processor, clipper,
rasterizer, fragment processor) image rendered This class: learn algorithms and order of these steps
Vertex Shader
Fragment(Pixel)Shader
Converts3D to 2D
![Page 31: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/31.jpg)
OpenGL Programming Interface
Programmer view of OpenGL? Application Programmer Interface (API) Writes OpenGL Application programs
![Page 32: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/32.jpg)
Framebuffer
Dedicated memory location: Draw in framebuffer => shows up on screen Located either on CPU (software) or GPU (hardware)
frame buffer
pixel at address [x,y]
0 639
479
0 x
ydisplay surface
scancontroller
x
y
x
y
spot at (x,y)
geometricpositionlogical
address
at (639, 0)
at (639, 479)
convert pixelvalue to color
![Page 33: Computer Graphics (CS 543) 1 (Part Introduction to Graphicsemmanuel/courses/cs543/f13/slides/lecture... · Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer](https://reader031.vdocuments.us/reader031/viewer/2022022014/5b3fc3557f8b9a3a138c78f1/html5/thumbnails/33.jpg)
References Angel and Shreiner, Interactive Computer Graphics (6th edition), Chapter 1
Hill and Kelley, Computer Graphics using OpenGL (3rdedition), Chapter 1