Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "2 COEN 290 - Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver."— Presentation transcript:

1

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

3 3 COEN 290 - 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 4 COEN 290 - Computer Graphics I Syllabus n Grading programming labs midterm final homework class participation

5 5 COEN 290 - 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 6 COEN 290 - Computer Graphics I Finding Course Information n Web Site http://plunk.org/COEN-290 one-stop shopping for information n Email Alias coen290@plunk.org use this for most correspondence email {grantham,shreiner}@plunk.org for personal issues

7 7 COEN 290 - Computer Graphics I Your First Assignment n Send an email to the class alias with your preferred email address(es) coen290@plunk.org

8 8 COEN 290 - 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 9 COEN 290 - 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 10 COEN 290 - Computer Graphics I The Essence of Computer Graphics “Figuring out what colors to make those dots on the screen” -me

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

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

13 13 COEN 290 - 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 14 COEN 290 - Computer Graphics I Mathematical Transformations ( cont. ) n Coordinate spaces we’ll be using model world eye normalized device ( NDC’s ) window screen viewport

15 15 COEN 290 - 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 16 COEN 290 - 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 17 COEN 290 - 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 18 COEN 290 - 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 19 COEN 290 - 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 20 COEN 290 - 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 21 COEN 290 - 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 22 COEN 290 - 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 23 COEN 290 - 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

24 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 25 COEN 290 - 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 26 COEN 290 - 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 27 COEN 290 - 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 28 COEN 290 - Computer Graphics I Modeling n Process of À organizing vertices into primitives Á organizing primitives into objects  organizing objects into a scene 1 2 6 4 5 3

29 29 COEN 290 - 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 30 COEN 290 - 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 31 COEN 290 - 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 32 COEN 290 - 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 33 COEN 290 - 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 34 COEN 290 - 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 35 COEN 290 - 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 36 COEN 290 - 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 37 COEN 290 - 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 38 COEN 290 - 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 39 COEN 290 - Computer Graphics I More of your First Assignment n Do what Brad says...


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

Similar presentations


Ads by Google