-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswDrawable.cpp
More file actions
34 lines (28 loc) · 769 Bytes
/
Copy pathswDrawable.cpp
File metadata and controls
34 lines (28 loc) · 769 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
#include <cmath>
#include <QGLWidget>
#include "swDrawable.h"
swDrawable::swDrawable(double px, double py, double r, double sx, double sy) : scale(sx, sy), pos(px, py), rot(r) {
type = SW_DRAWABLE;
}
swDrawable::~swDrawable() {}
void swDrawable::draw() {
glPushMatrix();
transform();
// draw... nothing
glPopMatrix();
}
void swDrawable::transform() {
glTranslated(pos.x, pos.y, 0);
glRotated(rot * 180.0 / M_PI, 0, 0, 1);
glScaled(scale.x, scale.y, 1);
}
void swDrawable::read(swStream* stream) {
scale.read(stream);
pos.read(stream);
stream->readDouble(rot);
}
void swDrawable::write(swStream* stream) {
scale.write(stream);
pos.write(stream);
stream->writeDouble(rot);
}