Download presentation

Presentation is loading. Please wait.

Published byFreddy Dary Modified over 3 years ago

1
OUTPUT PRIMITIVES 2010-2011

2
Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate System which can be three dimensional and real-valued. ● Locations on a video monitor are referenced in integer screen coordinates. Therefore object definitions has to be scan converted to discrete screen coordinate locations to be viewed on a video monitor.

3
Specification of a 2D WCS in OpenGL ● glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (xmin, xmax, ymin, ymax); ● Objects that are specified within these coordinate limits will be displayed within the OpenGL window.

4
Output Primitives ● Graphic SW and HW provide subroutines to describe a scene in terms of basic geometric structures called output primitives. ● Output primitives are combined to form complex structures ● Simplest primitives – Point (pixel) – Line segment

5
Scan Conversion ● Converting output primitives into frame buffer updates. Choose which pixels contain which intensity value. ● Constraints – Straight lines should appear as a straight line – primitives should start and end accurately – Primitives should have a consistent brightness along their length – They should be drawn rapidly

6
OpenGL Point Functions ● glBegin (GL_POINTS); glVertex2i(50, 100); glVertex2i(75, 150); glVertex2i(100, 200); glEnd();

7
OpenGL Line Functions ● glBegin (GL_LINES); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2

8
OpenGL Line Functions ● glBegin (GL_LINE_STRIP); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2

9
OpenGL Line Functions ● glBegin (GL_LINE_LOOP); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2

10
Line Drawing Algorithms ● Simple approach: sample a line at discrete positions at one coordinate from start point to end point, calculate the other coordinate value from line equation (slope-intercept line equation). If m>1, increment y and find x If m ≤1, increment x and find y Is this correct?

11
Digital Differential Analyzer ● Simple approach: too many floating point operations and repeated calculations ● Calculate from for a value

12
DDA ● Is faster than directly implementing y=mx+b. No floating point multiplications. We have floating point additions only at each step. ● But what about round-off errors? ● Can we get rid of floating point operations completely?

13
Bresenham's Line Algorithm ● DDA: Still floating point operations x k+1 xkxk ykyk yk+1yk+1 y=mx+b d upper d lower x k+2 x k+3

14
at step k+1: 0 if p k was negative1 if p k was positive to calculate p 0 at the starting pixel position (x 0,y 0 )

15
Input: two line end points ( x 0,y 0 ) and ( x end,y end ) draw ( x 0,y 0 ) p k ←2Δy-Δx; x k ←x 0 while x k <x end x k+1 ←x k +1 if p k ≤ 0 choose y k y k+1 ←y k ; p k+1 ←p k +2Δy else choose y k +1 y k+1 ←y k +1; p k+1 ←p k + 2Δy - 2Δx draw ( x k+1,y k+1 ) x k ←x k+1 p k ←p k+1 Bresenham’s Line-Drawing Algorithm

16
Example from the textbook ● Using Bresenham’s algorithm digitize the line with endpoints (20,10) and (30,18) Solution: ● Δy = (18-10)=8, Δx = (30-20)=10, ● m = Δy / Δx = 0.8, ● p0= 2Δy - Δx = 16 – 10 = 6. ● 2Δy = 16 and (2Δy) - 2Δx = 16 - 20 = -4. ● plot the initial point (x0, y0) = (20,10 ● find the following pixel positions along the line:

18
Example continued... 2021302225 10 18

19
Plotted pixels 2021302225 10 18

Similar presentations

OK

Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.

Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google

Ppt on electricity for class 10 download Ppt on science technology and society Ppt on pricing policy examples Ppt on world photography day Ppt on switching devices on verizon Ppt on sustainable rural development Ppt on natural disasters in hindi Ppt on c language fundamentals grade Flexible display ppt on tv Ppt on any social issues in india