8
Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Embed Size (px)

Citation preview

Page 1: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Glut Coordinate System

Used in keyboard and mouse callbacks

x

y

w

h[window]

Page 2: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Fall 2013 revised 2

Recall OpenGL Rendering Pipeline

stages of vertex transformation

Page 3: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

OpenGL NDC (normalized device coordinate)

x

y z

[-1,1]2 × [0,1]depth range

Near (0)

Far (1)

Note: this is a left-hand coordinate system!

Page 4: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Fall 2013 revised 4

Recall OpenGL Rendering Pipeline

stages of vertex transformation

Page 5: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

OpenGL Window Coordinates

x

y z

[0,1]2

Near (0)

Far (1)

Page 6: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Use Mouse to Pick 2D World

x

y

xmin xmax

(mx, my)

(x, y)

0

0

minmax

min

w

mx

xx

xx

w

x

Keep all terms positive

in the formula

Page 7: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Use Mouse to Pick 2D World

x

y

ymin

ymax

(mx, my)

(x, y)

h

myh

yy

yy

minmax

min

h

Length ratio: take positive

valuesy

Page 8: Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]

Summary

0

0

minmax

min

w

mx

xx

xx

h

myh

yy

yy

minmax

min

minmaxmin xxw

mxxx

minmaxmin yyh

myhyy