OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS...
Transcript of OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS...
![Page 1: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/1.jpg)
CS 148: Summer 2016Introduction of Graphics and ImagingZahid Hossain
OpenGL
http://www.pling.org.uk/cs/cgv.html
![Page 2: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/2.jpg)
SoFar:TheoryofRasterization
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 2
![Page 3: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/3.jpg)
Observation
• Applytransformation• Barycentric Interpolation• Rasterize• ComputeLightandShading(Moreonitlater)• LookupTextures(Moreonitlater)• Andlotmore….
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3
![Page 4: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/4.jpg)
Observation
• Applytransformation• Barycentric Interpolation• Rasterize• ComputeLightandShading(Moreonitlater)• LookupTextures(Moreonitlater)• Andlotmore….
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 4
To Millions of Triangles
and Billions of Fragments
![Page 5: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/5.jpg)
Observation
• Applytransformation• Barycentric Interpolation• Rasterize• ComputeLightandShading(Moreonitlater)• LookupTextures(Moreonitlater)• Andlotmore….
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 5
To Millions of Triangles
and Billions of Fragments
SIMD(Single Instruction Multiple Data)
![Page 6: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/6.jpg)
GraphicsHardware
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 6
2560 cores! (upto 1733 MHz, 8GB Mem)http://www.geforce.com/hardware/10series/geforce-gtx-1080
GTX1080
![Page 7: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/7.jpg)
Advice
Leaveimplementationoflow-levelfeaturestotheexperts.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 7
![Page 8: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/8.jpg)
Advice
Leaveimplementationoflow-levelfeaturestotheexperts.
Why?
• Abstractawayhardwaredifferences
• Rasterizationshouldbefast
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 8
![Page 9: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/9.jpg)
Introducing…
Industry Standard API for Computer Graphics(Cross Platform, since 1992)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 9
![Page 10: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/10.jpg)
NottheOnlyOne
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 10
![Page 11: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/11.jpg)
RelatedAPIsintheOpenGLFamily
GoogleMaps
AngryBirdsbyRovio
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 11
![Page 12: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/12.jpg)
RelatedAPIsintheOpenGLFamily
GoogleMaps
AngryBirdsbyRovio
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 12
![Page 13: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/13.jpg)
OpenGL1.x
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 13
![Page 14: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/14.jpg)
OpenGL1.x:Why?
•Easytolearn!•Littlecode•Instructional
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 14
![Page 15: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/15.jpg)
SimpleFirstProgram
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 15
![Page 16: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/16.jpg)
WhatOpenGLIsNot
OpenGLisnotawindowingsystem
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 16
![Page 17: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/17.jpg)
IntroducingGLUT(GLUtilityToolkit)
• Simplecross-platformwindowingAPI• glutInitDisplay(), glutInitWindowSize(..)
• Bindings:C,C++,Fortran,Ada,…• Features:• Multiplewindows,menus• Keyboard/mouse/otherinput• Assortedcallbacks:idle,timers• Basicfontsupport‘• glutSolidTeapot, glutSolidSphere, glutSolidCube, …
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 17
![Page 18: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/18.jpg)
IntroducingGLUT(GLUtilityToolkit)
• Simplecross-platformwindowingAPI• glutInitDisplay(), glutInitWindowSize(..)
• Bindings:C,C++,Fortran,Ada,…• Features:• Multiplewindows,menus• Keyboard/mouse/otherinput• Assortedcallbacks:idle,timers• Basicfontsupport‘• glutSolidTeapot, glutSolidSphere, glutSolidCube, …
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 18
Other options: glfw, SDL
![Page 19: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/19.jpg)
IntroducingGLU(GLUtility)• High-levelgraphicscommands• Not includedinOpenGLES• Someinterestingfeatures:• Mappingbetweenworldandscreencoordinates• Texturingsupport• Tessellationandothergeometricutilities• OpenGLerrorcodelookup• Moreprimitives:spheres,cylinders,disks,…• Camerasupport:gluLookAt, gluOrtho2D, …
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 19
![Page 20: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/20.jpg)
SimpleFirstProgram
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 20
Projection Matrix !(GL_PROJECTION)
![Page 21: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/21.jpg)
SimpleFirstProgram
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 21
Camera and Model Matrices Combined !
(GL_MODELVIEW)
![Page 22: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/22.jpg)
gluLookAt(eye,at,up)
defines thecamera/viewingmatrix!
whereistheviewpoint?
whereisitpointed?
whichwayisup?
eyeat
up
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 22
![Page 23: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/23.jpg)
gluPerspective(fovy,aspect,near,far)
TheRedbook, fig.3-14(p.155)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 23
![Page 24: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/24.jpg)
TransformationRecall
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 24
![Page 25: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/25.jpg)
TransformationRecall
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 25
NDC à Viewport Transformation à Final Image
![Page 26: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/26.jpg)
glViewport(x,y,width,height)
(x,y)atlowerleft
height
width
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 26
![Page 27: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/27.jpg)
Primitive[prim-i-tiv]:
AsmallpieceofgeometrythatcanberenderedinOpenGL;e.g.triangles,lines,pointsetc.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 27
![Page 28: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/28.jpg)
OpenGLPrimitiveTypes
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
![Page 29: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/29.jpg)
OpenGLPrimitives(Triangles)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 29
1 2
3
4 5
6
![Page 30: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/30.jpg)
OpenGLPrimitives(TriangleStrip)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 30
1
2
3
4
5
![Page 31: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/31.jpg)
OpenGLPrimitives(TriangleStrip)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 31
1
2
3
4
5
Immediate Mode(Deprecated)
![Page 32: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/32.jpg)
Color:glColor3f(red,green,blue)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 32
v1
v2
v3
![Page 33: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/33.jpg)
GL,GLU,andGLUTnotationsgl...
e.g.,glColor3f(...)coreOpenGLfunction
glu...e.g.,gluLookAt(...)
OpenGLutilityfunction,makescommontaskseasier(defined intermsofgl...functions)
glut...e.g.,glutSolidTeapot(...)
GLUTfunctions
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 33
![Page 34: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/34.jpg)
GL,GLU,andGLUTnotations
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 34
glVertex3f(...)...3f takes3floats...3d takes3doubles...3i takes3integers
...2f takes2floats
...4f takes4floats(etc)
![Page 35: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/35.jpg)
ComposingTransformationsglLoadMatrixf(A);glMultMatrixf(B);glMultMatrixf(C);
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 35
![Page 36: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/36.jpg)
ConvenienceFunctions
• glTranslatef(tx, ty, tz)
• glRotatef(degrees, x, y, z)
• glScalef(sx, sy, sz)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 36
![Page 37: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/37.jpg)
HierarchicalModeling
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)
MatrixStack
translate(0,4)translate(0,4)translate(1.5,0)rotateX(leftHipRotate)
![Page 38: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/38.jpg)
OpenGLMatrixStack
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 38
![Page 39: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/39.jpg)
OpenGL1.xPipeline(Simplified)
http://upload.wikimedia.org/wikipedia/commons/b/bb/Pipeline_OpenGL_%28en%29.pngCS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 39
![Page 40: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/40.jpg)
OpenGL1.xPipeline(Unsimplified)
http://www.opengl.org/documentation/specs/version1.1/state.pdf
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 40
![Page 41: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/41.jpg)
OpenGL1.xPipeline(Unsimplified)
http://www.opengl.org/documentation/specs/version1.1/state.pdf
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 41
![Page 42: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/42.jpg)
PiecesofthePipeline
Stores“subroutines”
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 42
GLuint boxList;boxList = glGenLists(1);glNewList(boxList, GL_COMPILE);
// draw boxglEndList(boxList);…glCallList(boxList);
![Page 43: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/43.jpg)
PiecesofthePipeline
Stores“subroutines”
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 43
![Page 44: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/44.jpg)
PiecesofthePipeline
Constructgeometricobjects
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 44
![Page 45: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/45.jpg)
PiecesofthePipeline
Changegeometry
Storeprimitiveshapes
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 45
![Page 46: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/46.jpg)
PiecesofthePipeline
Changegeometry
Storeprimitiveshapes
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 46
Includes Clipping
![Page 47: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/47.jpg)
PiecesofthePipeline
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 47
![Page 48: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/48.jpg)
Fragment[frag-muhnt]:
Thedatanecessarytogenerateasinglepixel’sworthofaprimitive.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 48
![Page 49: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/49.jpg)
PiecesofthePipeline
Modifyandcombineper-pixel
information
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 49
![Page 50: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/50.jpg)
PiecesofthePipeline
Prepareimagetobedisplayed
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 50
![Page 51: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/51.jpg)
OpenGLStateMachine
ChangeStateDrawDraw
ChangeStateDraw
ChangeStateChangeState
Draw
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 51
![Page 52: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/52.jpg)
OpenGLStateMachine
glColor3f(…)
glEnable(…)
glLineStipple(…)
glGetFloatv(…)
glIsEnabled(…)
glGetLineStipple(…)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 52
SetState GetState
![Page 53: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/53.jpg)
OpenGLStateMachine
glColor3f(…)
glEnable(…)
glLineStipple(…)
glGetFloatv(…)
glIsEnabled(…)
glGetLineStipple(…)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 53
Efficiently managing state changes is a major implementation challenge
SetState GetState
![Page 54: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/54.jpg)
OUT OF DATE.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 54
![Page 55: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/55.jpg)
OUT OF DATE.
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 55
![Page 56: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/56.jpg)
VertexLighting
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 56
![Page 57: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/57.jpg)
Normal
Avectorperpendiculartoasurface;constantoveraplane
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 57
https://en.wikipedia.org/wiki/Normal_(geometry)
![Page 58: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/58.jpg)
SpecifyingNormals
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 58
1
2
3
1
2
3
![Page 59: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/59.jpg)
VertexLighting
• DiffuseTerm
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 59
![Page 60: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/60.jpg)
VertexLighting
• SpecularTerm
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 60
Camera
![Page 61: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/61.jpg)
VertexLighting
• SpecularTerm
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 61
Camera
![Page 62: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/62.jpg)
VertexLighting
• SpecularTerm
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 62
Camera
AmbientLight
![Page 63: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/63.jpg)
VertexLighting
• SpecularTerm
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 63
Camera
AmbientLight
![Page 64: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/64.jpg)
VertexLighting
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 64
EnableaLight
Setupmaterial
![Page 65: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/65.jpg)
VertexLighting
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 65
EnableaLight
Setupmaterial
Note: w=0 is directional light
glutSolidTeapot specifies the normal in this case
![Page 66: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/66.jpg)
VertexLighting:Types
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 66
http://www.computing.northampton.ac.uk/~gary/csy3019/images3d/lightSources.gif
![Page 67: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/67.jpg)
Vertex&IndexBuffers
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 67
![Page 68: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/68.jpg)
Vertex/IndexBuffer
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 68
8 vertices only
![Page 69: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/69.jpg)
Vertex/IndexBuffer
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 69
Drawing with triangles: 36 vertices!
8 vertices only
![Page 70: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/70.jpg)
Vertex/IndexBuffer
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 70
8 vertices only
Vertices={v0,v1,..V7}
Indices={0,1,2,0,2,3,1,5,6,1,6,2…...}v0
v1
v2
v3
v5
v6
v7
![Page 71: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/71.jpg)
Vertex/IndexBuffer
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 71
![Page 72: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/72.jpg)
NextGenerationAPIs
• Vulkan (NextgenOpenGL)• DirectX12(Microsoft)• Metal(Apple)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 72
![Page 73: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/73.jpg)
NextGenerationAPIs
• Vulkan (NextgenOpenGL)• DirectX12(Microsoft)• Metal(Apple)
CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 73
![Page 74: OpenGL - GitHub Pages › cs148 › assets › slides › 05-OpenGL.pdf · Hierarchical Modeling CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain](https://reader035.fdocuments.in/reader035/viewer/2022081407/5f1ab319613f0f34dd55dcff/html5/thumbnails/74.jpg)
CS 148: Summer 2016Introduction of Graphics and ImagingZahid Hossain
OpenGL
http://www.pling.org.uk/cs/cgv.html