Presentation is loading. Please wait.

Presentation is loading. Please wait.

2003CS Hons RW778 Graphics1 Chapter 1: Introduction Admin: Admin: –Lecture slots: Monday 8-9:45, Tuesday 9:15-11:00. –Book: F. Hill, Computer Graphics.

Similar presentations


Presentation on theme: "2003CS Hons RW778 Graphics1 Chapter 1: Introduction Admin: Admin: –Lecture slots: Monday 8-9:45, Tuesday 9:15-11:00. –Book: F. Hill, Computer Graphics."— Presentation transcript:

1 2003CS Hons RW778 Graphics1 Chapter 1: Introduction Admin: Admin: –Lecture slots: Monday 8-9:45, Tuesday 9:15-11:00. –Book: F. Hill, Computer Graphics Using OpenGL (Little Big Bookstore) –Evaluation: 3hr closed book, 8 th week (50%) + weekly pracs (50%) –Pracs: Windows or Linux, OpenGL. CAREFUL when using 3D Studio Max. –This is a fun course, but also a LOT of hard work.

2 2003CS Hons RW778 Graphics2 Chapter 1 : Introduction Week 1: Introduction and OpenGL (Hill, Ch. 1,2). Week 1: Introduction and OpenGL (Hill, Ch. 1,2). Week 2: Windows and viewports; vector tools (Hill, Ch. 3,4). Week 2: Windows and viewports; vector tools (Hill, Ch. 3,4). Week 3: Vector tools (continued) (Hill, Ch. 4). Week 3: Vector tools (continued) (Hill, Ch. 4). Week 4: Transformations on objects (Hill, Ch. 5). Week 4: Transformations on objects (Hill, Ch. 5). Week 5: Polygonal meshes (Hill, Ch. 6). Week 5: Polygonal meshes (Hill, Ch. 6). Week 6: 3D viewing (Hill, Ch. 7). Week 6: 3D viewing (Hill, Ch. 7). Week 7: Lighting and face realism (Hill, Ch. 8). Week 7: Lighting and face realism (Hill, Ch. 8). Week 8: Exam Wednesday 09:00 Week 8: Exam Wednesday 09:00

3 2003CS Hons RW778 Graphics3 Chapter 1: Introduction 1.1 What is computer graphics (CG)? 1.1 What is computer graphics (CG)? –Simply pictures –Tools –Field of study 1.2 Where is CG used? 1.2 Where is CG used? –Art, entertainment, publishing –Image processing –Process monitoring, simulations, CAD –Scientific visualization

4 2003CS Hons RW778 Graphics4 Chapter 1: Introduction 1.3 Elements of pictures created in CG 1.3 Elements of pictures created in CG –Output primitives and attributes: »Polylines »Text »Filled regions »Raster images –1.3.1 Polylines »Connected sequence of straight lines

5 2003CS Hons RW778 Graphics5 Chapter 1: Introduction »Edge, vertex, polygon, simple polygon »Attributes: color, thickness, dashing, endpoint blending

6 2003CS Hons RW778 Graphics6 Chapter 1: Introduction –1.3.2 Text »Font, color, size, spacing, orientation »Tilting (graphs) –1.3.3 Filled regions » Filled shape – boundary (polygon) » Filling used for shadow effects

7 2003CS Hons RW778 Graphics7 Chapter 1: Introduction –1.3.4 Raster image »Consists of cells (called pixels) with color value »Stored as array of numerical values »Bitmap : 0-1 »Created as hand-designed, or computed, or scanned. »Computed: straight lines – “jaggies” »Easy manipulation (filters, cleanup)

8 2003CS Hons RW778 Graphics8 Chapter 1: Introduction –1.3.5 Shades of gray and color in raster images »Pixel depth : n bits => 2 n values (at least 256) »Smaller pixel depth => loss in quality. Banding. »Color: RGB »Color depth => sum of bits for each color »High quality (true color) : 24 bits (eye perception) 1.4 Graphics Display Devices 1.4 Graphics Display Devices –1.4.1 Line drawing (plotters): cross-hatching

9 2003CS Hons RW778 Graphics9 Chapter 1: Introduction –1.4.2 Raster displays (video monitor, flat-panel displays, printers) »Display surface (X,Y) »Frame buffer : memory to hold display pixels, with scan controller.

10 2003CS Hons RW778 Graphics10 Chapter 1: Introduction »Some hardware (video monitor) requires “refresh” : entire frame buffer scanned out to display many times per second.

11 2003CS Hons RW778 Graphics11 Chapter 1: Introduction »Video monitors : CRT CRT Digital-to-analog converters (DACs) Digital-to-analog converters (DACs) Refresh 60x per second to prevent flicker. Refresh 60x per second to prevent flicker. Scanning per line Scanning per line

12 2003CS Hons RW778 Graphics12 Chapter 1: Introduction –1.4.3 Indexed Color and the LUT »Programmable association between pixel value and color »Bits in frame buffer acts as index into LUT. »Palette: set of possible colors AT ONE TIME. –1.4.4 Other raster display devices: flat-panel, LCD, active matrix panels, plasma panel –1.4.5 Hard-copy raster devices: film recorder, laser printer, inkjet plotter. PostScript. 1.5 Graphics input primitives and devices 1.5 Graphics input primitives and devices –Selfstudy.

13 2003CS Hons RW778 Graphics13 Chapter 2: Drawing in OpenGL 2.1 Getting started 2.1 Getting started –Environment: window, coordinate system, elementary drawing routines –2.1.1 Device-independence and OpenGL »Libraries –2.1.2 Windows-based Programming »Event-driven, event queue and callbacks »System-dependent (glut) »Example: Fig. 2.2

14 2003CS Hons RW778 Graphics14 Chapter 2: Drawing in OpenGL #include #include // >>>>>>>>>>>>>>>>>>>>> void main(int argc, char** argv) { // initialize // create screen window glutDisplayFunc (myDisplay); glutMouseFunc (myMouse); glutKeyboardFunc (myKeyboard); glutMainLoop(); // go into a perpetual loop }

15 2003CS Hons RW778 Graphics15 Chapter 2: Drawing in OpenGL –2.1.3 Opening a window for drawing (framework) #include #include // >>>>>>>>>>>>>>>>>>>>> void main(int argc, char** argv) { glutInit(&argc, argv); // initialize the toolkit glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode glutInitWindowSize(640,480); // set window size glutInitWindowPosition(100, 150); // set window position on screen glutCreateWindow("my first attempt"); // open the screen window glutDisplayFunc(myDisplay); // register redraw function myInit(); glutMainLoop(); // go into a perpetual loop }

16 2003CS Hons RW778 Graphics16 Chapter 2: Drawing in OpenGL 2.2 Drawing basic graphics primitives 2.2 Drawing basic graphics primitives –Establish coordinate system –Line drawing primitives : glBegin, glEnd, vertices –Example: glBegin (GL_POINTS); glVertex2i(100,50);glVertex2i(100,130);glVertex2i(150,130);glEnd(); -OpenGL commands: glVertex2i (…)

17 2003CS Hons RW778 Graphics17 Chapter 2: Drawing in OpenGL –OpenGL data types : GLint, GLfloat –OpenGL state: current state variables. »glColor3f (red, green, blue) »glClear (GL_COLOR_BUFFER_BIT) –Establish coordinate system »Matrices and transformations (ch. 3) –Fig. 2.10: A complete OpenGL program »Note glFlush();

18 2003CS Hons RW778 Graphics18 Chapter 2: Drawing in OpenGL –2.2.1 Drawing dot constellations »The Big Dipper »The Sierpinski Gasket »Simple dot plots (note scaling and shifting, which are affine transformations) 2.3 Line Drawings 2.3 Line Drawings glBegin (GL_LINES); glVertex2i(40, 100); glVertex2i(202, 96); glEnd();

19 2003CS Hons RW778 Graphics19 Chapter 2: Drawing in OpenGL –More than 2 vertices : paired –2.3.1 Drawing polylines and polygons »Polyline: collection of joined line segments, specified by ordered list of points. »OpenGL: GL_LINE_STRIP (open line segment) »GL_LINE_LOOP (closed line segment – not fillable area – GL_POLYGON) »Examples: line graphs, polylines from file, parameterizing figures, polyline drawer

20 2003CS Hons RW778 Graphics20 Chapter 2: Drawing in OpenGL –2.3.2 Line drawing with moveto() and lineto() »Current position –2.3.3 Drawing aligned rectangles »glRecti(x1,y1,x2,y2) –2.3.4 Aspect ratio of aligned rectangle »width/height »NB! Work through all practice exercises on pp. 60— 61.

21 2003CS Hons RW778 Graphics21 Chapter 2: Drawing in OpenGL –2.3.5 Filling polygons »Must be convex! –2.3.6 Other graphics primitives: »GL_TRIANGLES,GL_QUADS,GL_TRIANGLE_STRIP »GL_TRIANGLE_FAN,GL_QUAD_STRIP

22 2003CS Hons RW778 Graphics22 Chapter 2: Drawing in OpenGL 2.4 Simple mouse and keyboard interaction 2.4 Simple mouse and keyboard interaction –glut callbacks on events: glutMouseFunc, glutMotionFunc, glutKeyboardFunc –2.4.1 Mouse interaction : selfstudy –2.4.2 Keyboard interaction : selfstudy 2.6 Case studies: SELFSTUDY 2.6 Case studies: SELFSTUDY

23 2003CS Hons RW778 Graphics23 Chapter 2: Drawing in OpenGL Programming Task 1 : Implement Case Study 2.5 (Polyline Stippling), p. 75, in Hill. Programming Task 1 : Implement Case Study 2.5 (Polyline Stippling), p. 75, in Hill. Familiarize yourself with OpenGL, Linux (or Windows) and C/C++. Familiarize yourself with OpenGL, Linux (or Windows) and C/C++. The usual rules for programming projects hold: The usual rules for programming projects hold: –No extensions (demo Monday 08:00) –No copying/cheating –Accompanying report to be handed in at demo


Download ppt "2003CS Hons RW778 Graphics1 Chapter 1: Introduction Admin: Admin: –Lecture slots: Monday 8-9:45, Tuesday 9:15-11:00. –Book: F. Hill, Computer Graphics."

Similar presentations


Ads by Google