opengl
play

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


  1. OpenGL CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain http://www.pling.org.uk/cs/cgv.html

  2. So Far: Theory of Rasterization 2 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  3. Observation • Apply transformation • Barycentric Interpolation • Rasterize • Compute Light and Shading (More on it later) • Lookup Textures (More on it later) • And lot more …. 3 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  4. Observation To Millions of Triangles • Apply transformation and • Barycentric Interpolation Billions of Fragments • Rasterize • Compute Light and Shading (More on it later) • Lookup Textures (More on it later) • And lot more …. 4 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  5. Observation To Millions of Triangles • Apply transformation and • Barycentric Interpolation Billions of Fragments • Rasterize • Compute Light and Shading (More on it later) • Lookup Textures (More on it later) • And lot more …. SIMD (Single Instruction Multiple Data) 5 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  6. Graphics Hardware GTX 1080 2560 cores! (upto 1733 MHz, 8GB Mem) http://www.geforce.com/hardware/10series/geforce-gtx-1080 6 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  7. Advice Leave implementation of low-level features to the experts. 7 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  8. Advice Leave implementation of low-level features to the experts. Why ? • Abstract away hardware differences • Rasterization should be fast 8 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  9. Introducing … Industry Standard API for Computer Graphics (Cross Platform, since 1992) 9 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  10. Not the Only One 10 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  11. Related APIs in the OpenGL Family Angry Birds by Rovio Google Maps 11 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  12. Related APIs in the OpenGL Family Angry Birds by Rovio Google Maps 12 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  13. OpenGL 1.x 13 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  14. OpenGL 1.x: Why ? • Easy to learn! • Little code • Instructional 14 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  15. Simple First Program 15 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  16. What OpenGL Is Not OpenGL is not a windowing system 16 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  17. Introducing GLUT (GL Utility Toolkit) • Simple cross-platform windowing API • glutInitDisplay(), glutInitWindowSize(..) • Bindings: C, C++, Fortran, Ada, … • Features: • Multiple windows, menus • Keyboard/mouse/other input • Assorted callbacks: idle, timers • Basic font support ‘ • glutSolidTeapot, glutSolidSphere, glutSolidCube, … 17 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  18. Introducing GLUT (GL Utility Toolkit) • Simple cross-platform windowing API • glutInitDisplay(), glutInitWindowSize(..) • Bindings: C, C++, Fortran, Ada, … • Features: • Multiple windows, menus • Keyboard/mouse/other input • Assorted callbacks: idle, timers • Basic font support ‘ • glutSolidTeapot, glutSolidSphere, glutSolidCube, … Other options: glfw, SDL 18 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  19. Introducing GLU (GL Utility) • High-level graphics commands • Not included in OpenGL ES • Some interesting features: • Mapping between world and screen coordinates • Texturing support • Tessellation and other geometric utilities • OpenGL error code lookup • More primitives: spheres, cylinders, disks, … • Camera support: gluLookAt, gluOrtho2D, … 19 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  20. Simple First Program Projection Matrix ! (GL_PROJECTION) 20 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  21. Simple First Program Camera and Model Matrices Combined ! (GL_MODELVIEW) 21 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  22. gluLookAt(eye, at, up) where is the viewpoint? which way is up? where is it pointed? up eye at defines the camera/viewing matrix! 22 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  23. gluPerspective(fovy, aspect, near, far) The Redbook, fig. 3-14 (p. 155) 23 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  24. Transformation Recall 24 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  25. Transformation Recall NDC à Viewport Transformation à Final Image 25 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  26. glViewport(x, y, width, height) width height (x, y) at lower left 26 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  27. Primitive [prim-i-tiv]: A small piece of geometry that can be rendered in OpenGL; e.g. triangles, lines, points etc. 27 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  28. OpenGL Primitive Types http://www.opengl2go.net/wp-content/uploads/2015/10/gl-primitives-with-background.png 28 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  29. OpenGL Primitives (Triangles) 3 6 5 1 2 4 29 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  30. OpenGL Primitives (Triangle Strip) 2 4 5 1 3 30 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  31. OpenGL Primitives (Triangle Strip) 2 4 5 1 3 Immediate Mode (Deprecated) 31 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  32. Color: glColor3f(red,green,blue) v 1 v 3 v 2 32 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  33. GL, GLU, and GLUT notations 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 33 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  34. GL, GLU, and GLUT notations glVertex3f(...) ...3f takes 3 floats ...3d takes 3 doubles ...3i takes 3 integers ...2f takes 2 floats ...4f takes 4 floats (etc) 34 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  35. Composing Transformations glLoadMatrixf(A); glMultMatrixf(B); glMultMatrixf(C); 35 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  36. Convenience Functions • glTranslatef(tx, ty, tz) • glRotatef(degrees, x, y, z) • glScalef(sx, sy, sz) 36 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  37. Hierarchical Modeling translate(0,4) drawTorso() pushMatrix() translate(1.5,0) rotateX(leftHipRotate) drawThigh() pushMatrix() translate(0,-2) rotateX(leftKneeRotate) drawLeg() ... popMatrix() popMatrix() pushMatrix() y translate(0,4) translate(1.5,0) rotateX(leftHipRotate) translate(-1.5,0) rotateX(rightHipRotate) translate(0,4) // Draw the right side x Matrix Stack ... ... CurrentMatrix = translate(0,4) translate(1.5,0) rotateX(leftHipRotate) translate(0,-2) rotate(leftKneeRotate) 37 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  38. OpenGL Matrix Stack 38 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  39. OpenGL 1.x Pipeline (Simplified) http://upload.wikimedia.org/wikipedia/commons/b/bb/Pipeline_OpenGL_%28en%29.png 39 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  40. OpenGL 1.x Pipeline (Unsimplified) http://www.opengl.org/documentation/specs/version1.1/state.pdf 40 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  41. OpenGL 1.x Pipeline (Unsimplified) http://www.opengl.org/documentation/specs/version1.1/state.pdf 41 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  42. Pieces of the Pipeline Stores “subroutines” GLuint boxList; boxList = glGenLists(1); glNewList(boxList, GL_COMPILE); // draw box glEndList(boxList); … glCallList(boxList); 42 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  43. Pieces of the Pipeline Stores “subroutines” 43 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

  44. Pieces of the Pipeline Construct geometric objects 44 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend