chapter 3: simple graphics program

17
Chapter 3 Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 3: Simple Graphics Program

Upload: korbin

Post on 19-Jan-2016

50 views

Category:

Documents


0 download

DESCRIPTION

Chapter 3: Simple Graphics Program. We will learn. Review coordinate systems Simplest drawing program Graphics API drawing procedure Abstraction of drawing with graphics API. Take a photograph. Paper: cut to right size Position: place at right palce. Coordinate system. The origin - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Chapter 3: Simple Graphics Program

Page 2: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

We will learn

Review coordinate systems Simplest drawing program Graphics API drawing procedure Abstraction of drawing with

graphics API

Page 3: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Take a photograph

Paper: cut to right size Position: place at right palce

Page 4: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Coordinate system

The origin The X/Y Axes

Directions Units on axes

Page 5: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Paper: size and location

Page 6: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Vertex Positions

Order of specification: Va Vb Vc Vd

Clockwise vs Counterclockwise Either is ok, but consistent !

Choice of origin Convenience!

Page 7: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tutorial 3.1: Computer graphics solution

Page 8: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tutorial 3.1: Frontend

Main application window and Drawing Window

Page 9: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tutorial 3.1: Backend programming

Main window (CTutorialDlg) Has an instance of drawing window

At runtime: place the drawing window into the application window

Page 10: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tutorial 3.1: Drawing Window

CGrfxWindowD3D …

A MFC CWnd object Knows how to replace itself onto an

application window Allows D3D drawing (OnPaint()) …

Page 11: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

GrfxWindow: OnPaint() function

Drawing … 4 steps …

Page 12: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

GrfxWindow: Drawing …

Page 13: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lesson learned:

Computer graphics: Draws geometry: Render Must measure and design before

coding Coordinate system

Choose a convenient system: Origin, and units for measurement

Page 14: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Graphics API independent drawing

Page 15: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Graphics objects: Rectangle

Page 16: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Graphics objects: Circle

Center: (0,0) Radius: r If center at (xc,yc)

x = xc + r sin(θ) y = yc + r cos(θ)

Page 17: Chapter 3:  Simple Graphics Program

Chapter 3

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Circle: implementation