SLIDE 1
Window to Viewport CS418 Computer Graphics John C. Hart Graphics - - PowerPoint PPT Presentation
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 2
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
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
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
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
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
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
Graphics Processing
Vertex Shader Scan Converter Fragment Shader 1
(HRES-1) 2 (VRES-1) 2 (HRES-1) 2 (VRES-1) 2