CSCE 641 Computer Graphics: Fourier Transform Jinxiang Chai.
Computer Graphics CSCE 441
-
Upload
kathleen-weaver -
Category
Documents
-
view
45 -
download
0
description
Transcript of Computer Graphics CSCE 441
![Page 1: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/1.jpg)
1
Dr. Scott Schaefer
Computer Graphics CSCE 441
![Page 2: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/2.jpg)
2/46
Staff
Instructor Dr. Scott Schaefer HRBB 527B Office Hours: T 2-3pm, R 8:30-9:30am
(or by appointment) TA
Donghui Han ETB 2016 Office Hours: M 1-3pm, W 10am-noon
![Page 3: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/3.jpg)
Websites
Course Pagehttp://courses.cs.tamu.edu/schaefer/441_Fall2014
Piazza Discussion Board
http://piazza.com/tamu/fall2014/csce441/home
3/46
![Page 4: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/4.jpg)
4/46
Why did you take this class?
![Page 5: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/5.jpg)
5/46
Games
![Page 6: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/6.jpg)
6/46
Movies
![Page 7: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/7.jpg)
7/46
Visualization
![Page 8: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/8.jpg)
8/46
Industrial Design
![Page 9: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/9.jpg)
9/46
What will you learn in this class?
2D Graphics Drawing lines, polygons Fractals
3D Graphics Transformations Lighting Ray Tracing Solid Modeling Splines/Subdivision
![Page 10: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/10.jpg)
10/46
What you’re expected to know
Programming ExperienceAssignments in C/C++
Simple Mathematics
Graphics is mathematics made visible
![Page 11: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/11.jpg)
11/46
How much math?
General geometry/linear algebra Matrices
Multiplication, inversion, determinant Vectors
Dot product, cross product, linear independence
![Page 12: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/12.jpg)
12/46
First Homework Assignment!
Linear Algebra Test
http://projects.cs.tamu.edu/keyser/LAtest/
Complete before September 17, 2014 Take as many times as you like Must get at least 90% correct
Grade = ActualGrade * (exam 90% ? 1 : 0 )
![Page 13: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/13.jpg)
13/46
Other Assignments
Simple Painting Program Polygon Drawing Fractals and Iterated Affine Transformations 3D Rasterization and Hidden Surfaces Ray Tracing
![Page 14: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/14.jpg)
14/46
More on Assignments
Turn in code via CSNET
(get an account if you don’t already have one) Due by 11:59pm on day specified Code, solution file, proj file and Win32
executable Make your code readable (comment) You may discuss concepts, but coding is
individual (no “team coding” or web)
![Page 15: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/15.jpg)
15/46
Grading
60% Assignments 15% Midterm 25% Final
![Page 16: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/16.jpg)
16/46
Late Policy
Penalty = m: number of minutes late
days late
perc
enta
ge p
enal
ty%6.57
m
![Page 17: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/17.jpg)
17/46
Textbooks
![Page 18: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/18.jpg)
18/46
Suggested Reading
![Page 19: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/19.jpg)
19/46
Introduction to OpenGL
What is OpenGL? Computer-graphics API (application
programming interface) Developed by SGI in 1992 Efficient, streaming interface 250+ function calls for drawing 2D and 3D graphics Hardware independent Operating system independent Direct3D alternative API from Microsoft
![Page 20: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/20.jpg)
20/46
Introduction to OpenGL
What OpenGL is NOTNo commands for windowingNo commands for obtaining user inputNo commands for anything except
drawing on the screen
![Page 21: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/21.jpg)
21/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
![Page 22: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/22.jpg)
22/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Sets the color for clearing the screen
![Page 23: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/23.jpg)
23/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Clears the screen
![Page 24: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/24.jpg)
24/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Sets the current drawing color to white
![Page 25: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/25.jpg)
25/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Sets the window coordinates to (0,0,-1) – (1,1,1)
![Page 26: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/26.jpg)
26/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Starts drawing a polygon
![Page 27: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/27.jpg)
27/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Specifies the vertices of the polygon
![Page 28: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/28.jpg)
28/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Ends the polygon
![Page 29: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/29.jpg)
29/46
A Smidgen of OpenGL Code# include <whateverYouNeed.h>
Main() {IntializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);glClear (GL_COLOR_BUFFER_BIT);glColor3f ( 1.0, 1.0, 1.0);glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0);
glEnd();glFlush();
UpdateTheWindowAndCheckForEvents();}
Flushes all commands to ensure polygon is drawn
![Page 30: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/30.jpg)
30/46
OpenGL Command Formats
glVertex3fv( v )
Number ofcomponents
2 - (x,y) 3 - (x,y,z)4 - (x,y,z,w)
Data Typeb - byteub - unsigned bytes - shortus - unsigned shorti - intui - unsigned intf - floatd - double
Vector
omit “v” forscalar form
glVertex2f( x, y )
PrefixInitial capital letters
![Page 31: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/31.jpg)
31/46
OpenGL Geometric Primitives
All geometric primitives are specified by vertices
GL_QUAD_STRIPGL_QUAD_STRIP
GL_POLYGONGL_POLYGON
GL_TRIANGLE_STRIPGL_TRIANGLE_STRIP
GL_TRIANGLE_FANGL_TRIANGLE_FAN
GL_POINTSGL_POINTSGL_LINESGL_LINES
GL_LINE_LOOPGL_LINE_LOOPGL_LINE_STRIPGL_LINE_STRIP
GL_TRIANGLESGL_TRIANGLES
GL_QUADSGL_QUADS
![Page 32: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/32.jpg)
32/46
OpenGL Drawing Functions
glBegin (GL_POINTS);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);glVertex2iv (p6);
glEnd();
P1
P2 P3
P4
P5P6
![Page 33: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/33.jpg)
33/46
OpenGL Drawing Functions
glBegin (GL_LINES);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);glVertex2iv (p6);
glEnd();
P1
P2 P3
P4
P5P6
![Page 34: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/34.jpg)
34/46
OpenGL Drawing Functions
glBegin (GL_LINE_STRIP);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);glVertex2iv (p6);
glEnd();
P1
P2 P3
P4
P5P6
![Page 35: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/35.jpg)
glBegin (GL_LINE_LOOP);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);glVertex2iv (p6);
glEnd();
35/46
OpenGL Drawing Functions
P1
P2 P3
P4
P5P6
![Page 36: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/36.jpg)
36/46
OpenGL Drawing Functions
glBegin (GL_POLYGON);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);glVertex2iv (p6);
glEnd();
P1
P2 P3
P4
P5P6
![Page 37: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/37.jpg)
glBegin (GL_TRIANGLES);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p6);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);
glEnd();
37/46
OpenGL Drawing Functions
P1
P2 P3
P4
P5P6
![Page 38: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/38.jpg)
38/46
OpenGL Drawing Functions
glBegin (GL_TRIANGLES_STRIP);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p6);glVertex2iv (p3);glVertex2iv (p5);glVertex2iv (p4);
glEnd();
P1
P2 P3
P4
P5P6
![Page 39: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/39.jpg)
39/46
OpenGL Drawing Functions
glBegin (GL_TRIANGLES_FAN);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);glVertex2iv (p6);
glEnd();
P1
P2 P3
P4
P5P6
![Page 40: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/40.jpg)
40/46
OpenGL Drawing Functions
glBegin (GL_QUADS);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p3);glVertex2iv (p4);glVertex2iv (p5);glVertex2iv (p6);glVertex2iv (p7);glVertex2iv (p8);
glEnd();
P1
P2P3
P4 P5
P6P7
P8
![Page 41: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/41.jpg)
41/46
OpenGL Drawing Functions
glBegin (GL_QUADS_STRIP);glVertex2iv (p1);glVertex2iv (p2);glVertex2iv (p4);glVertex2iv (p3);glVertex2iv (p5);glVertex2iv (p6);glVertex2iv (p8);glVertex2iv (p7);
glEnd();
P1
P2P3
P4 P5
P6P7
P8
![Page 42: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/42.jpg)
42/46
OpenGL-Related Libraries
GLU (OpenGL Utility Library) - Part of OpenGL - Provides higher-level drawing routines such as Spheres, NURBS, tessellators, quadric shapes, etc…
![Page 43: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/43.jpg)
43/46
OpenGL-Related Libraries
GLU (OpenGL Utility Library) - Part of OpenGL - Provides higher-level drawing routines such as Spheres, NURBS, tessellators, quadric shapes, etc…
GLUT (OpenGL Utility Toolkit) - perform system-level I/O with the host operating system - cross platform
- portable windowing API - not officially part of OpenGL
![Page 44: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/44.jpg)
44/46
GLUT: OpenGL Utility Toolkit
Application StructureConfigure and open window Initialize OpenGL stateRegister input callback functions
renderresizeinput: keyboard, mouse, etc.
Enter event processing loop
![Page 45: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/45.jpg)
45/46
Sample Program
void main( int argc, char* argv[]){
glutInit (&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize (250, 250);glutInitWindowPosition (100, 100);
glutCreateWindow ( "HELLO");
init();
glutDisplayFunc ( display );
glutMainLoop();}
/* OpenGL Initialization */
/* callback function */
![Page 46: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/46.jpg)
46/46
GLUT Callback Functions
Routine to call when something happenswindow resized, user input, window needs
drawing, etc… “Register” callbacks with GLUT
glutDisplayFunc( display );glutIdleFunc( idle );glutKeyboardFunc( keyboard );glutMouseFunc( mouse );
![Page 47: Computer Graphics CSCE 441](https://reader035.fdocuments.us/reader035/viewer/2022062408/5681329a550346895d9933d0/html5/thumbnails/47.jpg)
47/46
Assignment 1 – Simple OpenGL/GLUT Application
Build a simple OpenGL/GLUT application Designed to get you started using OpenGL
and callbacks for interaction
Full description available on course webpagehttp://courses.cs.tamu.edu/schaefer/441_Fall2014