This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext.h
183 lines (172 loc) · 4.61 KB
/
text.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//
// text.h
// CG_Projeto
//
// Created by Dylan Perdigão on 27/10/2020.
//
#include <string.h>
#ifndef text_h
#define text_h
char* meshText(char* str){
char aux[30];
sprintf(aux,"%d",dim);
strcat(str,aux);
return str;
}
char* intensityText(char* str){
char aux[30];
float percentage = abs(100*(torchIntensity)/INTENSITY_MAX);
sprintf(aux,"%.0f%s",percentage,"%");
strcat(str,aux);
return str;
}
char* colorsText(char* str){
if(isRed){
strcat(str,"1");
}else{
strcat(str,"0");
}
if(isGreen){
strcat(str,"1");
}else{
strcat(str,"0");
}
if(isBlue){
strcat(str,"1");
}else{
strcat(str,"0");
}
return str;
}
char* dayText(char* str){
if(isDay){
strcat(str,"DAY");
}else{
strcat(str,"NIGHT");
}
return str;
}
char* torchText(char* str){
if(isTorchON){
strcat(str,"ON");
}else{
strcat(str,"OFF");
}
return str;
}
char* specularityText(char* str){
if(originalCoef){
strcat(str,"TRUE");
}else{
strcat(str,"FALSE");
}
return str;
}
char* projectionText(char* text){
switch (projectionType) {
case ORTHOGONAL:
strcat(text, "Orthogonal");
break;
case PERSPECTIVE:
strcat(text, "Perspective");
break;
}
return text;
}
char* zoomText(char* text){
switch (zoom) {
case 1:
strcat(text, "1x");
break;
case 2:
strcat(text, "2x");
break;
case 4:
strcat(text, "4x");
break;
}
return text;
}
void drawText(char* string, GLfloat x, GLfloat y){
glDisable(GL_LIGHTING);
glPushMatrix();
glTranslatef(x, 0, y);
glRasterPos2f(0, 0);
while (*string)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, *string++);
glPopMatrix();
glEnable(GL_LIGHTING);
}
void drawCommands(int x,int y,int ySpace){
int line=0;
char text[100];
glColor4f(RED);
snprintf(text, 100, "COMMANDS");
drawText(text, x, y);line++;
//MOVES
glColor4f(GREEN);
snprintf(text, 100, "- AD..............Shift door left/right");
drawText(text, x,y+line*ySpace);line++;
snprintf(text, 100, "- WS..............Shift window up/down");
drawText(text, x,y+line*ySpace);line++;
snprintf(text, 100, "- QE..............Open/Close sec. door");
drawText(text, x,y+line*ySpace);line++;
snprintf(text, 100, "- ARROWS....Move observator");
drawText(text, x,y+line*ySpace);line++;
//PROJECTION
snprintf(text, 100, "- P.................Projection Mode");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........");
drawText(projectionText(text), x,y+line*ySpace);line++;
//ZOOM
glColor4f(GREEN);
snprintf(text, 100, "- O................Zoom");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........Zoom-");
drawText(zoomText(text), x,y+line*ySpace);line++;
//COLOR
glColor4f(GREEN);
snprintf(text, 100, "- RGB............Torch color");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........RGB-");
drawText(colorsText(text), x,y+line*ySpace);line++;
//DAY/NIGHT
glColor4f(GREEN);
snprintf(text, 100, "- 1.................Switch day/night");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........");
drawText(dayText(text), x,y+line*ySpace);line++;
//ON/OFF TORCH
glColor4f(GREEN);
snprintf(text, 100, "- 2.................On/Off torch");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........");
drawText(torchText(text), x,y+line*ySpace);line++;
//Intensity
glColor4f(GREEN);
snprintf(text, 100, "- 34................Torch Intensity");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........Intensity: ");
drawText(intensityText(text), x,y+line*ySpace);line++;
//Intensity
glColor4f(GREEN);
snprintf(text, 100, "- M.................Mesh");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........Mesh dim: ");
drawText(meshText(text), x,y+line*ySpace);line++;
//Intensity
glColor4f(GREEN);
snprintf(text, 100, "- C...............Original Specularity Coef.");
drawText(text, x,y+line*ySpace);line++;
glColor4f(CYAN);
snprintf(text, 100, "..........State: ");
drawText(specularityText(text), x,y+line*ySpace);line++;
}
#endif /* text_h */