CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain
OpenGL
http://www.pling.org.uk/cs/cgv.html
OpenGL CS 148: Summer 2016 Introduction of Graphics and Imaging - - PowerPoint PPT Presentation
OpenGL CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain http://www.pling.org.uk/cs/cgv.html So Far: Theory of Rasterization 2 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) Zahid Hossain
CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain
http://www.pling.org.uk/cs/cgv.html
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 2
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 4
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 5
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 6
http://www.geforce.com/hardware/10series/geforce-gtx-1080
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 7
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 8
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 9
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 10
Google Maps Angry Birds by Rovio
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 11
Google Maps Angry Birds by Rovio
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 12
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 13
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 14
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 15
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 16
glutInitWindowSize(..)
glutSolidSphere, glutSolidCube, …
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 17
glutInitWindowSize(..)
glutSolidSphere, glutSolidCube, …
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 18
gluOrtho2D, …
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 19
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 20
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 21
defines the camera/viewing matrix! where is the viewpoint? where is it pointed? which way is up?
eye at up
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 22
The Redbook, fig. 3-14 (p. 155)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 23
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 24
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 25
(x, y) at lower left height width
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 26
A small piece of geometry that can be rendered in OpenGL; e.g. triangles, lines, points etc.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 27
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 28
http://www.opengl2go.net/wp-content/uploads/2015/10/gl-primitives-with-background.png
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 29
1 2 3 4 5 6
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 30
1 2 3 4 5
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 31
1 2 3 4 5
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 32
v1 v2 v3
gl... e.g., glColor3f(...) core OpenGL function glu... e.g., gluLookAt(...) OpenGL utility function, makes common tasks easier (defined in terms of gl... functions) glut... e.g., glutSolidTeapot(...) GLUT functions
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 33
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 34
glVertex3f(...)
...3f takes 3 floats ...3d takes 3 doubles ...3i takes 3 integers ...2f takes 2 floats ...4f takes 4 floats (etc)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 35
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 36
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 37 translate(0,4) drawTorso() pushMatrix() translate(1.5,0) rotateX(leftHipRotate) drawThigh() pushMatrix() translate(0,-2) rotateX(leftKneeRotate) drawLeg() ... popMatrix() popMatrix() pushMatrix() translate(-1.5,0) rotateX(rightHipRotate) // Draw the right side ... ...
x y
CurrentMatrix = translate(0,4) translate(1.5,0) rotateX(leftHipRotate) translate(0,-2) rotate(leftKneeRotate) Matrix Stack
translate(0,4) translate(0,4) translate(1.5,0) rotateX(leftHipRotate)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 38
http://upload.wikimedia.org/wikipedia/commons/b/bb/Pipeline_OpenGL_%28en%29.png
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 39
http://www.opengl.org/documentation/specs/version1.1/state.pdf
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 40
http://www.opengl.org/documentation/specs/version1.1/state.pdf
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 41
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 42
GLuint boxList; boxList = glGenLists(1); glNewList(boxList, GL_COMPILE); // draw box glEndList(boxList); … glCallList(boxList);
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 43
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 44
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 45
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 46
Includes Clipping
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 47
The data necessary to generate a single pixel’s worth
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 48
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 49
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 50
Change State Draw Draw Change State Draw Change State Change State Draw
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 51
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 52
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 53
Efficiently managing state changes is a major implementation challenge
OUT OF DATE.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 54
OUT OF DATE.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 55
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 56
A vector perpendicular to a surface; constant over a plane
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 57
https://en.wikipedia.org/wiki/Normal_(geometry)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 58
1 2 3 1 2 3
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 59
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 60
Camera
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 61
Camera
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 62
Camera Ambient Light
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 63
Camera Ambient Light
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 64
Enable a Light Setup material
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 65
Enable a Light Setup material
Note: w=0 is directional light glutSolidTeapot specifies the normal in this case
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 66
http://www.computing.northampton.ac.uk/~gary/csy3019/images3d/lightSources.gif
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 67
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 68
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 69
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 70
Vertices = { v0,v1,.. V7 } Indices = { 0,1,2, 0,2,3, 1,5,6, 1,6,2 …... } v0 v1 v2 v3 v5 v6 v7
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 71
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 72
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 73
CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain
http://www.pling.org.uk/cs/cgv.html