|
2 | 2 | * draw-win.cpp
|
3 | 3 | *
|
4 | 4 | * Created on: 15 jan. 2016
|
5 |
| - * Author: mattr |
| 5 | + * Author: Mattias Larsson SKöld |
6 | 6 | */
|
7 | 7 |
|
8 |
| -#include "draw.h" |
9 | 8 | #include "GL/gl.h"
|
| 9 | +#include "draw.h" |
| 10 | + |
10 | 11 | #include <iostream>
|
11 | 12 |
|
12 | 13 | constexpr double angularMultiplier = 180. / pi;
|
13 | 14 |
|
14 |
| - |
15 |
| - |
16 | 15 | using namespace std;
|
17 | 16 |
|
18 |
| -void modelTransform(Vec p, double a, double scale) { |
19 |
| - |
| 17 | +void modelTransform(Vec /*p*/, double /*a*/, double /*scale*/) { |
20 | 18 | }
|
21 | 19 |
|
22 | 20 | void resetTransform() {
|
23 |
| - |
24 | 21 | }
|
25 | 22 | void setCam(Vec p, double a) {
|
26 |
| - glMatrixMode(GL_PROJECTION); |
27 |
| - glLoadIdentity(); |
28 |
| - glRotatef(-a * angularMultiplier, 0,0,1); |
29 |
| - glScalef(.05,.05,.05); |
30 |
| - glTranslatef(-p.x, -p.y, 0); |
31 |
| - glMatrixMode(GL_MODELVIEW); |
32 |
| - glLoadIdentity(); |
| 23 | + glMatrixMode(GL_PROJECTION); |
| 24 | + glLoadIdentity(); |
| 25 | + glRotated(-a * angularMultiplier, 0, 0, 1); |
| 26 | + glScaled(.05, .05, .05); |
| 27 | + glTranslated(-p.x, -p.y, 0); |
| 28 | + glMatrixMode(GL_MODELVIEW); |
| 29 | + glLoadIdentity(); |
33 | 30 | }
|
34 | 31 | void camTransform() {
|
35 |
| - |
36 | 32 | }
|
37 | 33 |
|
38 | 34 | void drawShip(Vec p, double a) {
|
39 |
| - glPushMatrix(); |
40 |
| - glTranslatef(p.x, p.y, 0); |
41 |
| - glRotatef(a * angularMultiplier, 0,0,1); |
42 |
| - glBegin(GL_TRIANGLES); |
43 |
| - glColor3f(1,1,1); |
44 |
| - glVertex2f(0.f, 1.f); |
45 |
| - glVertex2f(.5f, -1.f); |
46 |
| - glVertex2f(-.5f, -1.f); |
47 |
| - glEnd(); |
48 |
| - glPopMatrix(); |
49 |
| - |
| 35 | + glPushMatrix(); |
| 36 | + glTranslated(p.x, p.y, 0); |
| 37 | + glRotated(a * angularMultiplier, 0, 0, 1); |
| 38 | + glBegin(GL_TRIANGLES); |
| 39 | + glColor3f(1, 1, 1); |
| 40 | + glVertex2f(0.f, 1.f); |
| 41 | + glVertex2f(.5f, -1.f); |
| 42 | + glVertex2f(-.5f, -1.f); |
| 43 | + glEnd(); |
| 44 | + glPopMatrix(); |
50 | 45 | }
|
51 |
| -void drawStar(Vec p) { |
52 |
| - |
| 46 | +void drawStar(Vec /*p*/) { |
53 | 47 | }
|
54 | 48 |
|
55 |
| - |
56 |
| - |
57 | 49 | void drawArea(Vec p, double a, double r) {
|
58 |
| - glPushMatrix(); |
59 |
| - glTranslatef(p.x, p.y, 0); |
60 |
| - glScalef(r, r, r); |
61 |
| - glRotatef(a, 0,0,1); |
62 |
| - glBegin(GL_LINE_LOOP); |
63 |
| - glColor3f(.8,.8, 1); |
64 |
| - glVertex2f(-1, -1); |
65 |
| - glVertex2f(-1, 1); |
66 |
| - glVertex2f(1, 1); |
67 |
| - glVertex2f(1, -1); |
68 |
| - glEnd(); |
69 |
| - glPopMatrix(); |
| 50 | + glPushMatrix(); |
| 51 | + glTranslated(p.x, p.y, 0); |
| 52 | + glScaled(r, r, r); |
| 53 | + glRotated(a, 0, 0, 1); |
| 54 | + glBegin(GL_LINE_LOOP); |
| 55 | + glColor3f(.8f, .8f, 1); |
| 56 | + glVertex2f(-1, -1); |
| 57 | + glVertex2f(-1, 1); |
| 58 | + glVertex2f(1, 1); |
| 59 | + glVertex2f(1, -1); |
| 60 | + glEnd(); |
| 61 | + glPopMatrix(); |
70 | 62 | }
|
71 | 63 |
|
72 |
| - |
73 | 64 | void drawComet(Vec p, double a, double r) {
|
74 |
| - glPushMatrix(); |
75 |
| - glTranslatef(p.x, p.y, 0); |
76 |
| - glScalef(r, r, r); |
77 |
| - glRotatef(a, 0,0,1); |
78 |
| - glBegin(GL_TRIANGLE_FAN); |
79 |
| - glColor3f(.8,.8, 1); |
80 |
| - glVertex2f(-1, -1); |
81 |
| - glVertex2f(-1, 1); |
82 |
| - glVertex2f(1, 1); |
83 |
| - glVertex2f(1, -1); |
84 |
| - glEnd(); |
85 |
| - glPopMatrix(); |
| 65 | + glPushMatrix(); |
| 66 | + glTranslated(p.x, p.y, 0); |
| 67 | + glScaled(r, r, r); |
| 68 | + glRotated(a, 0, 0, 1); |
| 69 | + glBegin(GL_TRIANGLE_FAN); |
| 70 | + glColor3f(.8f, .8f, 1.f); |
| 71 | + glVertex2f(-1, -1); |
| 72 | + glVertex2f(-1, 1); |
| 73 | + glVertex2f(1, 1); |
| 74 | + glVertex2f(1, -1); |
| 75 | + glEnd(); |
| 76 | + glPopMatrix(); |
86 | 77 | }
|
87 |
| -void drawProjectile(Vec p, double a, double scale) { |
88 |
| - |
| 78 | +void drawProjectile(Vec /*p*/, double /*a*/, double /*scale*/) { |
89 | 79 | }
|
90 | 80 | void drawExplosion(Vec p, double size) {
|
91 |
| - glPushMatrix(); |
92 |
| - glTranslatef(p.x, p.y, 0); |
93 |
| - glScalef(size, size, size); |
94 |
| - glBegin(GL_TRIANGLE_FAN); |
95 |
| - glColor3f(.8,.8, 1); |
96 |
| - glVertex2f(-1, -1); |
97 |
| - glVertex2f(-1, 1); |
98 |
| - glVertex2f(1, 1); |
99 |
| - glVertex2f(1, -1); |
100 |
| - glEnd(); |
101 |
| - glPopMatrix(); |
102 |
| - |
| 81 | + glPushMatrix(); |
| 82 | + glTranslated(p.x, p.y, 0); |
| 83 | + glScaled(size, size, size); |
| 84 | + glBegin(GL_TRIANGLE_FAN); |
| 85 | + glColor3d(.8, .8, 1); |
| 86 | + glVertex2f(-1, -1); |
| 87 | + glVertex2f(-1, 1); |
| 88 | + glVertex2f(1, 1); |
| 89 | + glVertex2f(1, -1); |
| 90 | + glEnd(); |
| 91 | + glPopMatrix(); |
103 | 92 | }
|
104 |
| -void drawSmoke(Vec p1, Vec p2, double alpha1, double alpha2){ |
105 |
| - glBegin(GL_LINES); |
106 |
| - glColor4f(1,1,1, alpha2); |
107 |
| - glVertex3dv(&p1.x); |
108 |
| - glVertex3dv(&p2.x); |
109 |
| - glEnd(); |
| 93 | +void drawSmoke(Vec p1, Vec p2, double /*alpha1*/, double alpha2) { |
| 94 | + glBegin(GL_LINES); |
| 95 | + glColor4d(1, 1, 1, alpha2); |
| 96 | + glVertex3dv(&p1.x); |
| 97 | + glVertex3dv(&p2.x); |
| 98 | + glEnd(); |
110 | 99 | }
|
111 |
| -bool initDrawModule(double perspective){ |
112 |
| - |
| 100 | +bool initDrawModule(double /*perspective*/) { |
| 101 | + return false; |
113 | 102 | }
|
114 |
| -void flushDraw(){ |
115 |
| - |
| 103 | +void flushDraw() { |
116 | 104 | }
|
117 |
| - |
118 |
| - |
0 commit comments