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