©Zachary Wartell, UNCC9/28/2006 11:30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.

Slides:



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

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.
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
Chapter 2: Graphics Programming
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
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.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
OPENGL Return of the Survival Guide. Buffers (0,0) OpenGL holds the buffers in a coordinate system such that the origin is the lower left corner.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Pemrograman OpenGL Dasar
 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.
Buffers Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Buffers Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
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.
CMPE 466 COMPUTER GRAPHICS
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
 Bitmap: A bitmap is a rectangular array of 0s and 1s that serves as a drawing mask for a corresponding rectangular portion of the window.  Applications:
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
Speeding Up Rendering After Deciding What to Draw.
2002 by Jim X. Chen: 1 So far, we only concerned with the rendering of geometric data. Two other important classes of data:
Programming with OpenGL Part 1: Background
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
CSE 690: GPGPU Lecture 6: Cg Tutorial Klaus Mueller Computer Science, Stony Brook University.
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Review of OpenGL Basics
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
OpenGL Architecture Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Frame Buffer Texture.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Programming With OpenGL
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
Buffers Computer Graphics I, Fall 2010.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
Introduction to Graphics Programming. Graphics API.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL: Event-driven How in OpenGL? Programmer registers callback functions Callback function called when.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Buffers Ed Angel Professor Emeritus of Computer Science
Draw a Simple Object.
Computer Graphics Lecture 32
Chapter 6 GPU, Shaders, and Shading Languages
Models and Architectures
Geb Thomas Adapted from the OpenGL Programming Guide
Introduction to OpenGL
Computer Graphics Buffers
Buffers Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights Reserved

©Zachary Wartell, UNCC9/28/ :30 AM 2 Graphics APIs Generally these API’s support both 2D and 3D graphics: ●GKS (Graphics Kernal System) ●PHIGS (Programmer Hierarchical Interactive Graphics Standard) ●PHIGS+ ●GL (Graphics Library) by SGI ●OpenGL ●DirectDraw, Direct3D by Microsoft

©Zachary Wartell, UNCC9/28/ :30 AM 3 OpenGL ●OpenGL – hardware independent, only specifies graphics output low level, no GUI operations (events, windows, menu’s) ●OpenGL Utility (GLU) – higher level graphics primitives (spheres, curves, curved surfaces) ●OpenGL Utility Toolkit (GLUT) – primitive window setup & event handling

©Zachary Wartell, UNCC9/28/ :30 AM 4 OpenGL Block Diagram input commands –vertex coordinates and vertex attributes –pixel blocks –state changes (affects how input data is rendered) output commands –read current state, read framebuffer, etc. commands

©Zachary Wartell, UNCC9/28/ :30 AM 5 OpenGL Basic Syntax (C Language Binding) ●Functions: glXXXX – glBegin, glEnd, glPolygonMode ●Constants: GL_XXXX – GL_2D, GL_RGB, GL_CCW ●Types: GLxxx – GLbyte, GLshort, GLint, GLfloat, GLdouble, GLboolean

©Zachary Wartell, UNCC9/28/ :30 AM 6 OpenGL Geometric Output Primitives ●Types: GL_POINTS, GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_POLYGON, GL_QUADS, GL_QUAD_STRIP, GL_TRIANGLE, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN ●Basic Syntax: glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); glVertex(2|3|4)(s|i|d|f)[v]

©Zachary Wartell, UNCC9/28/ :30 AM 7 OpenGL: A State Machine OpenGL state remains in effect until it is changed Examples: current - color, viewing/projection transforms, line/polygon fill pattern, light positions, etc, etc, etc.. Each state variable has default value and can be queried (glGetIntegerv, glGetFloatv, etc.) and enabled/disable collections of state can also be saved (glPushAttrib,glPopAttrib) commands

©Zachary Wartell, UNCC9/28/ :30 AM 8 Display Lists immediate vs retained mode display list can collect geometry and attributes to be stored for later use; allows optimizations display list are write-only; no other structure within objects (OpenInventor, Java3D, VRML, etc.) commands

©Zachary Wartell, UNCC9/28/ :30 AM 9 Evaluators (3D stuff) a set of functions that generates vertex coordinates lying on various types of curves surfaces uses polynomial mapping. Can produce surface normals, texture coordinates, colors, vertex coordinates given a set of control points commands

©Zachary Wartell, UNCC9/28/ :30 AM 10 Per-Vertex Operations vertices are transformed by 4x4 matrices (model&view, projection) in preparation for primitive assembly texture coordinates can be directly specified or generated and also transformed lighting calculations are also performed with transformed vertex and normals based on lighting attributes commands

©Zachary Wartell, UNCC9/28/ :30 AM 11 Primitive Assembly points, lines, polygon edges are clipped and transformed to window coordinates resulting primitives are then passed to rasterization stage commands

©Zachary Wartell, UNCC9/28/ :30 AM 12 Points & Lines v0 v1 v2 v3 glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); v0 v1 v2 v3 v4 v5 GL_POINTS GL_LINES GL_LINE_STRIP v0 v1 v2 v3 v4 GL_LINE_LOOP

©Zachary Wartell, UNCC9/28/ :30 AM 13 Polygons glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); GL_POLYGON v0 v1 v2 v3 v4 v0 v1 v2 v3 v4 v5 v6 v7 GL_QUADS v0 v1 v2 v3 v4 v5 v6 v7 GL_QUAD_STRIP

©Zachary Wartell, UNCC9/28/ :30 AM 14 ©Zachary Wartell - 1/26/2005 Polygons (2) glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); v0 v1 v2 v3 v4 v5 GL_TRIANGLES GL_TRIANGLE_STRIP v0 v1 v2 v3 v4 v5 GL_TRIANGLE_FAN v0 v1 v2 v3 v4 v5 N vertices N/3 Triangles N+2 vertices N Triangles N+2 vertices N Triangles

©Zachary Wartell, UNCC9/28/ :30 AM 15 Why glBegin/glEnd? ● trying to define a separate function for each possible combinations of vertex data too cumbersome: glBegin (PrimitiveConstant); glColor3f (c1,c1,c1) glTexCoord2f(t1,t2) glVertex3f (x1,y1,z1) glColor3i (c1,c2,c3) glNormal3f (n1,n2,n3) glVertex3f (x2,y2,z2) …. glEnd(); -vertex uses last specified color/normal/texCoord. Allows application to avoid redundant specification, but every app. may want different combinations -Also lots of combinations of (s|i|f|d)[v] especially when combined with all possible combinations of glColor ×glTexCoord × glNormal × glVertex

©Zachary Wartell, UNCC9/28/ :30 AM 16 Why glBegin/glEnd? ● allow maximum possible parallelism in host CPU and Graphics Processor glBegin (PrimitiveConstant); compute x1,y1,z1 coordinate glVertex3f (x1,y1,z1) compute x2,y2,z2 coordinate glVertex3f (x2,y2,z2) …. glEnd(); CPU to GP communication and GP processing of x1,y1,z1 can potentially occur while CPU does this

©Zachary Wartell, UNCC9/28/ :30 AM 17 Vertex Arrays ● downside of glBegin/glEnd is lots of function calls ●OpenGL Vertex Arrays -drastically reduce function call overhead -support most common combinations of vertex data -allow sharing of vertex coordinates for adjacent primitives glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer ( 3 /* N-coordinates */, GL_FLOAT /* coordinate type */, 0 /* stride */, vertex_coordinates); glDrawElements (GL_QUADS /* primitive type */, 24, /* number of vertices */ GL_UNSIGNED_BYTE, /* type of index value */ vertex_indices ); -void* parameter, actual type determined by 3 rd parameter

©Zachary Wartell, UNCC9/28/ :30 AM 18 Pixel Operations pixels packed or unpacked into RGB(A) components; also may be scaled, biased or transformed results are clamped and sent to texture memory OR rasterization pixel data also can be read from framebuffer commands

©Zachary Wartell, UNCC9/28/ :30 AM 19 Pixel-Array Primitives glBitmap (width, height, x0, y0, xOffset, yOffset, bit_array) ● width, height - size of bit map to draw (in last specified color) ●x0, y0 – defines window coordinate of lower-left corner of bit_array ● xOffset, yOffset – added to current raster position (see glRasterPos2i); useful for text output ● bit_array – bits encode in unsigned byte array

©Zachary Wartell, UNCC9/28/ :30 AM 20 glBitmap Figure 3-61: Hearn & Baker

©Zachary Wartell, UNCC9/28/ :30 AM 21 glDrawPixels glDrawPixels (width, height, dataFormat, dataType, pixel_array) ● width, height - size of pixel array map to draw ●dataFormat – GL_RGB,GL_RED, GL_RGBA, GL_DEPTH_COMPONENT, etc. ●dataType – GL_UNSIGNED_BYTE, GL_BYTE, etc. ●pixel_array – memory encoding data -data write to current raster position (glRasterPos)

©Zachary Wartell, UNCC9/28/ :30 AM 22 OpenGL Raster Operations ●raster operations, bitblt’s (bit-block transfers), pixblt’s ● glReadPixels (xmin, ymin, width, height, dataFormat, dataType, pixel_array) -reads pixel data from framebuffer to main memory -xmin, ymin, width, height – rectangle in framebuffer to read -dataFormat – GL_RGB,GL_RED, GL_RGBA, GL_DEPTH_COMPONENT, etc. -dataType – GL_UNSIGNED_BYTE, GL_BYTE, etc. -pixel_array – memory encoding data ●glCopyPixels – from glReadBuffer to glDrawBuffer

©Zachary Wartell, UNCC9/28/ :30 AM 23 Texture Assembly Textures (images + lots of texture rendering options) can be bound to texture objects; then you can switch between texture objects Multiple textures layers commands

©Zachary Wartell, UNCC9/28/ :30 AM 24 Rasterization scan convert coordinate primitives (lines, polygons, etc.) or pixel data into fragments fragment is pixel color + depth value + stencil + accumulation commands

©Zachary Wartell, UNCC9/28/ :30 AM 25 Fragment Operations sequence of operations that may discard fragment blending, dithering, logic combination (and/or/xor) commands

©Zachary Wartell, UNCC9/28/ :30 AM 26 Revisions Revision 1.1: 1.typos 2.Added copyright 3.formatted master Slide 1.Revision added GL pipeline slides