6/10/2015 3:41:00 AM 1 CSE 307 COMPUTER GRAPHICS  OVERVIEW OF GRAPHICS SYSTEMS  GRAPHICS OUTPUT PRIMITIVES  GEOMETRICAL TRANSFORMATIONS  TWO DIMENSIONAL.

Slides:



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

1Computer Graphics Lecture 2 - What is Computer Graphics? John Shearer Culture Lab – space 2
Chapter 2: Graphics Programming
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.
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 What is Computer Graphics? 靜宜大學 資訊工程系 蔡奇偉 副教授
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics February 26, 2007.
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 1: Background Ed Angel Professor of Computer Science, Electrical.
30/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 1: Introduction.
Programming with OpenGL Part 0: 3D API March 1, 2007.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 What is Computer Graphics? Ed Angel Professor of Computer Science, Electrical and Computer.
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
Introduction to Computer Graphics Mohan Sridharan Based on Slides by Edward Angel and Dave Shreiner CS4395: Computer Graphics 1.
CSE40166 (Notre Dame) Computer Graphics Lecture 1 John H Stewman 205C Cushing
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 What is Computer Graphics? Sai-Keung Wong ( 黃世強 ) Computer Science National.
Computer Graphics An Introduction. Computer Graphics 26/9/2008Lecture 12 What’s this course all about? We will cover… Graphics programming and algorithms.
Computer Graphics Bing-Yu Chen National Taiwan University.
Lecture 5 - Programming with OpenGL
Chapter 1 Graphics Systems and Models. What is Computer Graphics? Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media.
CS 480/680 Computer Graphics What is Computer Graphics Dr. Frederick C Harris, Jr.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Prof. Zhang Caiming (张彩明) Dr. Zhou Yuanfeng (周元峰) Shandong University
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.
1 Chapter 1: Graphics Systems and Models Dr. Payne CSCI 3600 North Georgia College & St. Univ.
CSC 461: Lecture 1 1 Lecture 1: Introduction Objectives Explore what computer graphics is about Survey some application areas Introduce a history of computer.
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.
Programming with OpenGL Part 1: Background
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.
Computer Graphics I, Fall : What is Computer Graphics?
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Advanced Computer Graphics September 15, Grading Programming homework Paper study and presentation Final project No written exams.
Scientific Visualization with OpenGL 22 February 2006.
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,
Introduction to OpenGL Week 1 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico CS.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 1: Background Ed Angel Professor Emeritus.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
What is Computer Graphics?. 2 Objectives In this lecture, we explore what computer graphics is about We will give a historical introduction.
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 What is Computer Graphics? Sai-Keung Wong ( 黃世強 ) Computer Science National.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 What is Computer Graphics?
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.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Intro to Computer Graphics and Image Formation Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 Contact Information Wsalhalabi.kau.edu.sa Parts of the slides were adopted from Dr. Barbara Hecker.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Hank Childs, University of Oregon Oct. 28th, 2016 CIS 441/541: Introduction to Computer Graphics Lecture 16: textures.
What is Computer Graphics?
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 1: Background
Computer Graphics - Introduction -
What is Computer Graphics?
INTERACTIVE COMPUTER GRAPHICS
What is Computer Graphics?
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 1: Background
Introduction to OpenGL
What is Computer Graphics?
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 1: Background
Presentation transcript:

6/10/2015 3:41:00 AM 1 CSE 307 COMPUTER GRAPHICS  OVERVIEW OF GRAPHICS SYSTEMS  GRAPHICS OUTPUT PRIMITIVES  GEOMETRICAL TRANSFORMATIONS  TWO DIMENSIONAL VIEWING  THREE DIMENSIONAL VIEWING  PARAMETRIC CURVES  VISIBLE SURFACE DETECTION METHODS  ILLUMINATION MODELS  COMPUTER ANIMATION Narendra V G CSE MIT

6/10/2015 3:41:00 AM 2 Text Book: 1. Donald Hearn, Pauline Baker M., “Computer Graphics with OpenGL”, Pearson Education, 3 rd Edition, (2010) References: 1.Edward Angel, “Interactive Computer Graphics- A top down approach using OpenGL”, Pearson Education, 5 th Edition. 2.Foley J. D., VanDam A., Feiner S. K., Hughes J. F., “Computer Graphics, Principles and Practice”, Addision-Wesley, 2 nd Edition. 3.Malay Pakhira K., “Computer Graphics Multimedia and Animation”, PHI Learning,. 2 nd Edition. 4.Amarendra Sinha N., Arun Udai D., “Computer Graphics”, Tata McGraw Hill publishing. 5.Er. Rajiv Chopra “Computer Graphics”, S. Chand & Company Ltd. 2 nd Edition. Narendra V G CSE MIT

6/10/2015 3:41:00 AM 3 Computer Graphics Applications Narendra V G CSE MIT

Computer Graphics is about animation (films) Major driving force now 6/10/2015 3:41:00 AM4Narendra V G CSE MIT

Games are very important in Computer Graphics 6/10/2015 3:41:00 AM5Narendra V G CSE MIT

Medical Imaging is another driving force Much financial support Promotes linking of graphics with video, scans, etc. 6/10/2015 3:41:00 AM6Narendra V G CSE MIT

Computer Aided Design too 6/10/2015 3:41:00 AM7Narendra V G CSE MIT

Scientific Visualisation To view below and above our visual range 6/10/2015 3:41:00 AM8Narendra V G CSE MIT

Graphics Pipelines Graphics processes generally execute sequentially Typical ‘pipeline’ model There are two ‘graphics’ pipelines – The Geometry or 3D pipeline – The Imaging or 2D pipeline 6/10/2015 3:41:00 AM9Narendra V G CSE MIT

6/10/2015 3:41:00 AM 10 Computer Graphics ? Narendra V G CSE MIT

Computer Graphics Computer graphics deals with all aspects of creating images with a computer – Hardware – Software – Applications 11 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Example Where did this image come from? What hardware/software did we need to produce it? 12 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Preliminary Answer Application: The object is an artist’s rendition of the sun for an animation to be shown in a domed environment (planetarium) Software: Maya for modeling and rendering but Maya is built on top of OpenGL Hardware: PC with graphics card for modeling and rendering 13 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Basic Graphics System 14 Input devices Output device Image formed in FB 6/10/2015 3:41:00 AMNarendra V G CSE MIT

CRT Can be used either as a line-drawing device (calligraphic) or to display contents of frame buffer (raster mode) 15 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Computer Graphics: Computer graphics goes back to the earliest days of computing – Strip charts – Pen plotters – Simple displays using A/D converters to go from computer to calligraphic CRT Cost of refresh for CRT too high – Computers slow, expensive, unreliable 16 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Computer Graphics: Wireframe graphics – Draw only lines Sketchpad Display Processors Storage tube 17 wireframe representation of sun object 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Sketchpad Ivan Sutherland’s PhD thesis at MIT – Recognized the potential of man-machine interaction – Loop Display something User moves light pen Computer generates new display – Sutherland also created many of the now common algorithms for computer graphics 18 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Display Processor Rather than have the host computer try to refresh display use a special purpose computer called a display processor (DPU) Graphics stored in display list (display file) on display processor Host compiles display list and sends to DPU 19 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Direct View Storage Tube Created by Tektronix – Did not require constant refresh – Standard interface to computers Allowed for standard software Plot3D in Fortran – Relatively inexpensive Opened door to use of computer graphics for CAD community 20 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Computer Graphics: Raster Graphics Beginning of graphics standards – IFIPS GKS: European effort – Becomes ISO 2D standard Core: North American effort – 3D but fails to become ISO standard Workstations and PCs 21 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Raster Graphics Image produced as an array (the raster) of picture elements (pixels) in the frame buffer 22 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Raster Graphics Allows us to go from lines and wire frame images to filled polygons 23 6/10/2015 3:41:00 AMNarendra V G CSE MIT

PCs and Workstations Although we no longer make the distinction between workstations and PCs, historically they evolved from different roots – Early workstations characterized by Networked connection: client-server model High-level of interactivity – Early PCs included frame buffer as part of user memory Easy to change contents and create images 24 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Computer Graphics: Realism comes to computer graphics 25 smooth shadingenvironment mapping bump mapping 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Computer Graphics: Special purpose hardware – Silicon Graphics geometry engine VLSI implementation of graphics pipeline Industry-based standards – PHIGS – RenderMan Networked graphics: X Window System Human-Computer Interface (HCI) 26 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Computer Graphics: OpenGL API Completely computer-generated feature- length movies (Toy Story) are successful New hardware capabilities – Texture mapping – Blending – Accumulation, stencil buffers 27 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Computer Graphics: Photorealism Graphics cards for PCs dominate market – Nvidia, ATI Game boxes and game players determine direction of market Computer graphics routine in movie industry: Maya, Lightwave Programmable pipelines 28 6/10/2015 3:41:00 AMNarendra V G CSE MIT

Graphics Definitions Point – a location in space, 2D or 3D – sometimes denotes one pixel Line – straight path connecting two points – infinitesimal width, consistent density – beginning and end on points 6/10/2015 3:41:00 AM29Narendra V G CSE MIT

Graphics Definitions Vertex – point in 3D Edge – line in 3D connecting two vertices Polygon/Face/Facet – arbitrary shape formed by connected vertices – fundamental unit of 3D computer graphics 6/10/2015 3:41:00 AM30Narendra V G CSE MIT

Graphics Definitions Raster – derived from TV systems for a row of pixels – commonly referred to as a scanline – does influence algorithms – reducing memory requirements, parallelism, etc. – is the derivation of rasterization, scan-line algorithms 6/10/2015 3:41:00 AM31Narendra V G CSE MIT

Summary The course is about algorithms, not applications Graphics execution is a pipelined approach Basic definitions presented 6/10/2015 3:41:00 AM32Narendra V G CSE MIT

Programming with OpenGL Basics

Objectives Development of the OpenGL API OpenGL Architecture – OpenGL as a state machine Functions – Types – Formats Simple program Narendra V G CSE MIT 34 6/10/2015 3:41:00 AM

Early History of APIs IFIPS (1973) formed two committees to come up with a standard graphics API – Graphical Kernel System (GKS) 2D but contained good workstation model – Core Both 2D and 3D – GKS adopted as IS0 and later ANSI standard (1980s) GKS not easily extended to 3D (GKS-3D) – Far behind hardware development Narendra V G CSE MIT 35 6/10/2015 3:41:00 AM

PHIGS and X Programmers Hierarchical Graphics System (PHIGS) – Arose from CAD community – Database model with retained graphics (structures) X Window System – DEC/MIT effort – Client-server architecture with graphics PEX combined the two – Not easy to use (all the defects of each) Narendra V G CSE MIT 36 6/10/2015 3:41:00 AM

SGI and GL Silicon Graphics (SGI) revolutionized the graphics workstation by implementing the pipeline in hardware (1982) To access the system, application programmers used a library called GL With GL, it was relatively simple to program three dimensional interactive applications Narendra V G CSE MIT 37 6/10/2015 3:41:01 AM

OpenGL 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 Narendra V G CSE MIT 38 6/10/2015 3:41:01 AM

OpenGL Evolution Originally controlled by an Architectural Review Board (ARB) – Members included SGI, Microsoft, Nvidia, HP, 3DLabs, IBM,……. – Relatively stable (present version 2.1) Evolution reflects new hardware capabilities – 3D texture mapping and texture objects – Vertex programs – Allows for platform specific features through extensions – ARB replaced by Kronos Narendra V G CSE MIT 39 6/10/2015 3:41:01 AM

OpenGL Libraries OpenGL core library – OpenGL32 on Windows – GL on most unix/linux systems (libGL.a) OpenGL Utility Library (GLU) – Provides functionality in OpenGL core but avoids having to rewrite code Links with window system – GLX for X window systems – WGL for Windows – AGL for Macintosh Narendra V G CSE MIT 40 6/10/2015 3:41:01 AM

GLUT OpenGL Utility Toolkit (GLUT) – Provides functionality common to all window systems Open a window Get input from mouse and keyboard Menus Event-driven – Code is portable but GLUT lacks the functionality of a good toolkit for a specific platform No slide bars Narendra V G CSE MIT 41 6/10/2015 3:41:01 AM

Software Organization Narendra V G CSE MIT 42 GLUT GLU GL GLX, AGL or WGL X, Win32, Mac O/S software and/or hardware application program OpenGL Motif widget or similar 6/10/2015 3:41:01 AM

OpenGL Architecture Narendra V G CSE MIT 43 Immediate Mode Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Texture Memory CPU Pixel Operations Frame Buffer geometry pipeline 6/10/2015 3:41:01 AM

OpenGL Functions Primitives – Points – Line Segments – Polygons Attributes Transformations – Viewing – Modeling Control (GLUT) Input (GLUT) Query Narendra V G CSE MIT 44 6/10/2015 3:41:01 AM

OpenGL State OpenGL is a state machine OpenGL functions are of two types – Primitive generating Can cause output if primitive is visible How vertices are processed and appearance of primitive are controlled by the state – State changing Transformation functions Attribute functions Narendra V G CSE MIT 45 6/10/2015 3:41:01 AM

Lack of Object Orientation OpenGL is not object oriented so that there are multiple functions for a given logical function – glVertex3f – glVertex2i – glVertex3dv Underlying storage mode is the same Easy to create overloaded functions in C++ but issue is efficiency Narendra V G CSE MIT 46 6/10/2015 3:41:01 AM

OpenGL function format Narendra V G CSE MIT 47 glVertex3f(x,y,z) belongs to GL library function name x,y,z are floats glVertex3fv(p) p is a pointer to an array dimensions 6/10/2015 3:41:01 AM

OpenGL #defines Most constants are defined in the include files gl.h, glu.h and glut.h – Note #include should automatically include the others – Examples – glBegin(GL_POLYGON) – glClear(GL_COLOR_BUFFER_BIT) include files also define OpenGL data types: GLfloat, GLdouble,…. Narendra V G CSE MIT 48 6/10/2015 3:41:01 AM

A Simple Program Generate a square on a solid background Narendra V G CSE MIT 49 6/10/2015 3:41:01 AM

simple.c Narendra V G CSE MIT 50 #include void mydisplay(){ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } int main(int argc, char** argv){ glutCreateWindow("simple"); glutDisplayFunc(mydisplay); glutMainLoop(); } 6/10/2015 3:41:01 AM

Event Loop Note that the program defines a display callback function named mydisplay – Every glut program must have a display callback – The display callback is executed whenever OpenGL decides the display must be refreshed, for example when the window is opened – The main function ends with the program entering an event loop Narendra V G CSE MIT 51 6/10/2015 3:41:01 AM

Defaults simple.c is too simple Makes heavy use of state variable default values for – Viewing – Colors – Window parameters Next version will make the defaults more explicit Narendra V G CSE MIT 52 6/10/2015 3:41:01 AM

Notes on compilation See website and ftp for examples Unix/linux – Include files usually in …/include/GL – Compile with –lglut –lGLU –lGL loader flags – May have to add –L flag for X libraries – Mesa implementation included with most linux distributions – Check web for latest versions of Mesa and glut Narendra V G CSE MIT 53 6/10/2015 3:41:01 AM

Compilation on Windows Visual C++ – Get glut.h, glut32.lib and glut32.dll from web – Create a console application – Add opengl32.lib, glut32.lib, glut32.lib to project settings (under link tab) Borland C similar Cygwin (linux under Windows) – Can use gcc and similar makefile to linux – Use –lopengl32 –lglu32 –lglut32 flags Narendra V G CSE MIT 54 6/10/2015 3:41:01 AM

To display window and line segment #include void init (void) { glClearColor(1.0,1.0,1.0,0.0) ;//set display-window color to white glMatrixMode(GL_PROJECTION); //set projection parameter gluOrtho2D(0.0,200.0,0.0,150.0); } void lineSegment(void) { glClear(GL_COLOR_BUFFER_BIT); //clear display window glColor3f(1.0,0.0,0.0); //set line segment color to red glBegin(GL_LINES); glVertex2i(180,15); //specify line-segment geometry glVertex2i(10,145); glEnd(); glFlush(); } 6/10/2015 3:41:01 AMNarendra V G CSE MIT 55

void main(int argc, char** argv) { glutInit(&argc, argv); // Initialize GLUT glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); //set display mode glutInitWindowPosition(50,100); //set top-left display window position glutInitWindowSize(400,300); //set display window width and height glutCreateWindow(“An Example OpenGL Program”); //create dis-win init( ); //Execute initialization procedure glutDisplayFunc(lineSegment); //send graphics to display window glutMainLoop( );//Display everything and wait } 6/10/2015 3:41:01 AMNarendra V G CSE MIT 56 To display window and line segment