 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.

Slides:



Advertisements
Similar presentations
Programming with OpenGL - Getting started - Hanyang University Han Jae-Hyek.
Advertisements

1Computer Graphics Building Models John Shearer Culture Lab – space 2
Vertex Buffer Objects, Vertex Array Objects, Pixel Buffer Objects.
OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Chapter 2: Graphics Programming
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
Pemrograman OpenGL Dasar
Meshes Dr. Scott Schaefer. 3D Surfaces Vertex Table.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
Open Graphics Library (OpenGL)
CS 480/680 Computer Graphics Course Overview Dr. Frederick C Harris, Jr. Fall 2012.
Modeling. Geometric Models  2D and 3D objects  Triangles, quadrilaterals, polygons  Spheres, cones, boxes  Surface characteristics  Color  Texture.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
CSC 461: Lecture 41 CSC461: Lecture 4 Introduction to OpenGL Objectives: Development of the OpenGL API OpenGL Architecture -- OpenGL as a state machine.
Graphics Architectures & OpenGL API Introduction Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS 480/680 Computer Graphics Programming with Open GL Part 1: Background Dr. Frederick C Harris, Jr. Fall 2011.
Speeding Up Rendering After Deciding What to Draw.
Programming with OpenGL Part 1: Background
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Introduction to Computer Graphics 靜宜大學 資訊工程系 蔡奇偉 副教授
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Introduction to Computer Graphics Ed Angel Professor Emeritus of Computer.
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
CS 480/680 Intro Dr. Frederick C Harris, Jr. Fall 2014.
به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 1: Background Ed Angel Professor Emeritus.
Objectives Introduce simple data structures for building polygonal models -- Vertex lists and Edge lists Introduce simple data structures for building.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
1 Building Models Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley.
GLSL OpenGL Programming and Reference Guides, other sources
Programming with OpenGL Part 0: 3D API. For Further Reading Angel 7 th Ed: –2.2: JavaScript –2.3: OpenGL & WebGL –2.8: fragment & vertex shaders Beginning.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Ed Angel Professor Emeritus of Computer Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
Computer Graphics I, Fall 2010 Building Models.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Programming with OpenGL Part 1: Background
Introduction to OpenGL
Introduction to Computer Graphics with WebGL
Models and Architectures
Introduction to Computer Graphics with WebGL
Building Models Ed Angel
Introduction to Computer Graphics with WebGL
Building Models Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Programming with OpenGL
Programming with OpenGL Part 1: Background
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Building Models Ed Angel Professor Emeritus of Computer Science
Isaac Gang University of Mary Hardin-Baylor
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 2: Complete Programs
Introduction to OpenGL
Presentation transcript:

 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance  Focus on rendering  Omitted windowing and input to avoid window system dependencies 2

 Originally controlled by an Architectural Review Board (ARB)  Members included SGI, Microsoft, Nvidia, HP, 3DLabs, IBM,…….  Now Khronos Group  Was relatively stable (through version 2.5) ▪ Backward compatible ▪ Evolution reflected new hardware capabilities ▪ 3D texture mapping and texture objects ▪ Vertex and fragment programs  Allows platform specific features through extensions 3

 Performance is achieved by using GPU rather than CPU  Control GPU through programs called shaders  Application’s job is to send data to GPU  GPU does all rendering

 Totally shader-based  No default shaders  Each application must provide both a vertex and a fragment shader  No immediate mode  Few state variables  Most 2.5 functions deprecated  Backward compatibility not required

 OpenGL ES  Embedded systems  Version 1.0 simplified OpenGL 2.1  Version 2.0 simplified OpenGL 3.1 ▪ Shader based  WebGL  Javascript implementation of ES 2.0  Supported on newer browsers  OpenGL 4.1 and 4.2  Add geometry shaders and tessellator

8

 Windows only  Advantages  Better control of resources  Access to high level functionality  Disadvantages  New versions not backward compatible  Windows only  Recent advances in shaders are leading to convergence with OpenGL

 Most OpenGL programs have a similar structure that consists of the following functions  main() : ▪ specifies the callback functions ▪ opens one or more windows with the required properties ▪ enters event loop (last executable statement)  init() : sets the state variables ▪ Viewing ▪ Attributes  initShader(): read, compile and link shaders  callbacks ▪ Display function ▪ Input and window functions

 Geometry specified by vertices  Locations in space( 2 or 3 dimensional)  Points, lines, circles, polygons, curves, surfaces  Immediate mode  Each time a vertex is specified in application, its location is sent to the GPU  Old style uses glVertex  Creates bottleneck between CPU and GPU  Removed from OpenGL 3.1

 Put all vertex and attribute data in array  Send array to GPU to be rendered immediately  Almost OK but problem is we would have to send array over each time we need another render of it  Better to send array over and store on GPU for multiple renderings

 Vertices can have many attributes  Position  Color  Texture Coordinates  Application data  A vertex array holds these data  Using types in vec.h point2 vertices[3] = {point2(0.0, 0.0), point2( 0.0, 1.0), point2(1.0, 1.0)};

 Bundles all vertex data (positions, colors,..,)  Get name for buffer then bind  At this point we have a current vertex array but no contents  Use of glBindVertexArray lets us switch between VAOs Glunit abuffer; glGenVertexArrays(1, &abuffer); glBindVertexArray(abuffer);

 Buffers objects allow us to transfer large amounts of data to the GPU  Need to create, bind and identify data  Data in current vertex array is sent to GPU Gluint buffer; glGenBuffers(1, &buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(points), points);

 Once we get data to GLU, we can initiate the rendering with a simple callback  Arrays are buffer objects that contain vertex arrays void mydisplay() { glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLES, 0, 3); glFlush(); }

17 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison- Wesley 2012  Put the geometry in an array  Use pointers from the vertices into this array  Introduce a polygon list x 1 y 1 z 1 x 2 y 2 z 2 x 3 y 3 z 3 x 4 y 4 z 4 x 5 y 5 z 5. x 6 y 6 z 6 x 7 y 7 z 7 x 8 y 8 z 8 P1 P2 P3 P4 P5 v1v7v6v1v7v6 v8v5v6v8v5v6 topology geometry

18 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison- Wesley 2012 void colorcube( ) { quad(0,3,2,1); quad(2,3,7,6); quad(0,4,7,3); quad(1,2,6,5); quad(4,5,6,7); quad(0,1,5,4); } Note that vertices are ordered so that we obtain correct outward facing normals

19 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison- Wesley 2012  The weakness of our approach is that we are building the model in the application and must do many function calls to draw the cube  Drawing a cube by its faces in the most straight forward way used to require  6 glBegin, 6 glEnd  6 glColor  24 glVertex  More if we use texture and lighting

20 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison- Wesley 2012  OpenGL provided a facility called vertex arrays that allows us to store array data in the implementation  Six types of arrays were supported initially  Vertices  Colors  Color indices  Normals  Texture coordinates  Edge flags  Now vertex arrays can be used for any attributes

21 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison- Wesley 2012  Using the same color and vertex data, first we enable glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);  Identify location of arrays glVertexPointer(3, GL_FLOAT, 0, vertices); glColorPointer(3, GL_FLOAT, 0, colors); 3d arraysstored as floats data contiguous data array

22 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison- Wesley 2012  Form an array of face indices  Each successive four indices describe a face of the cube  Draw through glDrawElements which replaces all glVertex and glColor calls in the display callback GLubyte cubeIndices[24] = {0,3,2,1,2,3,7,6 0,4,7,3,1,2,6,5,4,5,6,7,0,1,5,4};

23 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison- Wesley 2012  Old Method:  Problem is that although we avoid many function calls, data are still on client side  Solution:  no immediate mode  Vertex buffer object  Use glDrawArrays glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE, cubeIndices); Draws cube with 1 function call!!

24

25

26

27

 Check out 28