Window to Viewport CS418 Computer Graphics John C. Hart Graphics - - PowerPoint PPT Presentation

window to viewport
SMART_READER_LITE
LIVE PREVIEW

Window to Viewport CS418 Computer Graphics John C. Hart Graphics - - PowerPoint PPT Presentation

Window to Viewport CS418 Computer Graphics John C. Hart Graphics Processing Vertex Fragment Scan Converter Shader Shader Window to Viewport Viewport Coordinates (0,VRES-1) (HRES-1,VRES-1) Physical per-pixel integer coordinates


slide-1
SLIDE 1

Window to Viewport

CS418 Computer Graphics John C. Hart

slide-2
SLIDE 2

Graphics Processing

Vertex Shader Scan Converter Fragment Shader Window to Viewport

slide-3
SLIDE 3

Viewport Coordinates

  • Physical per-pixel

integer coordinates

  • Also called screen or

device coordinates gl.viewport(x,y,w,h)

  • x,y – lower left pixel
  • w – width
  • h – height
  • Sometimes (0,0) is in

the upper left corner (e.g. for mouse input)

(0,0) (HRES-1,0) (HRES-1,VRES-1) (0,VRES-1)

slide-4
SLIDE 4

Window Coordinates

  • Logical, mathematical

floating-point coordinates

  • WebGL defaults to a

window extending from (-1,-1) to (1,1)

  • This is the normalized

coordinate system you would use to plot an equation – Origin at the middle – All four quadrants

(-1,-1) (1,-1) (1,1) (-1,1)

(0,0)

slide-5
SLIDE 5

Window to Viewport

  • Translate lower-left

corner of window (-1,-1) to the lower-left corner

  • f viewport (0,0)

(-1,-1) (1,-1) (1,1) (-1,1)

(0,0)

slide-6
SLIDE 6

Window to Viewport

  • Translate lower-left

corner of window (-1,-1) to the lower-left corner

  • f viewport (0,0)

1 1 1 1 1

(0,0) (2,0) (2,2) (0,2)

(1,1)

slide-7
SLIDE 7

Window to Viewport

  • Translate lower-left

corner of window (-1,-1) to the lower-left corner

  • f viewport (0,0)

1 1 1 1 1

  • Scale upper-right corner

from (2,2) to upper-right corner of viewport 1

(HRES-1) 2 (VRES-1) 2 (0,0) (HRES-1,0) (HRES-1,VRES-1) (0,VRES-1)

slide-8
SLIDE 8

Window to Viewport

1 1 1 1 1 1 = 1

(HRES-1) 2 (VRES-1) 2 (HRES-1) 2 (VRES-1) 2 (HRES-1) 2 (VRES-1) 2

slide-9
SLIDE 9

Graphics Processing

Vertex Shader Scan Converter Fragment Shader 1

(HRES-1) 2 (VRES-1) 2 (HRES-1) 2 (VRES-1) 2