-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtle.c
More file actions
474 lines (446 loc) · 24.7 KB
/
Copy pathturtle.c
File metadata and controls
474 lines (446 loc) · 24.7 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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
// #define TURTLE_IMPLEMENTATION
#include "turtle.h"
#include <time.h>
void parseRibbonOutput() {
if (tt_ribbon.output[0] == 0) {
return;
}
tt_ribbon.output[0] = 0;
if (tt_ribbon.output[1] == 0) { // File
if (tt_ribbon.output[2] == 1) { // New
list_clear(osToolsFileDialog.selectedFilenames);
printf("New\n");
}
if (tt_ribbon.output[2] == 2) { // Save
if (osToolsFileDialog.selectedFilenames -> length == 0) {
if (osToolsFileDialogSave(OSTOOLS_FILE_DIALOG_FILE, "Save.txt", NULL) != -1) {
printf("Saved to: %s\n", osToolsFileDialog.selectedFilenames -> data[0].s);
}
} else {
printf("Saved to: %s\n", osToolsFileDialog.selectedFilenames -> data[0].s);
}
}
if (tt_ribbon.output[2] == 3) { // Save As...
list_clear(osToolsFileDialog.selectedFilenames);
if (osToolsFileDialogSave(OSTOOLS_FILE_DIALOG_FILE, "Save.txt", NULL) != -1) {
printf("Saved to: %s\n", osToolsFileDialog.selectedFilenames -> data[0].s);
}
}
if (tt_ribbon.output[2] == 4) { // Open
list_clear(osToolsFileDialog.selectedFilenames);
if (osToolsFileDialogOpen(OSTOOLS_FILE_DIALOG_MULTIPLE_SELECT, OSTOOLS_FILE_DIALOG_FILE, "", NULL) != -1) {
printf("Loaded data from: ");
list_print(osToolsFileDialog.selectedFilenames);
}
}
}
if (tt_ribbon.output[1] == 1) { // Edit
if (tt_ribbon.output[2] == 1) { // Undo
printf("Undo\n");
}
if (tt_ribbon.output[2] == 2) { // Redo
printf("Redo\n");
}
if (tt_ribbon.output[2] == 3) { // Cut
osToolsClipboardSetText("test123");
printf("Cut \"test123\" to clipboard!\n");
}
if (tt_ribbon.output[2] == 4) { // Copy
osToolsClipboardSetText("test345");
printf("Copied \"test345\" to clipboard!\n");
}
if (tt_ribbon.output[2] == 5) { // Paste
osToolsClipboardGetText();
printf("Pasted \"%s\" from clipboard!\n", osToolsClipboard.text);
}
}
if (tt_ribbon.output[1] == 2) { // View
if (tt_ribbon.output[2] == 1) { // Change theme
printf("Change theme\n");
if (tt_theme == TT_THEME_DARK) {
turtleBackgroundColor(36, 30, 32);
turtleToolsSetTheme(TT_THEME_COLT);
} else if (tt_theme == TT_THEME_COLT) {
turtleBackgroundColor(212, 201, 190);
turtleToolsSetTheme(TT_THEME_NAVY);
} else if (tt_theme == TT_THEME_NAVY) {
turtleBackgroundColor(255, 255, 255);
turtleToolsSetTheme(TT_THEME_LIGHT);
} else if (tt_theme == TT_THEME_LIGHT) {
turtleBackgroundColor(30, 30, 30);
turtleToolsSetTheme(TT_THEME_DARK);
}
}
if (tt_ribbon.output[2] == 2) { // GLFW
printf("GLFW settings\n");
}
}
}
void parsePopupOutput(GLFWwindow *window) {
if (tt_popup.output[0] == 0) {
return;
}
tt_popup.output[0] = 0; // untoggle
if (tt_popup.output[1] == 0) { // cancel
turtle.close = 0;
glfwSetWindowShouldClose(window, 0);
}
if (tt_popup.output[1] == 1) { // close
turtle.popupClose = 1;
}
}
int main(int argc, char *argv[]) {
/* create window */
GLFWwindow *window = turtleCreateWindowIcon(TURTLE_WINDOW_DEFAULT_WIDTH, TURTLE_WINDOW_DEFAULT_HEIGHT, "turtle demo", "images/thumbnail.png");
if (window == NULL) {
return -1; // failed to create window
}
/* initialise turtle */
turtleSetResizeMode(TURTLE_RESIZE_MODE_PAD); // change to TURTLE_RESIZE_MODE_STRETCH to have content stretch when resized
turtleInit(window, -320, -180, 320, 180);
/* initialise osTools */
osToolsInit(argv[0], window); // must include argv[0] to get executableFilepath, must include GLFW window for copy paste and cursor functionality
osToolsFileDialogAddGlobalExtension("txt"); // add txt to extension restrictions
osToolsFileDialogAddGlobalExtension("csv"); // add csv to extension restrictions
/* initialise turtleText */
char constructedFilepath[5120];
strcpy(constructedFilepath, osToolsFileDialog.executableFilepath);
strcat(constructedFilepath, "config/roberto.tgl");
turtleTextInit(constructedFilepath);
/* initialise turtleTools ribbon */
turtleToolsSetTheme(TT_THEME_DARK); // dark theme preset
strcpy(constructedFilepath, osToolsFileDialog.executableFilepath);
strcat(constructedFilepath, "config/ribbonConfig.txt");
tt_ribbonInit(constructedFilepath);
// list_t *ribbonConfig = list_init();
// list_append(ribbonConfig, (unitype) "File, 📄 New, 📄 Save, 📄 Save As..., 📄 Open", 's');
// list_append(ribbonConfig, (unitype) "Edit, Undo, Redo, Cut, Copy, Paste", 's');
// list_append(ribbonConfig, (unitype) "View, Change Theme, GLFW", 's');
// tt_ribbonInitList(ribbonConfig);
/* initialise turtleTools popup */
strcpy(constructedFilepath, osToolsFileDialog.executableFilepath);
strcat(constructedFilepath, "config/popupConfig.txt");
tt_popupInit(constructedFilepath);
// list_t *popupConfig = list_init();
// list_append(popupConfig, (unitype) "Are you sure you want to close?", 's');
// list_append(popupConfig, (unitype) "Cancel", 's');
// list_append(popupConfig, (unitype) "Close", 's');
// tt_popupInitList(popupConfig);
strcpy(constructedFilepath, osToolsFileDialog.executableFilepath);
strcat(constructedFilepath, "config/test.csv");
list_t *rowLike = osToolsLoadCSVString(constructedFilepath, OSTOOLS_CSV_ROW);
list_t *columnLike = osToolsLoadCSVString(constructedFilepath, OSTOOLS_CSV_COLUMN);
if (rowLike != NULL) {
list_print(rowLike);
}
if (columnLike != NULL) {
list_print(columnLike);
}
/* textures */
turtle_texture_t empvImage = turtleTextureLoad("images/EMPV.png");
// uint8_t array[16] = {
// 100, 100, 100, 100,
// 100, 100, 100, 100,
// 100, 100, 100, 100,
// 100, 100, 100, 100,
// };
// turtle_texture_t empvImage = turtleTextureLoadArray(array, 4, 4, GL_GREEN);
turtleTexturePrint(empvImage);
list_t *folders = osToolsFolderList(".");
list_t *files = osToolsFileList(".");
list_t *filesAndFolders = osToolsFileAndFolderList(".");
list_print(folders);
list_print(files);
list_print(filesAndFolders);
list_free(folders);
list_free(files);
list_free(filesAndFolders);
list_t *serialPorts = osToolsSerialList();
printf("Serial Ports: ");
list_print(serialPorts);
for (int32_t i = 0; i < serialPorts -> length; i++) {
osToolsSerialOpen(serialPorts -> data[i].s, OSTOOLS_BAUD_115200);
osToolsSerialSend(serialPorts -> data[i].s, (uint8_t *) "Hello World\r\n", strlen("Hello World\r\n"));
osToolsSerialClose(serialPorts -> data[i].s);
}
list_free(serialPorts);
/* Server testing */
// osToolsServerSocketCreate("Server1", OSTOOLS_PROTOCOL_TCP, "6000");
// osToolsServerSocketListen("Server1", "Client1");
// osToolsSocketSend("Client1", (uint8_t *) "Hello World\r\n", strlen("Hello World\r\n"));
// uint8_t *buffer = calloc(128, 1);
// osToolsSocketReceive("Client1", buffer, 128, 10000);
// printf("Received: %s\n", buffer);
// free(buffer);
// osToolsSocketDestroy("Client1");
/* Client testing */
// osToolsClientSocketCreate("Client1", OSTOOLS_PROTOCOL_TCP, "127.0.0.1", "6000", 10000);
// osToolsSocketSend("Client1", (uint8_t *) "Hello World\r\n", strlen("Hello World\r\n"));
// uint8_t *buffer = calloc(128, 1);
// osToolsSocketReceive("Client1", buffer, 128, 10000);
// printf("Received: %s\n", buffer);
// free(buffer);
// osToolsSocketDestroy("Client1");
/* test list saving and loading */
// list_t *listWrite = list_init();
// list_append(listWrite, (unitype) 'A', 'c');
// list_append(listWrite, (unitype) 1.0, 'd');
// list_append(listWrite, (unitype) 500.1, 'd');
// list_append(listWrite, (unitype) 2938274, 'i');
// list_append(listWrite, (unitype) 6552, 'h');
// list_t *listEmbed = list_init();
// list_append(listEmbed, (unitype) "C:\\Information\\Programming\\C\\openGL\\turtle-development", 's');
// list_append(listWrite, (unitype) listEmbed, 'r');
// list_append(listWrite, (unitype) "SimpleString", 's');
// list_append(listWrite, (unitype) "Hello World illegal ,,[],\\\\akdja", 's');
// list_append(listWrite, (unitype) 'Z', 'c');
// FILE *listWriteFile = fopen("listWriteFile.txt", "w");
// list_write(listWriteFile, listWrite);
// fclose(listWriteFile);
// FILE *listReadFile = fopen("listWriteFile.txt", "r");
// list_t *listRead = list_read(listReadFile);
// fclose(listReadFile);
// list_print(listWrite);
// list_print(listRead);
list_t *cameras = osToolsCameraList();
printf("Cameras: ");
list_print(cameras);
char *cameraName = NULL;
uint8_t *cameraFrame = NULL;
list_t *imageDropdownOptions = list_init();
list_append(imageDropdownOptions, (unitype) "Image", 's');
for (int32_t i = 0; i < cameras -> length; i += 4) {
list_append(imageDropdownOptions, cameras -> data[i], 's');
}
tt_dropdown_t *imageDropdown = tt_dropdownInit("Source", imageDropdownOptions, NULL, TT_DROPDOWN_ALIGN_RIGHT, 700, 36, 8);
int32_t oldImageDropdown = imageDropdown -> value;
double sliderVar, dialVar;
tt_button_t *button = tt_buttonInit("Button", NULL, 150, 20, 10);
button -> shape = TT_BUTTON_SHAPE_ROUNDED_RECTANGLE;
tt_switchInit("Switch", NULL, 150, -20, 10);
tt_dialInit("Exp", &dialVar, TT_DIAL_SCALE_EXP, -150, 20, 10, 0, 1000, 1);
tt_dialInit("Linear", &dialVar, TT_DIAL_SCALE_LINEAR, -150, -20, 10, 0, 1000, 1);
tt_dialInit("Log", &dialVar, TT_DIAL_SCALE_LOG, -150, -60, 10, 0, 1000, 1);
tt_sliderInit("Slider", NULL, TT_SLIDER_TYPE_HORIZONTAL, TT_SLIDER_ALIGN_LEFT, -100, 35, 10, 50, 0, 255, 1);
tt_sliderInit("Slider", NULL, TT_SLIDER_TYPE_HORIZONTAL, TT_SLIDER_ALIGN_CENTER, 0, 35, 10, 50, 0, 255, 1);
tt_sliderInit("Slider", NULL, TT_SLIDER_TYPE_HORIZONTAL, TT_SLIDER_ALIGN_RIGHT, 100, 35, 10, 50, 0, 255, 1);
tt_sliderInit("Log", &sliderVar, TT_SLIDER_TYPE_VERTICAL, TT_SLIDER_ALIGN_LEFT, -100, -35, 10, 50, 0, 255, 1) -> scale = TT_SLIDER_SCALE_LOG;
tt_sliderInit("Linear", &sliderVar, TT_SLIDER_TYPE_VERTICAL, TT_SLIDER_ALIGN_CENTER, 0, -35, 10, 50, 0, 255, 1) -> scale = TT_SLIDER_SCALE_LINEAR;
tt_sliderInit("Exp", &sliderVar, TT_SLIDER_TYPE_VERTICAL, TT_SLIDER_ALIGN_RIGHT, 100, -35, 10, 50, 0, 255, 1) -> scale = TT_SLIDER_SCALE_EXP;
tt_scrollbar_t *scrollbarX = tt_scrollbarInit(NULL, TT_SCROLLBAR_TYPE_HORIZONTAL, 20, -170, 10, 550, 50);
tt_scrollbar_t *scrollbarY = tt_scrollbarInit(NULL, TT_SCROLLBAR_TYPE_VERTICAL, 310, 0, 10, 320, 33);
list_t *dropdownOptions = list_init();
list_append(dropdownOptions, (unitype) "Indicator", 's');
list_append(dropdownOptions, (unitype) "Register", 's');
list_append(dropdownOptions, (unitype) "P15 Pin", 's');
list_append(dropdownOptions, (unitype) "K50 Touch", 's');
tt_dropdown_t *dropdown = tt_dropdownInit("Dropdown", dropdownOptions, NULL, TT_DROPDOWN_ALIGN_CENTER, 0, 70, 10);
tt_textbox_t *username = tt_textboxInit("Username", NULL, 128, -50, -110, 10, 100);
tt_textbox_t *password = tt_textboxInit("Password", NULL, 128, -50, -135, 10, 100);
list_t *contextOptions = list_init();
list_append(contextOptions, (unitype) "Button", 's');
list_append(contextOptions, (unitype) "Switch", 's');
list_append(contextOptions, (unitype) "Dial", 's');
list_append(contextOptions, (unitype) "Slider", 's');
list_append(contextOptions, (unitype) "Textbox", 's');
list_append(contextOptions, (unitype) "Dropdown", 's');
list_append(contextOptions, (unitype) "Scrollbar", 's');
list_append(contextOptions, (unitype) "Context", 's');
tt_context_t *context = tt_contextInit(contextOptions, NULL, 0, 0, 10);
context -> enabled = TT_ELEMENT_HIDE;
double x = 103, y = 95, z = 215;
list_t *sources = list_init();
list_append(sources, (unitype) "None", 's');
list_append(sources, (unitype) "SP932", 's');
list_append(sources, (unitype) "SP932U", 's');
list_append(sources, (unitype) "SP928", 's');
list_append(sources, (unitype) "SP1203", 's');
list_append(sources, (unitype) "SP-1550M", 's');
tt_dialInit("Power", NULL, TT_DIAL_SCALE_LINEAR, -150, -210, 10, 0, 100, 1);
tt_dialInit("Speed", NULL, TT_DIAL_SCALE_LINEAR, -100, -210, 10, 0, 1000, 1);
tt_dialInit("Exposure", NULL, TT_DIAL_SCALE_EXP, -50, -210, 10, 0, 1000, 1);
tt_dropdownInit("Source", sources, NULL, TT_DROPDOWN_ALIGN_LEFT, -10, -211.2, 10);
tt_slider_t *xSlider = tt_sliderInit("", &x, TT_SLIDER_TYPE_HORIZONTAL, TT_SLIDER_ALIGN_CENTER, -100, -240, 10, 100, -300, 300, 0);
tt_slider_t *ySlider = tt_sliderInit("", &y, TT_SLIDER_TYPE_HORIZONTAL, TT_SLIDER_ALIGN_CENTER, -100, -260, 10, 100, -300, 300, 0);
tt_slider_t *zSlider = tt_sliderInit("", &z, TT_SLIDER_TYPE_HORIZONTAL, TT_SLIDER_ALIGN_CENTER, -100, -280, 10, 100, -300, 300, 0);
tt_switchInit("", NULL, -10, -240, 10);
tt_switchInit("", NULL, -10, -260, 10);
tt_switchInit("", NULL, -10, -280, 10);
tt_switch_t *sideswipe = tt_switchInit("Side Swipe", NULL, 305, 15, 10);
tt_switch_t *checkbox = tt_switchInit("Checkbox", NULL, 300, 0, 10);
tt_switch_t *xbox = tt_switchInit("Xbox", NULL, 300, -15, 10);
sideswipe -> style = TT_SWITCH_STYLE_SIDESWIPE_LEFT;
checkbox -> value = 1;
checkbox -> style = TT_SWITCH_STYLE_CHECKBOX;
xbox -> value = 1;
xbox -> style = TT_SWITCH_STYLE_XBOX;
tt_button_t *textButton = tt_buttonInit("Text Button", NULL, 330, -30, 10);
tt_button_t *circleButton = tt_buttonInit("Circle Button", NULL, 338, -100, 10);
textButton -> shape = TT_BUTTON_SHAPE_TEXT;
circleButton -> shape = TT_BUTTON_SHAPE_CIRCLE;
uint64_t tick = 0; // count number of ticks since application started
tt_readerInit("tick", (unitype *) &tick, 'l', -315, 155, 10);
tt_readerInit("tt_globals.elementLogicTypeOld", (unitype *) &tt_globals.elementLogicTypeOld, 'i', -315, 135, 10);
tt_readerInit("tt_globals.elementLogicIndexOld", (unitype *) &tt_globals.elementLogicIndexOld, 'i', -315, 115, 10);
tt_reader_t *listReader = tt_readerInit("Sources", (unitype *) &sources, 'r', -315, 95, 10);
listReader -> height = 175;
listReader -> width = 100;
list_t *xPositions = list_init();
list_t *yPositions = list_init();
for (int32_t i = 0; i < tt_elements.all -> length; i++) {
list_append(xPositions, (unitype) ((tt_button_t *) tt_elements.all -> data[i].p) -> x, 'd');
list_append(yPositions, (unitype) ((tt_button_t *) tt_elements.all -> data[i].p) -> y, 'd');
}
double scroll = 0.0;
double scrollFactor = 15;
char keys[8] = {0};
uint32_t tps = 120; // ticks per second (locked to fps in this case)
clock_t start, end;
// turtleBackgroundColor(13, 17, 23);
while (turtle.popupClose == 0) {
start = clock();
turtleGetMouseCoordinates();
turtleClear();
/* update element positions (scrollbar) */
for (int32_t i = 0; i < tt_elements.all -> length; i++) {
if (((tt_button_t *) tt_elements.all -> data[i].p) -> element != TT_ELEMENT_SCROLLBAR && ((tt_button_t *) tt_elements.all -> data[i].p) -> element != TT_ELEMENT_CONTEXT) {
if ((((tt_button_t *) tt_elements.all -> data[i].p) -> element == TT_ELEMENT_VARIABLE_READER || ((tt_button_t *) tt_elements.all -> data[i].p) -> element == TT_ELEMENT_LIST_READER) && (((tt_reader_t *) tt_elements.all -> data[i].p) -> status == TT_STATUS_CLICK || ((tt_reader_t *) tt_elements.all -> data[i].p) -> status == TT_STATUS_CLICK_FIRST_TICK)) {
xPositions -> data[i].d = ((tt_button_t *) tt_elements.all -> data[i].p) -> x + scrollbarX -> value * 5;
yPositions -> data[i].d = ((tt_button_t *) tt_elements.all -> data[i].p) -> y - scrollbarY -> value * 3.3;
continue;
}
((tt_button_t *) tt_elements.all -> data[i].p) -> x = xPositions -> data[i].d - scrollbarX -> value * 5;
((tt_button_t *) tt_elements.all -> data[i].p) -> y = yPositions -> data[i].d + scrollbarY -> value * 3.3;
}
}
/* write element annotations */
tt_setColor(TT_COLOR_TEXT);
turtleTextWriteString("X", xSlider -> x - xSlider -> length / 2 - xSlider -> size, xSlider -> y, xSlider -> size - 1, 100);
turtleTextWriteStringf(ySlider -> x + xSlider -> length / 2 + xSlider -> size, xSlider -> y, 4, 0, "%.01lf", round(x) / 10);
turtleTextWriteString("Y", xSlider -> x - ySlider -> length / 2 - xSlider -> size, ySlider -> y, xSlider -> size - 1, 100);
turtleTextWriteStringf(ySlider -> x + ySlider -> length / 2 + xSlider -> size, ySlider -> y, 4, 0, "%.01lf", round(y) / 10);
turtleTextWriteString("Z", zSlider -> x - zSlider -> length / 2 - xSlider -> size, zSlider -> y, xSlider -> size - 1, 100);
turtleTextWriteStringf(zSlider -> x + zSlider -> length / 2 + xSlider -> size, zSlider -> y, 4, 0, "%.01lf", round(z) / 10);
if (username -> mouseOver || password -> mouseOver) {
osToolsSetCursor(GLFW_IBEAM_CURSOR);
} else {
osToolsSetCursor(GLFW_ARROW_CURSOR);
}
/* write all characters supported */
turtleTextWriteUnicode("AÀÁĂÄÃÅĀĄÆBCĆČĊÇDĎĐÐEÈÉĚÊËĒĖĘƏFGĞĠHĦ", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 180, 10, 0);
turtleTextWriteUnicode("IÌÍÎÏĪİĮJKĶLĹĽĻŁĿMNŃŇÑŅOÒÓÔÖÕŐØŒPQRŔ", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 195, 10, 0);
turtleTextWriteUnicode("ŘSŚŠŞȘẞTŤȚÞUÙÚÛÜŮŰŪŲVWXYÝZŹŽŻaàáâăäã", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 210, 10, 0);
turtleTextWriteUnicode("åāąæbcćčċçdďđðeèéěêëēėęəfgğġhħiìíîïī", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 225, 10, 0);
turtleTextWriteUnicode("ıįjkķlĺľļłŀmnńňñņoòóôöõőøœpqrŕřsśšşș", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 240, 10, 0);
turtleTextWriteUnicode("ßtťțþuùúûüůűūųvwxyýzźžżАБВГҐҒДЂЕЁЄӘЖ", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 255, 10, 0);
turtleTextWriteUnicode("ӁЗИӢЙІЇЈКҚҜЛЉМНҢЊОӨПРСТЋУӮҮҰЎФХҲҺЦЧҶ", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 270, 10, 0);
turtleTextWriteUnicode("ҸЏШЩЪЫЬЭЮЯабвгґғдђеёєәжӂзиӣйіїјкқҝлљ", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 285, 10, 0);
turtleTextWriteUnicode("мнңњоөпрстћуӯүұўфхҳһцчҷҹџшщъыьэюя", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 300, 10, 0);
turtleTextWriteUnicode("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 315, 10, 0);
turtleTextWriteUnicode("αβγδεζηθικλμνξοπρσςτυφχψω", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 330, 10, 0);
turtleTextWriteUnicode("1234567890!@#$£€₺₽¥₩₹₣฿%^&*()`~-_=+[", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 345, 10, 0);
turtleTextWriteUnicode("{]}\\|;:‘'’“\"”,<.>/?½¨°︘📷📄📁😊", scrollbarX -> value * -5 + 260, scrollbarY -> value * 3.3 - 360, 10, 0);
turtleTextWriteStringRotated("Rotated Text", scrollbarX -> value * -5 - 100, scrollbarY -> value * 3.3 + 75, 9, 50, -15);
/* draw texture */
if (oldImageDropdown != imageDropdown -> value) {
if (cameraName) {
osToolsCameraClose(cameraName);
}
oldImageDropdown = imageDropdown -> value;
if (imageDropdown -> value == 0) {
cameraName = NULL;
if (cameraFrame) {
free(cameraFrame);
cameraFrame = NULL;
}
turtleTextureUnload(empvImage);
empvImage = turtleTextureLoad("images/EMPV.png");
} else {
cameraName = cameras -> data[(imageDropdown -> value - 1) * 4].s;
osToolsCameraOpen(cameraName);
if (cameraFrame) {
free(cameraFrame);
}
cameraFrame = malloc(cameras -> data[(imageDropdown -> value - 1) * 4 + 1].i * cameras -> data[(imageDropdown -> value - 1) * 4 + 2].i * 3);
}
}
if (cameraName) {
osToolsCameraReceive(cameraName, cameraFrame);
turtleTextureReplaceArray(empvImage, cameraFrame, cameras -> data[(imageDropdown -> value - 1) * 4 + 1].i, cameras -> data[(imageDropdown -> value - 1) * 4 + 2].i, GL_RGB);
double textureCenterX = 550;
double textureCenterY = -60.5;
double textureWidth = 300.0 / ((16.0 / 9) * ((double) cameras -> data[(imageDropdown -> value - 1) * 4 + 2].i / cameras -> data[(imageDropdown -> value - 1) * 4 + 1].i));
if (textureWidth > 300) {
textureWidth = 300;
}
double textureHeight = (16.0 / 9) * ((double) cameras -> data[(imageDropdown -> value - 1) * 4 + 2].i / cameras -> data[(imageDropdown -> value - 1) * 4 + 1].i) * 169.0;
if (textureHeight > 169) {
textureHeight = 169;
}
turtleTexture(empvImage, scrollbarX -> value * -5 + textureCenterX - textureWidth / 2, scrollbarY -> value * 3.3 + textureCenterY - textureHeight / 2, scrollbarX -> value * -5 + textureCenterX + textureWidth / 2, scrollbarY -> value * 3.3 + textureCenterY + textureHeight / 2, 0);
} else {
turtleTexture(empvImage, scrollbarX -> value * -5 + 400, scrollbarY -> value * 3.3 - 145, scrollbarX -> value * -5 + 700, scrollbarY -> value * 3.3 + 24, 0);
}
// turtlePenColor(0, 0, 0);
// turtle3DTriangle(-5, 0, 10, 5, 0, 10, 0, 5, 10);
scroll = turtleMouseWheel();
if (scroll != 0) {
if (turtleKeyPressed(GLFW_KEY_LEFT_SHIFT)) {
scrollbarX -> value -= scroll * scrollFactor;
if (scrollbarX -> value < 0) {
scrollbarX -> value = 0;
}
if (scrollbarX -> value > 100) {
scrollbarX -> value = 100;
}
} else {
scrollbarY -> value -= scroll * scrollFactor;
if (scrollbarY -> value < 0) {
scrollbarY -> value = 0;
}
if (scrollbarY -> value > 100) {
scrollbarY -> value = 100;
}
}
}
if (button -> value) {
button -> value = 0;
printf("button clicked\n");
}
if (circleButton -> value) {
circleButton -> value = 0;
printf("circle button clicked\n");
}
if (textButton -> value) {
textButton -> value = 0;
printf("text button clicked\n");
}
if (turtleMouseRight()) {
if (keys[1] == 0) {
keys[1] = 1;
context -> enabled = TT_ELEMENT_ENABLED;
context -> x = turtle.mouseX;
context -> y = turtle.mouseY;
}
} else {
keys[1] = 0;
}
turtleToolsUpdate(); // update turtleTools
tt_setColor(TT_COLOR_TEXT);
turtleTextWriteStringf(-310, -170, 5, 0, "%.2lf, %.2lf", turtle.mouseX, turtle.mouseY);
parseRibbonOutput(); // user defined function to use ribbon
parsePopupOutput(window); // user defined function to use popup
turtleUpdate(); // update the screen
end = clock();
while ((double) (end - start) / CLOCKS_PER_SEC < (1.0 / tps)) {
end = clock();
}
tick++;
}
if (cameraName) {
osToolsCameraClose(cameraName);
}
turtleFree();
glfwTerminate();
return 0;
}