blob: 605720c47890d36432649d4295e3ecea82695a6f (
plain)
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
51
52
53
54
55
56
57
58
|
#include <GL/glut.h>
#include "../math/math_gl.h"
#include "control_object.h"
bool point_control::check_hit(_vector2<double> check_position, double radius)
{
return (check_position - my_position).length_squared() < (radius * radius);
}
_vector2<double> point_control::get_state()
{
return my_position;
}
//basic rendering function
void point_control::render_static()
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_POINT_SMOOTH);
glPointSize(5.0);
glColor3d(0.0,0.8,0.0);
glBegin(GL_POINTS);
glVertex(my_position);
glEnd();
}
//rendering for when mouse is over the object
void point_control::render_hover()
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_POINT_SMOOTH);
glPointSize(8.0);
glColor3d(0.0,1.0,0.0);
glBegin(GL_POINTS);
glVertex(my_position);
glEnd();
}
void point_control::render_drag(_vector2<double> mouse_position)
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_POINT_SMOOTH);
glPointSize(5.0);
glColor3d(0.1,0.9,0.1);
glBegin(GL_POINTS);
glVertex(mouse_position);
glEnd();
}
void point_control::set_state(_vector2<double> new_param)
{
my_position = new_param;
}
|