path:
root/
src/
controller/
mousewheel.c (
plain)
blob: c9ac742fa10705a672973b845b0b373ff74b3dc5
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 "mousewheel.h"
#include "performzoom.h"
#include <GL/glut.h>
void
mousewheel (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)
{
performzoom (step,
step,
viewport[3] - step,
viewport[3] - step);
}
// Zoom out
else
{
performzoom (-step,
-step,
viewport[3] + step,
viewport[3] + step);
}
return;
}
|