-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMouse.cpp
More file actions
47 lines (33 loc) · 688 Bytes
/
Mouse.cpp
File metadata and controls
47 lines (33 loc) · 688 Bytes
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
#include "Mouse.h"
#include <GL/glut.h>
int buttons[3] = {0};
int mousex = 0;
int mousey = 0;
void Mouse::mousePress(int button, int state, int x, int y) {
if(button == GLUT_LEFT_BUTTON)
buttons[0] = state;
else if(button == GLUT_MIDDLE_BUTTON)
buttons[1] = state;
else if(button == GLUT_RIGHT_BUTTON)
buttons[2] = state;
mousex = x;
mousey = y;
}
void Mouse::mouseMove(int x, int y) {
mousex = x;
mousey = y;
}
void Mouse::warp(int x, int y) {
glutWarpPointer(x, y);
}
bool Mouse::isButtonDown(int button) {
if(button < 0 || button >= 3)
return false;
return buttons[button];
}
int Mouse::getx() {
return mousex;
}
int Mouse::gety() {
return mousey;
}