-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaneGL.cpp
More file actions
97 lines (82 loc) · 3.75 KB
/
planeGL.cpp
File metadata and controls
97 lines (82 loc) · 3.75 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
#include <GLFW/glfw3.h>
#include <cmath>
#include <cstdlib>
// horizon d'arbres ?? should we keep it ?
void dessinerArbres() {
glBegin(GL_TRIANGLES);//arbres sont des triangles
float baseY = -0.35f; //after the sky
float treeH = 0.35f; //height of each tree
float step = 0.15f; // Horizontal spacing between tree centers
for (int i = 0; i < 40; i++) { //dessiner plusieurs arbres
float cx = -1.0f + i * step; // X center of current tree, evenly spaced from left edge
if (i % 2 == 0)
glColor3f(0.13f, 0.45f, 0.18f); //light green
else
glColor3f(0.08f, 0.30f, 0.12f); // Dark green
glVertex2f(cx, baseY + treeH); // Top tip of the triangle (tree peak)
glVertex2f(cx - 0.055f, baseY); // Bottom-left base corner of the triangle
glVertex2f(cx + 0.055f, baseY); // Bottom-right base corner of the triangle
}
glEnd();
}
//herbes
void dessinerHerbe() {
//behin the runway
glBegin(GL_QUADS); //rectangle
glColor3f(0.15f, 0.50f, 0.15f);
glVertex2f(-1.0f, -0.35f); //top left
glVertex2f(1.0f, -0.35f); //top right
glVertex2f(1.0f, -0.50f); //bottom right
glVertex2f(-1.0f, -0.50f); //bottomleft
glEnd();
// in front of runway
glBegin(GL_QUADS);
glColor3f(0.15f, 0.50f, 0.15f);
glVertex2f(-1.0f, -0.80f); //top left
glVertex2f(1.0f, -0.80f); //top right
glVertex2f(1.0f, -1.00f); //bottom right
glVertex2f(-1.0f, -1.00f); //bottom left
glEnd();
}
// runway
void dessinerPiste() {
glBegin(GL_QUADS);
glColor3f(0.28f, 0.28f, 0.28f);
glVertex2f(-1.0f, -0.50f); //top left
glVertex2f(1.0f, -0.50f); //top right
glVertex2f(1.0f, -0.80f); //bottom right
glVertex2f(-1.0f, -0.80f); //bottom left
glEnd();
//bordure
glLineWidth(3.0f); //epaisseur
glBegin(GL_LINES);
glColor3f(1.0f, 1.0f, 1.0f);
glVertex2f(-1.0f, -0.505f);
glVertex2f(1.0f, -0.505f);
glVertex2f(-1.0f, -0.795f);
glVertex2f(1.0f, -0.795f);
glEnd();
// middle runway
float midY = -0.65f;
float dashW = 0.07f;
float gapW = 0.05f;
float x = -1.0f;
glBegin(GL_QUADS);
glColor3f(1.0f, 1.0f, 1.0f);
while (x < 1.0f) {
glVertex2f(x, midY + 0.008f);
glVertex2f(x + dashW, midY + 0.008f);
glVertex2f(x + dashW, midY - 0.008f);
glVertex2f(x, midY - 0.008f);
x += dashW + gapW;
}
glEnd();
}
void display() {
glClear(GL_COLOR_BUFFER_BIT);
dessinerArbres();
dessinerHerbe();
dessinerPiste();
glFlush();
}
//widden runway