-
Notifications
You must be signed in to change notification settings - Fork 0
/
CurveStorage.cpp
85 lines (60 loc) · 1.52 KB
/
CurveStorage.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "stdafx.h"
#include "CurveStorage.h"
#include "DCPoint.h"
CurveStorage::CurveStorage()
{
}
CurveStorage::~CurveStorage()
{
}
void CurveStorage::StartCurve()
{
//tempCurve.clear();
}
void CurveStorage::AddPoint(int x, int y)
{
tempCurve.push_back(DCPoint(x, y));
}
void CurveStorage::EndCurve()
{
std::vector<DCPoint> cloneCurve;
for(size_t a = 0; a < tempCurve.size(); a++)
{
cloneCurve.push_back(DCPoint(tempCurve[a].x, tempCurve[a].y));
}
curves.push_back(cloneCurve);
tempCurve.clear();
}
void CurveStorage::DrawCurve()
{
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0, 0, 0, 1);
glLineWidth(1.0);
glBegin(GL_LINES);
for(size_t a = 0; a < curves.size(); a++)
{
for(size_t b = 1; b < curves[a].size(); b++)
{
DCPoint p0 = curves[a][b - 1];
DCPoint p1 = curves[a][b];
glVertex3f(p0.x, p0.y, 0);
glVertex3f(p1.x, p1.y, 0);
//std::cout << p0.x << " " << p0.y << " " << p1.x << p1.y << std::endl;
}
}
for(size_t b = 1; b < tempCurve.size(); b++)
{
DCPoint p0 = tempCurve[b - 1];
DCPoint p1 = tempCurve[b];
glVertex3f(p0.x, p0.y, 0);
glVertex3f(p1.x, p1.y, 0);
//std::cout << p0.x << " " << p0.y << " " << p1.x << p1.y << std::endl;
}
glEnd();
//std::cout << curves.size() << std::endl;
glFlush();
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
}