This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfacilities.cpp
executable file
·131 lines (112 loc) · 3.29 KB
/
facilities.cpp
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "facilities.h"
using namespace std;
#pragma comment(lib, "glaux")
AUX_RGBImageRec *UI_fac_Images[30];
GLuint UI_fac_ImageIDs[30];
char *UI_fac_pictures[30] = {
"pictures\\back9.bmp",
"pictures\\11.bmp",
"pictures\\12.bmp",
"pictures\\13.bmp",
"pictures\\14.bmp",
"pictures\\15.bmp",
"pictures\\21.bmp",
"pictures\\22.bmp",
"pictures\\23.bmp",
"pictures\\24.bmp",
"pictures\\endlesspuz.bmp",
"pictures\\endlessball.bmp",
"pictures\\33.bmp",
"pictures\\34.bmp",
"pictures\\35.bmp",
"pictures\\start164.bmp",
"pictures\\00.bmp",
"pictures\\cross.bmp", //17
"pictures\\doc\\11s.bmp", //18
"pictures\\doc\\12s.bmp", //19
"pictures\\doc\\14s.bmp",
"pictures\\doc\\15s.bmp",
"pictures\\doc\\22s.bmp",
"pictures\\doc\\23s.bmp",
"pictures\\doc\\24s.bmp",
"pictures\\doc\\33s.bmp",
"pictures\\doc\\34s.bmp",
"pictures\\doc\\35s.bmp", //27
"pictures\\out.bmp", //28
"pictures\\tuli.bmp" //29
};
void facilities::settexture()
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glEnable(GL_TEXTURE_2D);
glGenTextures(30, UI_fac_ImageIDs);
for (int i = 0; i < 30; i++)
{
glBindTexture(GL_TEXTURE_2D, UI_fac_ImageIDs[i]);
UI_fac_Images[i] = auxDIBImageLoadA(UI_fac_pictures[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, UI_fac_Images[i]->sizeX, UI_fac_Images[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, UI_fac_Images[i]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
}
facilities::facilities(int kind, int color, float position[3], float size[3], bool appear)
{
UI_faci_kind = kind; //cross = 2
UI_faci_color = color;
for (int i = 0; i <= 2; i++)
{
UI_faci_position[i] = position[i]; //一定要loop才可以传进去,传入位置
UI_faci_size[i] = size[i];
}
UI_faci_appear = appear;
}
void facilities::drawself()
{
if (UI_faci_appear == true){
glPushMatrix();
glTranslatef(UI_faci_position[0], UI_faci_position[1], UI_faci_position[2]); //画一个字帖
glScalef(UI_faci_scale, UI_faci_scale, 0.0);
glBindTexture(GL_TEXTURE_2D, UI_fac_ImageIDs[UI_faci_color]);
glBegin(GL_POLYGON);
glNormal3f(0.0, 0.0, 1.0); //正面
glTexCoord2f(0.0, 1.0);
glVertex3f(-UI_faci_size[0] / 2.0, UI_faci_size[1] / 2.0, -1.0);
glTexCoord2f(0.0, 0.0);
glVertex3f(-UI_faci_size[0] / 2.0, -UI_faci_size[1] / 2.0, -1.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(UI_faci_size[0] / 2.0, -UI_faci_size[1] / 2.0, -1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(UI_faci_size[0] / 2.0, UI_faci_size[1] / 2.0, -1.0);
glEnd();
glPopMatrix();
}
}
void facilities::turn_big() //方块变大
{
if (UI_faci_kind == 1)
{
if (UI_faci_scale < 1.1)
{
UI_faci_scale += -0.04 * UI_faci_scale + 0.044;
UI_faci_position[2] = 2.0;
}
}
else{
if (UI_faci_scale < 1.2)
{
UI_faci_scale += -0.04 * UI_faci_scale + 0.048;
UI_faci_position[2] = 2.0;
}
}
}
void facilities::turn_small() //方块变小
{
if (UI_faci_scale > 1.0)
{
UI_faci_scale -= 0.04 * UI_faci_scale - 0.04;
UI_faci_position[2] = 1.0;
}
}