36 files changed, 332 insertions, 176 deletions
diff --git a/src/controller/callbacks/reshape.c b/src/controller/callbacks/reshape.c new file mode 100644 index 0000000..da2e2bf --- a/dev/null +++ b/src/controller/callbacks/reshape.c | |||
@@ -0,0 +1,50 @@ | |||
1 | #include "../../model/geometry/density_legend_geometry.h" | ||
2 | #include "../../view/exp004state0.h" | ||
3 | #include "../actions/set_ortho.h" | ||
4 | #include "reshape.h" | ||
5 | #include <GL/glut.h> | ||
6 | |||
7 | #define S exp004state0 | ||
8 | |||
9 | void | ||
10 | reshape (int w, int h) | ||
11 | { | ||
12 | glMatrixMode (GL_PROJECTION); | ||
13 | glLoadIdentity (); | ||
14 | |||
15 | /* | ||
16 | * This scaling produces an odd effect when the coordinates are not | ||
17 | * centered at 0,0. When 0,0 is the lower left rather than the | ||
18 | * center this reshape is a bit unnatural since the image is not | ||
19 | * centered in the middle of the window. | ||
20 | */ | ||
21 | |||
22 | if (w <= h) | ||
23 | { | ||
24 | S.ortho.min_x = S.ortho_min; | ||
25 | S.ortho.max_x = S.ortho_max; | ||
26 | S.ortho.min_y = S.ortho_min * (double) h / (double) w; | ||
27 | S.ortho.max_y = S.ortho_max * (double) h / (double) w; | ||
28 | } | ||
29 | else | ||
30 | { | ||
31 | S.ortho.min_x = S.ortho_min * (double) w / (double) h; | ||
32 | S.ortho.max_x = S.ortho_max * (double) w / (double) h; | ||
33 | S.ortho.min_y = S.ortho_min; | ||
34 | S.ortho.max_y = S.ortho_max; | ||
35 | } | ||
36 | |||
37 | set_ortho (); | ||
38 | |||
39 | glMatrixMode (GL_MODELVIEW); | ||
40 | |||
41 | // Set the viewport equal to the size of the window. | ||
42 | glViewport (0, 0, (GLsizei) w, (GLsizei) h); | ||
43 | |||
44 | S.viewport.w = w; | ||
45 | S.viewport.h = h; | ||
46 | |||
47 | density_legend_geometry (); | ||
48 | |||
49 | return; | ||
50 | } | ||