2 COEN 290 - Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.

Slides:



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

Chapter 2: Graphics Programming
Computer Graphics CSCE 441
Pemrograman OpenGL Dasar
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Interactive 3D Graphics and Virtual Reality Introduction to OpenGL concepts Session 2.
CSE 494/598 Intro to Applied Computer Graphics Anshuman Razdan DCST AR's Web Page AR's Web Page
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
Introduction to OpenGL M. Ramanathan STTP CAD 2011Introduction to OpenGL.
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.
Chapter 03: Graphics Primitives Course web page: Chapter #3.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 2.
Computer Graphics Bing-Yu Chen National Taiwan University.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Using OpenGL. 2 What is OpenGL? A software interface to graphics hardware It is a Graphics Rendering API (Application Programmer’s Interface) that is.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
CSC 461: Lecture 41 CSC461: Lecture 4 Introduction to OpenGL Objectives: Development of the OpenGL API OpenGL Architecture -- OpenGL as a state machine.
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. 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);
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 4 of 41 William H. Hsu Department of Computing.
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.
CA 302 Computer Graphics and Visual Programming Lecture 2: Introduction to OpenGL Aydın Öztürk
Programming With OpenGL
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
Lecture 2: Introduction to OpenGL
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
CSCE 441: Computer Graphics
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: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
Introduction to OpenGL Muhammad Aamir Khan Lecturer, DCS, UOP.
Introduction to Graphics Programming. Graphics API.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
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.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
CSC Graphics Programming
Introduction to OpenGL (IDE: Eclipse)
The Human Visual System vs The Pinhole camera
Programming with OpenGL Part 1: Background
CS380 Lab Spring Myungbae Son.
Programming with OpenGL Part 1: Background
Introduction to OpenGL
Programming with OpenGL Part 2: Complete Programs
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
Graphics Programming (I)
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
גרפיקה ממוחשבת: מבוא ל-OpenGL
Programming with OpenGL Part 1: Background
Introduction to OpenGL
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
CS297 Graphics with Java and OpenGL
Introduction to OpenGL
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver

3 COEN Computer Graphics I Course Goals n Develop demonstrable skills in Computer Graphics utilizing the necessary mathematics n Demonstrate an understanding of the required programming concepts we’ll be using C / C++ n Have fun doing cool stuff

4 COEN Computer Graphics I Syllabus n Grading programming labs midterm final homework class participation

5 COEN Computer Graphics I Course Texts n Required Interactive Computer Graphics - A top-down approach using OpenGL (2 nd Edition) –by Edward Angel n Recommended The OpenGL Programming Guide (3 rd Edition) –by Mason Woo, Jackie Neider, Tom Davis, Dave Shreiner

6 COEN Computer Graphics I Finding Course Information n Web Site one-stop shopping for information n Alias use this for most correspondence for personal issues

7 COEN Computer Graphics I Your First Assignment n Send an to the class alias with your preferred address(es)

8 COEN Computer Graphics I Evening’s Goals n Introduce many of the concepts that we’ll be discussing over the quarter n Describe the process of 3D modelling n Provide an overview of the rendering library we’ll be using n Set up you for your first assignment

9 COEN Computer Graphics I Motivation for Learning Graphics n Entertainment n Training and Simulation n Art n Publications n Scientific Visualization n Computer Aided Design / Engineering

10 COEN Computer Graphics I The Essence of Computer Graphics “Figuring out what colors to make those dots on the screen” -me

11 COEN Computer Graphics I The Tools of the Trade n Rendering Primitives n Mathematical Transformations n Graphical Techniques simulating lighting texture mapping shading models

12 COEN Computer Graphics I Rendering Primitives n Geometric primitives points lines polygons n Image primitives

13 COEN Computer Graphics I Mathematical Transformations n Use transformations for moving from one coordinate space to another n The good news only requires multiplication and addition n The bad news its multiplication and addition of matrices

14 COEN Computer Graphics I Mathematical Transformations ( cont. ) n Coordinate spaces we’ll be using model world eye normalized device ( NDC’s ) window screen viewport

15 COEN Computer Graphics I Screen Space n Addressable space of your display device 2 dimensional space n Most often measured in pixels integer addressing (0,0) (0,5) (10,0) (5,0) (0,10) Pixel located at (4,2)

16 COEN Computer Graphics I Framebuffers n Computer memory for storing screen space pixels addresses converted into memory addresses n Pixels can contain different types of information color depth

17 COEN Computer Graphics I Framebuffer Size n Usually measured in bitplanes also referred to as bits per pixel n “Deeper” the pixels, the more information they can hold

18 COEN Computer Graphics I Window Coordinates n Addressable space of your window subset of screen space –2D space measured in pixels controlled by your windowing system

19 COEN Computer Graphics I Rasterization n Process of converting primitives into pixels topic of a future class From this... To (0,0) (0,5) (10,0) (5,0) (0,10)

20 COEN Computer Graphics I What we’ll be using as our Toolbox n Some home-rolled stuff n OpenGL industry standard graphics library available on almost all computing platforms –Unix, Linux, Macintosh, Microsoft Windows n GLUT portable OpenGL windowing library tightly integrated with OpenGL

21 COEN Computer Graphics I OpenGL n Application Programming Interface ( API ) simple procedural interface over 400 calls n Immediate gratification see what you draw immediately also implements “retained” mode n Not photo-realistic meant for interactive applications

22 COEN Computer Graphics I OpenGL’s Rendering Pipeline n OpenGL implements a rendering pipeline rendering is the name for the entire process Application Framebuffer Transform Rasterization Graphics Pipeline

23 COEN Computer Graphics I Quick Introduction to OpenGL Commands n OpenGL and related libraries “Core” OpenGL gl OpenGL Utility Library glu OpenGL Utility Toolkit glut n GLU commands implemented in core GL n GLUT is a freeware library abstracts away dealing with a specific window system

Preliminaries n Header files #include n Link with graphics libraries cc prog.c -lglut -lGLU -lGL -lX11 -lXmu -o prog cl proc.c glut32.lib glu32.lib opengl32.lib \ gdi32.lib user32.lib n GL enumerated types for platform independence GLbyte, GLshort, GLushort, GLint, GLuint, GLsizei, GLfloat, GLdouble, GLclampf, GLclampd, GLubyte, GLboolean, GLenum, GLbitfield n Header files #include n Link with graphics libraries cc prog.c -lglut -lGLU -lGL -lX11 -lXmu -o prog cl proc.c glut32.lib glu32.lib opengl32.lib \ gdi32.lib user32.lib n GL enumerated types for platform independence GLbyte, GLshort, GLushort, GLint, GLuint, GLsizei, GLfloat, GLdouble, GLclampf, GLclampd, GLubyte, GLboolean, GLenum, GLbitfield

25 COEN Computer Graphics I OpenGL Command Syntax glVertex3fv(... ) Number of components 2 - (x,y) 3 - (x,y,z) 4 - (x,y,z,w) Data Type b - byte ub - unsigned byte s - short us - unsigned short i - int ui - unsigned int f - float d - double Vector omit “v” for scalar form glVertex2f( x, y )

26 COEN Computer Graphics I OpenGL Geometric Primitives n All geometric primitives are specified by their vertices GL_QUAD_STRIP GL_TRIANGLE_FAN GL_POINTS GL_LINES GL_LINE_LOOP GL_TRIANGLES GL_TRIANGLE_STRIP GL_QUADS GL_LINE_STRIP GL_POLYGON

27 COEN Computer Graphics I Specifying Primitives n Primitives are described by their vertices n Vertex is a point in space which is used in the construction of a geometric primitive n Described by a homogenous coordinate

28 COEN Computer Graphics I Modeling n Process of À organizing vertices into primitives Á organizing primitives into objects  organizing objects into a scene

29 COEN Computer Graphics I Specifying an OpenGL Vertex n Recall OpenGL specifies geometric primitives by its vertices glVertex3f( x, y, z ); n Different primitives require different numbers of vertices

30 COEN Computer Graphics I Actually Drawing Something... n Here’s an OpenGL sequence to draw a square centered around the origin glBegin( GL_QUADS ); glVertex2f( -0.8, -0.8 ); glVertex2f( 0.8, -0.8 ); glVertex2f( 0.8, 0.8 ); glVertex2f( -0.8, 0.8 ); glEnd();

31 COEN Computer Graphics I Adding Personality to Primitives n State ( or Attributes ) data required for computing colors for primitives n Examples color reflectivity surface texture

32 COEN Computer Graphics I Specifying a Vertex’s Color n Use the OpenGL color command glColor3f( r, g, b ); n Where you specify the color determines how the primitive is shaded points only get one color

33 COEN Computer Graphics I Flat Shading in OpenGL If you issue only one glColor() command per primitive glColor3f( r, g, b ); glBegin( GL_TRIANGLES ); glVertex3fv( v1 ); glVertex3fv( v2 ); glVertex3fv( v3 ); glEnd();

34 COEN Computer Graphics I Gouraud Shading in OpenGL n However, to get Gouraud, issue a color per vertex glBegin( GL_TRIANGLES ); glColor3fv( c1 ); glVertex3fv( v1 ); glColor3fv( c2 ); glVertex3fv( v2 ); glColor3fv( c3 ); glVertex3fv( v3 ); glEnd();

35 COEN Computer Graphics I Hacking Graphics Code n Basics steps in going a graphics program À open a window with proper attributes Á clear the window  change attributes à render stuff  goto  as necessary

36 COEN Computer Graphics I Opening a Window Using GLUT void main( int argc, char** argv ) { glutInitWindowSize( 512, 512 ); glutInitDisplayMode( GLUT_RGBA ); glutCreateWindow( “my window” ); init(); glutDisplayFunc( drawScene ); glutMainLoop(); }

37 COEN Computer Graphics I OpenGL Initalization n We’ll use the init() routine for our one-time OpenGL state initialization call after window has been created, but before first rendering call void init( void ) { glClearColor( 1.0, 0.0, 0.0, 1.0 ); }

38 COEN Computer Graphics I Rendering a Scene void drawScene( void ) { glClear( GL_COLOR_BUFFER_BIT ); glColor3f( 1, 1, 1 ); glRectf( -0.9, -0.9, 0.9, 0.9 ); glFlush(); }

39 COEN Computer Graphics I More of your First Assignment n Do what Brad says...