Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.

Slides:



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

Computer Graphics - Graphics Programming -
Department of nskinfo i-education
School of Computer Science University of Seoul. How can we create a window? How can we handle the events? What kind of objects can we render? How can.
Lecture 3 Graphics Pipeline and Graphics Software
©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
Computer Graphics CSCE 441
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Pemrograman OpenGL Dasar
© 2004, Tom Duff and George Ledin Jr1 Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma.
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
What is OpenGL? Low level 2D and 3D Graphics Library Competitor to Direct3D (the rendering part of DirectX) Used in: CAD, virtual reality, scientific.
Computer Graphics (Fall 2008) COMS 4160, Lecture 9: OpenGL 1
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
Computer Graphics (Fall 2003) COMS 4160, Lecture 6: OpenGL 2 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphics (Fall 2005) COMS 4160, Lecture 10: OpenGL 1
CENG477 Introduction to Computer Graphics Introduction to OpenGL, GLUT and GLUI.
Introduction to OpenGL Jian Huang This set of slides are extracted from the Interactive OpenGL Programming course given by Dave Shreine, Ed Angel and Vicki.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 2.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 GLUT Callback functions Event-driven: Programs that use windows  Input/Output  Wait until an event happens and then execute some pre-defined functions.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
Using OpenGL in Visual C++ Opengl32.dll and glu32.dll should be in the system folder Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib.
Lecture 3 OpenGL.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 6: OpenGL 1
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
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 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 Computer Graphics Programming with OpenGL I.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
Graphics: Conceptual Model
CSCE 441: Computer Graphics
Introduction to OpenGL Programming
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
CS552: Computer Graphics Lecture 6: Viewing in 2D.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
Introduction to Graphics Programming. Graphics API.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Introduction to Graphics Programming. Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL: Event-driven How in OpenGL? Programmer registers callback functions Callback function called when.
INTRODUCTION TO OPENGL
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
The Human Visual System vs The Pinhole camera
Draw a Simple Object.
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
גרפיקה ממוחשבת: מבוא ל-OpenGL
Rendering Pipeline, OpenGL/GLUT
Introduction to OpenGL
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys

Introduction to OpenGL OpenGL is a graphics API –Software library –Layer between programmer and graphics hardware (and software) OpenGL can fit in many places –Between application and graphics system –Between higher level API and graphics system

Programmer’s View Application Graphics PackageApplication OpenGL Application Programming Interface Hardware and software Output Device Input Device

Why OpenGL? Fast Simple Window system independent Supports some high-end graphics features Geometric and pixel processing Standard, available on many platforms

OpenGL As a Renderer Renders simple geometric primitives –Points, lines, polygons Renders images and bitmaps Separate pipelines for geometry and pixel processing, linked through texture mapping The output of the renderer depends on state –Current color, light sources, current material, current texture, current normal, etc

OpenGL Buffers OpenGL supports a variety of buffers that can be used for rendering –Color buffers (front, back, left, right) –Depth buffer (used to store z information) –Accumulation buffer –Stencil buffer Window system interactions must be handled outside of OpenGL –GLUT –Motif –GLX –Tcl/TK –…

OpenGL Primitives Points Lines Polygon Triangle Quad Quad Strip Triangle StripTriangle Fan

GLUT 3D Primitives Cube Sphere Teapot And others…

Simple OpenGL Program #include void display(void) { glClearColor( 0, 0, 0, 0 ); glClear( GL_COLOR_BUFFER_BIT ); glColor3f( 1, 1, 1 ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( -1, 1, -1, 1, -1, 1 ); glBegin( GL_POLYGON ); glVertex2f( -.5, -.5 ); glVertex2f( -.5,.5 ); glVertex2f(.5,.5 ); glVertex2f(.5, -.5 ); glEnd(); glFlush(); }

Window System Glue int main( int argc, char *argv[] ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB ); glutInitWindowSize( 250, 250 ); glutCreateWindow( “We love COMS 4160” ); glutDisplayFunc( display ); glutMainLoop(); }

OpenGL Rendering Pipeline Geometry Primitive Operations Pixel Operations Scan Conversion Texture Memory Fragment Operations Framebuffer Vertices Images

Viewing consists of two parts –Object positioning: model view transformation matrix –View projection: projection transformation matrix OpenGL supports both perspective and orthographic viewing transformations OpenGL’s camera is always at the origin, pointing in the –z direction Transformations move objects relative to the camera Viewing in OpenGL

Outline Introduction (Chapter 1) Geometry, Drawing (Chapter 2) Transformations, Viewing (Chapter 3) Color, Types (Chapter 4) Lighting (Chapter 5) Putting it all together… Textures (Chapter 9) Display Lists, Vertex Arrays, etc. (Chapter 7) Advanced Topics, Extensions Rest of red book should be read…

Introduction (Chapter 1) Examples (color plates) Code sample (page 6) OpenGL as a state machine OpenGL Rendering pipeline (page 11) –Geometry: Points, lines, polygons, GLUT primitives –Pixels: Images, Bitmaps –Texture Mapping –Depends on state (color, material, texture, etc.) Animation, Double Buffering –Buffers: Color (front, back); Depth (z); Accumulation; Stencil

Drawing (Chapter 2) glClearColor(red, green, blue, alpha) [0,0,0,0] glClear (GL_COLOR_BUFFER_BIT) –Other buffers… glColor3f (r,g,b) Draw (assembly line: Transform, clip, shade, …) –Client/Server glFlush() (forces client to send network packet) –Doesn’t wait for completion; only begins execution –Previous commands execute in finite time glFinish() (waits for ack that drawing complete) –Synchronization, sparing use

Window System Interaction Not part of OpenGL Toolkits (GLUT) available Callback functions for events –Keyboard, Mouse, etc. –Open, initialize, resize window –Similar to other systems (X, Java, etc.) Menus, Animation etc. Typical main function (pp 100)

Geometry Points (GL_POINTS) –Stored in Homogeneous coordinates Line segments (GL_LINES) Polygons –Simple, convex (take your chances with concave) –Tessellate, GLU for complex shapes –Rectangles: glRect Special cases (strips, loops, triangles, fans, quads) –Pages 44, 45 More complex primitives (GLUT): Sphere, teapot, cube,…

Specifying Geometry glBegin(GL_POLYGON) ; // Page 43 –glVertex2f –glColor, glIndex, glNormal, glTexCoord, … (pp 47) –glMaterial, glArrayElement, glEvalCoord, … (pp 48) –Other GL commands invalid between begin and end Can write normal C code… glEnd() ; Examples: pp 48,49