summaryrefslogtreecommitdiffstats
path: root/src/controller/exp004reshape.c (plain)
blob: a127e46d6d41339bb38e2847d585ef4188d486af
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "exp004reshape.h"
#include "set_ortho.h"
#include "../view/exp004state0.h"
#include "../model/geometry/density_legend_geometry.h"
#include <GL/glut.h>

#define S exp004state0

void
exp004reshape (int w, int h)
{
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();

  /*
   * This scaling produces an odd effect when the coordinates are not
   * centered at 0,0.  When 0,0 is the lower left rather than the
   * center this reshape is a bit unnatural since the image is not
   * centered in the middle of the window.
   */

  if (w <= h)
    {
      S.ortho.min_x = S.ortho_min;
      S.ortho.max_x = S.ortho_max;
      S.ortho.min_y = S.ortho_min * (double) h / (double) w;
      S.ortho.max_y = S.ortho_max * (double) h / (double) w;
    }
  else
    {
      S.ortho.min_x = S.ortho_min * (double) w / (double) h;
      S.ortho.max_x = S.ortho_max * (double) w / (double) h;
      S.ortho.min_y = S.ortho_min;
      S.ortho.max_y = S.ortho_max;
    }

  set_ortho ();

  glMatrixMode (GL_MODELVIEW);

  // Set the viewport equal to the size of the window.
  glViewport (0, 0, (GLsizei) w, (GLsizei) h);

  S.viewport.w = w;
  S.viewport.h = h;

  density_legend_geometry ();

  return;
}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.