summaryrefslogtreecommitdiffstats
path: root/src/controller/callbacks/mouse_wheel.c (plain)
blob: 52d3c8b27634493f4b78f4688354d93f0bd5276c
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
#include "mouse_wheel.h"
#include "../actions/zoom.h"
#include <GL/glut.h>

void
mouse_wheel (int button, int dir, int x, int y)
{
  /*
   * Get the current coordinates, substract some fixed amount and
   * then perform the zoom.
   */
  GLint viewport[4];
  glGetIntegerv (GL_VIEWPORT, viewport);

  /*
   * The step size could be either a fixed number of pixels or a percentage.
   */
  //  int step = 5;
  int step = (viewport[3] - viewport[1]) * 0.10;

  /*
   * Not that the focus of the zoom is currently the center of the
   * window but could alternatively be the mouse pointer's position.
   */

  // Zoom in
  if (dir > 0)
    {
      zoom (step,
	    step,
	    viewport[3] - step,
	    viewport[3] - step);
    }

  // Zoom out
  else
    {
      zoom (-step,
	    -step,
	    viewport[3] + step,
	    viewport[3] + step);
    }

  return;
}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.