-
Notifications
You must be signed in to change notification settings - Fork 8
/
PretextView.cpp
9739 lines (8238 loc) · 347 KB
/
PretextView.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
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2021 Ed Harry, Wellcome Sanger Institute
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define String_(x) #x
#define String(x) String_(x)
#define PretextView_Version "PretextView Version " String(PV)
#include "Header.h"
#ifdef DEBUG
#include <errno.h>
#endif
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#include <glad/glad.h>
#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wdocumentation"
#pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#include <GLFW/glfw3.h>
#pragma clang diagnostic pop
#include "TextureLoadQueue.cpp"
#include "ColorMapData.cpp"
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#pragma GCC diagnostic ignored "-Wpadded"
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wdouble-promotion"
#pragma GCC diagnostic ignored "-Wcomma"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion"
#define FONTSTASH_IMPLEMENTATION
#include "fontstash.h"
#define GLFONTSTASH_IMPLEMENTATION
#include "gl3corefontstash.h"
#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wcast-align"
#pragma GCC diagnostic ignored "-Wextra-semi-stmt"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wconditional-uninitialized"
#pragma GCC diagnostic ignored "-Wdouble-promotion"
#pragma GCC diagnostic ignored "-Wpadded"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#define STB_SPRINTF_IMPLEMENTATION
#include "stb_sprintf.h"
#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wcast-align"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wdouble-promotion"
#pragma GCC diagnostic ignored "-Wpadded"
#pragma GCC diagnostic ignored "-Wimplicit-int-conversion"
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_PNG
#ifndef DEBUG
#define STBI_ASSERT(x)
#endif
#include "stb_image.h"
#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#pragma GCC diagnostic ignored "-Wswitch-enum"
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#pragma GCC diagnostic ignored "-Wcomma"
#pragma GCC diagnostic ignored "-Wextra-semi-stmt"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#pragma GCC diagnostic ignored "-Wdouble-promotion"
#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion"
#define NK_PRIVATE
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_STANDARD_IO
#define NK_ZERO_COMMAND_MEMORY
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_IMPLEMENTATION
#define NK_INCLUDE_STANDARD_VARARGS
//#define NK_KEYSTATE_BASED_INPUT
#ifndef DEBUG
#define NK_ASSERT(x)
#endif
#include "nuklear.h"
#pragma clang diagnostic pop
#include "Resources.cpp"
global_variable
const
GLchar *
VertexSource_Texture = R"glsl(
#version 330
in vec2 position;
in vec3 texcoord;
out vec3 Texcoord;
uniform mat4 matrix;
void main()
{
Texcoord = texcoord;
gl_Position = matrix * vec4(position, 0.0, 1.0);
}
)glsl";
global_variable
const
GLchar *
FragmentSource_Texture = R"glsl(
#version 330
in vec3 Texcoord;
out vec4 outColor;
uniform sampler2DArray tex;
uniform usamplerBuffer pixstartlookup;
uniform usamplerBuffer pixrearrangelookup;
uniform uint pixpertex;
uniform uint ntex1dm1;
uniform float oopixpertex;
uniform samplerBuffer colormap;
uniform vec3 controlpoints;
float bezier(float t)
{
float tsq = t * t;
float omt = 1.0 - t;
float omtsq = omt * omt;
return((omtsq * controlpoints.x) + (2.0 * t * omt * controlpoints.y) + (tsq * controlpoints.z));
}
float linearTextureID(vec2 coords)
{
float min;
float max;
if (coords.x > coords.y)
{
min = coords.y;
max = coords.x;
}
else
{
min = coords.x;
max = coords.y;
}
int i = int(min);
return((min * ntex1dm1) -
((i & 1) == 1 ? (((i-1)>>1) * min) :
((i>>1)*(min-1))) + max);
}
// https://community.khronos.org/t/mipmap-level-calculation-using-dfdx-dfdy/67480
float mip_map_level(in vec2 texture_coordinate)
{
// The OpenGL Graphics System: A Specification 4.2
// - chapter 3.9.11, equation 3.21
vec2 dx_vtc = dFdx(texture_coordinate);
vec2 dy_vtc = dFdy(texture_coordinate);
float delta_max_sqr = max(dot(dx_vtc, dx_vtc), dot(dy_vtc, dy_vtc));
return 0.5 * log2(delta_max_sqr);
}
vec3 pixLookup(vec3 inCoords)
{
vec2 pix = floor(inCoords.xy * pixpertex);
vec2 over = inCoords.xy - (pix * oopixpertex);
vec2 pixStart = texelFetch(pixstartlookup, int(inCoords.z)).xy;
pix += pixStart;
pix = vec2(texelFetch(pixrearrangelookup, int(pix.x)).x, texelFetch(pixrearrangelookup, int(pix.y)).x);
if (pix.y > pix.x)
{
pix = vec2(pix.y, pix.x);
over = vec2(over.y, over.x);
}
vec2 tileCoord = pix * oopixpertex;
vec2 tileCoordFloor = floor(tileCoord);
float z = linearTextureID(tileCoordFloor);
pix = tileCoord - tileCoordFloor;
pix = clamp(pix + over, vec2(0, 0), vec2(1, 1));
return(vec3(pix, z));
}
// https://www.codeproject.com/Articles/236394/Bi-Cubic-and-Bi-Linear-Interpolation-with-GLSL/
float BiLinear( vec3 inCoord, vec2 texSize, float lod )
{
vec2 texelSize = 1.0 / texSize;
vec3 coord = pixLookup(inCoord);
float p0q0 = textureLod(tex, coord, lod).r;
float p1q0 = textureLod(tex, pixLookup(inCoord + vec3(texelSize.x, 0, 0)), lod).r;
float p0q1 = textureLod(tex, pixLookup(inCoord + vec3(0, texelSize.y, 0)), lod).r;
float p1q1 = textureLod(tex, pixLookup(inCoord + vec3(texelSize, 0)), lod).r;
float a = fract( inCoord.x * texSize.x ); // Get Interpolation factor for X direction.
// Fraction near to valid data.
float b = fract( inCoord.y * texSize.y );// Get Interpolation factor for Y direction.
float pInterp_q0 = mix( p0q0, p1q0, a ); // Interpolates top row in X direction.
float pInterp_q1 = mix( p0q1, p1q1, a ); // Interpolates bottom row in X direction.
return mix( pInterp_q0, pInterp_q1, b ); // Interpolate in Y direction.
}
void main()
{
float mml = mip_map_level(Texcoord.xy * textureSize(tex, 0).xy);
float floormml = floor(mml);
float f1 = BiLinear(Texcoord, textureSize(tex, 0).xy, floormml);
float f2 = BiLinear(Texcoord, textureSize(tex, 0).xy, floormml + 1);
float value = bezier(mix(f1, f2, fract(mml)));
int idx = int(round(value * 0xFF));
outColor = vec4(texelFetch(colormap, idx).rgb, 1.0);
}
)glsl";
global_variable
const
GLchar *
VertexSource_Flat = R"glsl(
#version 330
in vec2 position;
uniform mat4 matrix;
void main()
{
gl_Position = matrix * vec4(position, 0.0, 1.0);
}
)glsl";
global_variable
const
GLchar *
FragmentSource_Flat = R"glsl(
#version 330
out vec4 outColor;
uniform vec4 color;
void main()
{
outColor = color;
}
)glsl";
global_variable
const
GLchar *
VertexSource_EditablePlot = R"glsl(
#version 330
in float position;
uniform usamplerBuffer pixrearrangelookup;
uniform samplerBuffer yvalues;
uniform float ytop;
uniform float yscale;
void main()
{
float x = position;
float realx = texelFetch(pixrearrangelookup, int(x)).x;
x /= textureSize(pixrearrangelookup);
x -= 0.5;
float y = texelFetch(yvalues, int(realx)).x;
y *= yscale;
y += ytop;
gl_Position = vec4(x, y, 0.0, 1.0);
}
)glsl";
global_variable
const
GLchar *
FragmentSource_EditablePlot = R"glsl(
#version 330
out vec4 outColor;
uniform vec4 color;
void main()
{
outColor = color;
}
)glsl";
// https://blog.tammearu.eu/posts/gllines/
global_variable
const
GLchar *
GeometrySource_EditablePlot = R"glsl(
#version 330
layout (lines) in;
layout (triangle_strip, max_vertices = 4) out;
uniform mat4 matrix;
uniform float linewidth;
void main()
{
vec3 start = gl_in[0].gl_Position.xyz;
vec3 end = gl_in[1].gl_Position.xyz;
vec3 lhs = cross(normalize(end-start), vec3(0.0, 0.0, -1.0));
lhs *= linewidth*0.0007;
gl_Position = matrix * vec4(start+lhs, 1.0);
EmitVertex();
gl_Position = matrix * vec4(start-lhs, 1.0);
EmitVertex();
gl_Position = matrix * vec4(end+lhs, 1.0);
EmitVertex();
gl_Position = matrix * vec4(end-lhs, 1.0);
EmitVertex();
EndPrimitive();
}
)glsl";
#define UI_SHADER_LOC_POSITION 0
#define UI_SHADER_LOC_TEXCOORD 1
#define UI_SHADER_LOC_COLOR 2
global_variable
const
GLchar *
VertexSource_UI = R"glsl(
#version 330
layout (location = 0) in vec2 position;
layout (location = 1) in vec2 texcoord;
out vec2 Texcoord;
layout (location = 2) in vec4 color;
out vec4 Color;
uniform mat4 matrix;
void main()
{
Texcoord = texcoord;
Color = color;
gl_Position = matrix * vec4(position, 0.0, 1.0);
}
)glsl";
global_variable
const
GLchar *
FragmentSource_UI = R"glsl(
#version 330
in vec2 Texcoord;
in vec4 Color;
out vec4 outColor;
uniform sampler2D tex;
void main()
{
outColor = texture(tex, Texcoord) * Color;
}
)glsl";
struct
tex_vertex
{
f32 x, y, pad;
f32 s, t, u;
};
struct
vertex
{
f32 x, y;
};
global_variable
memory_arena
Working_Set;
global_variable
thread_pool *
Thread_Pool;
global_variable
u32
Redisplay = 0;
global_variable
s32
Window_Width, Window_Height, FrameBuffer_Width, FrameBuffer_Height;
global_variable
struct nk_vec2
Screen_Scale;
enum
theme
{
THEME_BLACK,
THEME_WHITE,
THEME_RED,
THEME_BLUE,
THEME_DARK,
THEME_COUNT
};
global_variable
theme
Current_Theme;
global_variable
u08 *
Theme_Name[THEME_COUNT];
global_function
void
SetTheme(struct nk_context *ctx, enum theme theme);
global_variable
nk_context *
NK_Context;
global_function
void
ChangeSize(s32 width, s32 height)
{
glViewport(0, 0, width, height);
}
global_function
void
UpdateScreenScale()
{
Screen_Scale.x = (f32)FrameBuffer_Width / (f32)Window_Width;
Screen_Scale.y = (f32)FrameBuffer_Height / (f32)Window_Height;
SetTheme(NK_Context, Current_Theme);
}
global_function
void
GLFWChangeFrameBufferSize(GLFWwindow *win, s32 width, s32 height)
{
(void)win;
ChangeSize(width, height);
Redisplay = 1;
FrameBuffer_Height = height;
FrameBuffer_Width = width;
UpdateScreenScale();
}
global_function
void
GLFWChangeWindowSize(GLFWwindow *win, s32 width, s32 height)
{
(void)win;
Window_Width = width;
Window_Height = height;
UpdateScreenScale();
}
struct
contact_matrix
{
GLuint textures;
GLuint pixelStartLookupBuffer;
GLuint pixelRearrangmentLookupBuffer;
GLuint pixelStartLookupBufferTex;
GLuint pixelRearrangmentLookupBufferTex;
GLint pad;
GLuint *vaos;
GLuint *vbos;
GLuint shaderProgram;
GLint matLocation;
};
struct
flat_shader
{
GLuint shaderProgram;
GLint matLocation;
GLint colorLocation;
u32 pad;
};
struct
ui_shader
{
GLuint shaderProgram;
GLint matLocation;
};
struct
editable_plot_shader
{
GLuint shaderProgram;
GLuint yValuesBuffer;
GLuint yValuesBufferTex;
GLint matLocation;
GLint colorLocation;
GLint yScaleLocation;
GLint yTopLocation;
GLint lineSizeLocation;
};
struct
quad_data
{
GLuint *vaos;
GLuint *vbos;
u32 nBuffers;
u32 pad;
};
struct
color_maps
{
GLuint *maps;
u32 currMap;
u32 nMaps;
GLint cpLocation;
GLfloat controlPoints[3];
struct nk_image *mapPreviews;
};
struct
nk_glfw_vertex
{
f32 position[2];
f32 uv[2];
nk_byte col[4];
};
struct
device
{
u08 *lastContextMemory;
struct nk_buffer cmds;
struct nk_draw_null_texture null;
GLuint vbo, vao, ebo;
GLuint prog;
GLuint vert_shdr;
GLuint frag_shdr;
GLint attrib_pos;
GLint attrib_uv;
GLint attrib_col;
GLint uniform_tex;
GLint uniform_proj;
GLuint font_tex;
};
global_variable
device *
NK_Device;
global_variable
nk_font_atlas *
NK_Atlas;
global_variable
nk_font *
NK_Font;
global_variable
nk_font *
NK_Font_Browser;
global_variable
color_maps *
Color_Maps;
#ifdef Internal
global_variable
quad_data *
Texture_Tile_Grid;
global_variable
quad_data *
QuadTree_Data;
#endif
global_variable
quad_data *
Grid_Data;
global_variable
quad_data *
Contig_ColourBar_Data;
global_variable
quad_data *
Scaff_Bar_Data;
global_variable
quad_data *
Edit_Mode_Data;
global_variable
quad_data *
Label_Box_Data;
global_variable
quad_data *
Scale_Bar_Data;
global_variable
quad_data *
Tool_Tip_Data;
global_variable
quad_data *
Waypoint_Data;
global_variable
ui_shader *
UI_Shader;
global_variable
flat_shader *
Flat_Shader;
global_variable
contact_matrix *
Contact_Matrix;
global_variable
threadSig
Texture_Ptr = 0;
global_variable
volatile texture_buffer *
Current_Loaded_Texture = 0;
global_variable
u32
Texture_Resolution;
global_variable
u32
Number_of_MipMaps;
global_variable
u32
Number_of_Textures_1D;
global_variable
u32
Number_of_Pixels_1D;
global_variable
u32
Bytes_Per_Texture;
global_variable
texture_buffer_queue *
Texture_Buffer_Queue;
struct
pointi
{
s32 x;
s32 y;
};
struct
pointui
{
u32 x, y;
};
struct
pointd
{
f64 x;
f64 y;
};
struct
point2f
{
f32 x;
f32 y;
};
struct
quad
{
point2f corner[2];
};
struct
point3f
{
f32 x;
f32 y;
f32 z;
};
global_variable
pointd
Mouse_Move;
struct
tool_tip
{
pointui pixels;
point2f worldCoords;
};
global_variable
tool_tip
Tool_Tip_Move;
struct
edit_pixels
{
pointui pixels;
point2f worldCoords;
pointui selectPixels;
u08 editing : 1;
u08 selecting : 1;
u08 scaffSelecting : 1;
u08 snap : 1;
};
global_variable
edit_pixels
Edit_Pixels;
global_variable
point3f
Camera_Position;
global_variable
FONScontext *
FontStash_Context;
struct
ui_colour_element_bg
{
u32 on;
nk_colorf fg;
nk_colorf bg;
f32 size;
};
#define Grey_Background {0.569f, 0.549f, 0.451f, 1.0f}
#define Yellow_Text_Float {0.941176471f, 0.725490196f, 0.058823529f, 1.0f}
#define Red_Text_Float {0.941176471f, 0.039215686f, 0.019607843f, 1.0f}
#define Green_Float {0.3f, 0.6f, 0.0f, 0.2f}
#define Red_Float {0.6f, 0.3f, 0.0f, 0.2f}
#define Blue_Float {0.0f, 0.3f, 0.6f, 0.2f}
#define Red_Full {1.0f, 0.0f, 0.0f, 1.0f}
#define Blue_Full {0.0f, 0.0f, 1.0f, 1.0f}
global_variable
ui_colour_element_bg *
Contig_Name_Labels;
global_variable
ui_colour_element_bg *
Scale_Bars;
global_variable
ui_colour_element_bg *
Tool_Tip;
global_variable
u32
Waypoints_Always_Visible = 1;
global_variable
u08
Scaffs_Always_Visible = 1;
global_variable
u08
MetaData_Always_Visible = 1;
struct
ui_colour_element
{
u32 on;
nk_colorf bg;
f32 size;
};
global_variable
ui_colour_element *
Grid;
global_variable
ui_colour_element *
Contig_Ids;
#ifdef Internal
global_variable
ui_colour_element *
Tiles;
global_variable
ui_colour_element *
QuadTrees;
#endif
struct
edit_mode_colours
{
nk_colorf preSelect;
nk_colorf select;
nk_colorf invSelect;
nk_colorf fg;
nk_colorf bg;
};
global_variable
edit_mode_colours *
Edit_Mode_Colours;
struct
waypoint_mode_data
{
nk_colorf base;
nk_colorf selected;
nk_colorf text;
nk_colorf bg;
f32 size;
};
global_variable
waypoint_mode_data *
Waypoint_Mode_Data;
struct
meta_mode_data
{
nk_colorf text;
nk_colorf bg;
f32 size;
};
global_variable
meta_mode_data *
Scaff_Mode_Data;
global_variable
meta_mode_data *
MetaData_Mode_Data;
global_variable
u32
UI_On = 0;
enum
global_mode
{
mode_normal = 0,
mode_edit = 1,
mode_waypoint_edit = 2,
mode_scaff_edit = 3,
mode_meta_edit = 4
};
global_variable
global_mode
Global_Mode = mode_normal;
#define Edit_Mode (Global_Mode == mode_edit)
#define Normal_Mode (Global_Mode == mode_normal)
#define Waypoint_Edit_Mode (Global_Mode == mode_waypoint_edit)
#define Scaff_Edit_Mode (Global_Mode == mode_scaff_edit)
#define MetaData_Edit_Mode (Global_Mode == mode_meta_edit)
global_variable
s32
Font_Normal = FONS_INVALID;
global_variable
s32
Font_Bold = FONS_INVALID;
global_function
void
ClampCamera()
{
Camera_Position.z = Min(Max(Camera_Position.z, 1.0f), ((f32)(Pow2((Number_of_MipMaps + 1)))));
Camera_Position.x = Min(Max(Camera_Position.x, -0.5f), 0.5f);
Camera_Position.y = Min(Max(Camera_Position.y, -0.5f), 0.5f);
}
global_function
void
ZoomCamera(f32 dir)
{
f32 scrollFactor = 1.1f;
scrollFactor += dir > 0.0f ? dir : -dir;
Camera_Position.z *= (dir > 0.0f ? scrollFactor : (1.0f / scrollFactor));
ClampCamera();
}
global_variable
u32
Loading = 0;
global_function
s32
RearrangeMap(u32 pixelFrom, u32 pixelTo, s32 delta, u08 snap = 0);
global_function
void
InvertMap(u32 pixelFrom, u32 pixelTo);
global_variable
u32
Global_Edit_Invert_Flag = 0;
global_variable
u08
Scaff_Painting_Flag = 0;
global_variable
u08
Scaff_FF_Flag = 0;
global_variable
u32
Scaff_Painting_Id = 0;
struct
original_contig
{
u32 name[16];
u32 *contigMapPixels;
u32 nContigs;
u32 pad;
};
global_variable
original_contig *
Original_Contigs;
global_variable
u32
Number_of_Original_Contigs;
struct
contig
{
u64 *metaDataFlags;
u32 originalContigId;
u32 length;
u32 startCoord;
u32 scaffId;
u32 pad;
};
struct
contigs
{
u08 *contigInvertFlags;
contig *contigs;
u32 numberOfContigs;
u32 pad;
};
global_variable