-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle.cpp
More file actions
58 lines (45 loc) · 969 Bytes
/
Circle.cpp
File metadata and controls
58 lines (45 loc) · 969 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
48
49
50
51
52
53
54
55
56
57
58
#include "Circle.h"
#define NDEBUG
#include <GL/freeglut.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace MF;
Circle::Circle(double radius, double red, double green, double blue)
: Physics(),
m_size_radius(radius)
{
SetBorders(
-m_size_radius, -m_size_radius,
m_size_radius, m_size_radius
);
m_colour_red = red;
m_colour_green = green;
m_colour_blue = blue;
}
Circle::~Circle()
{
}
void Circle::Draw()
{
if (m_flag_show)
{
glPushMatrix();
{
glTranslated(m_position_x, m_position_y, 0.0);
glRotated(m_rotation_z, 0.0, 0.0, 1.0);
glColor3d(m_colour_red, m_colour_green, m_colour_blue);
glBegin(GL_TRIANGLE_FAN);
{
for (int i = 0; i <= 360; i++)
{
// 180 - pi
// i - degInRad
double degInRad = i*M_PI / 180;
glVertex2f(cos(degInRad)*m_size_radius, sin(degInRad)*m_size_radius);
}
}
glEnd();
}
glPopMatrix();
}
}