-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcockpit.h
54 lines (45 loc) · 1021 Bytes
/
cockpit.h
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
#ifndef COCKPIT_H_INCLUDED
#define COCKPIT_H_INCLUDED
#ifdef __APPLE_CC__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "ship.h"
class Cockpit {
Ship ship;
int cockpitId;
public:
Cockpit(Ship ship): ship(ship) {}
void create();
void draw();
};
void Cockpit::create() {
cockpitId = glGenLists(1);
glNewList(cockpitId, GL_COMPILE);
glDisable(GL_LIGHTING);
glColor3f(0.8, 0.8, 0.7);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0, -1, 0);
glVertex3f(1, -1, 0);
for (double x = 1.0; x >= -1.05; x -= 0.05) {
glVertex3f(x, 20*cos(x / 10.0) - 20.6, 0);
}
glVertex3f(-1, -1, 0);
glEnd();
glEnable(GL_LIGHTING);
glEndList();
}
inline void Cockpit::draw() {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glCallList(cockpitId);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
#endif // COCKPIT_H_INCLUDED