1.3.64
 
Loading...
Searching...
No Matches
Visualizer.h
Go to the documentation of this file.
1
16#ifndef HELIOS_VISUALIZER
17#define HELIOS_VISUALIZER
18
19#include "Context.h"
20
21// GLM Libraries (math-related functions for graphics)
22#define GLM_FORCE_RADIANS
23#ifndef APIENTRY
24#define APIENTRY
25#endif
26#include <GLFW/glfw3.h>
27#include "glm/glm.hpp"
28#include "glm/gtc/matrix_transform.hpp"
29#include "glm/gtx/transform.hpp"
30
31#include "GeometryHandler.h"
32
33class Visualizer;
34
35
46bool validateTextureFile(const std::string &texture_file, bool pngonly = false);
47
49void mouseCallback(GLFWwindow *window, int button, int action, int mods);
50
52void cursorCallback(GLFWwindow *window, double x, double y);
53
55void scrollCallback(GLFWwindow *window, double xoffset, double yoffset);
56
58class Glyph {
59public:
60 Glyph() = default;
61 Glyph(const helios::uint2 &size, const std::vector<std::vector<unsigned char>> &data) : size(size), data(data) {
62 }
63 helios::uint2 size;
64 std::vector<std::vector<unsigned char>> data;
65};
66
68struct Shader {
69
71 void disableTextures() const;
72
74 void enableTextureMaps() const;
75
77 void enableTextureMasks() const;
78
80 void setTransformationMatrix(const glm::mat4 &matrix) const;
81
83 void setViewMatrix(const glm::mat4 &matrix) const;
84
86 void setProjectionMatrix(const glm::mat4 &matrix) const;
87
89 void setDepthBiasMatrix(const glm::mat4 &matrix) const;
90
92 void setLightDirection(const helios::vec3 &direction) const;
93
95 void setLightingModel(uint lightingmodel) const;
96
98 void setLightIntensity(float lightintensity) const;
99
101 void useShader() const;
102
104
110 void initialize(const char *vertex_shader_file, const char *fragment_shader_file, Visualizer *visualizer_ptr, const char *geometry_shader_file = nullptr);
111
112 ~Shader();
113
114 // Primary Shader
115 uint shaderID;
116 GLint textureUniform;
117 GLint shadowmapUniform;
118 GLint transformMatrixUniform;
119 GLint viewMatrixUniform;
120 GLint projectionMatrixUniform;
121 GLint depthBiasUniform;
122 GLint lightDirectionUniform;
123 GLint lightingModelUniform;
124 GLint RboundUniform;
125 GLint lightIntensityUniform;
126 std::vector<GLuint> vertex_array_IDs;
127 GLint uvRescaleUniform;
128
129 // Texture buffer uniform locations (cached to avoid glGetUniformLocation during rendering)
130 GLint colorTextureObjectUniform;
131 GLint normalTextureObjectUniform;
132 GLint textureFlagTextureObjectUniform;
133 GLint textureIDTextureObjectUniform;
134 GLint coordinateFlagTextureObjectUniform;
135 GLint skyGeometryFlagTextureObjectUniform;
136 GLint hiddenFlagTextureObjectUniform;
137
139 bool initialized = false;
140};
141
143struct Colormap {
144
145 Colormap() : cmapsize(0), minval(0.0f), maxval(1.0f) {};
146
147 Colormap(const std::vector<helios::RGBcolor> &ctable, const std::vector<float> &clocs, int size, float minval_, float maxval_) : cmapsize(size), minval(minval_), maxval(maxval_) {
148 set(ctable, clocs, size, minval_, maxval_);
149 }
150
151 void set(const std::vector<helios::RGBcolor> &ctable, const std::vector<float> &clocs, int size, float a_minval, float a_maxval) {
152 cmapsize = size;
153 minval = a_minval;
154 maxval = a_maxval;
155
156 size_t Ncolors = ctable.size();
157
158 assert(clocs.size() == Ncolors && minval < maxval);
159
160 cmap.resize(Ncolors);
161
162 std::vector<float> cinds;
163 cinds.resize(Ncolors);
164
165 for (uint i = 0; i < Ncolors; i++) {
166 cinds.at(i) = clocs.at(i) * static_cast<float>(cmapsize - 1);
167 }
168
169 cmap.resize(cmapsize);
170 for (uint c = 0; c < Ncolors - 1; c++) {
171 float cmin = cinds.at(c);
172 float cmax = cinds.at(c + 1);
173
174 for (uint i = 0; i < cmapsize; i++) {
175 auto i_f = static_cast<float>(i);
176
177 if (i_f >= cmin && i_f <= cmax) {
178 cmap.at(i).r = ctable.at(c).r + (i_f - cmin) / (cmax - cmin) * (ctable.at(c + 1).r - ctable.at(c).r);
179 cmap.at(i).g = ctable.at(c).g + (i_f - cmin) / (cmax - cmin) * (ctable.at(c + 1).g - ctable.at(c).g);
180 cmap.at(i).b = ctable.at(c).b + (i_f - cmin) / (cmax - cmin) * (ctable.at(c + 1).b - ctable.at(c).b);
181 }
182 }
183 }
184 }
185
186 [[nodiscard]] helios::RGBcolor query(float x) const {
187 assert(cmapsize > 0 && !cmap.empty());
188
189 helios::RGBcolor color;
190
191 uint color_ind;
192 if (minval == maxval) {
193 color_ind = 0;
194 } else {
195 float normalized_pos = (x - minval) / (maxval - minval) * float(cmapsize - 1);
196
197 // Handle values below minimum range
198 if (normalized_pos < 0) {
199 color_ind = 0;
200 }
201 // Handle values above maximum range
202 else if (normalized_pos > float(cmapsize - 1)) {
203 color_ind = cmapsize - 1;
204 }
205 // Handle values within range
206 else {
207 color_ind = std::round(normalized_pos);
208 }
209 }
210
211 color.r = cmap.at(color_ind).r;
212 color.g = cmap.at(color_ind).g;
213 color.b = cmap.at(color_ind).b;
214
215 return color;
216 }
217
218 void setRange(float min, float max) {
219 minval = min;
220 maxval = max;
221 }
222
223 [[nodiscard]] helios::vec2 getRange() const {
224 return {minval, maxval};
225 }
226
227 [[nodiscard]] float getLowerLimit() const {
228 return minval;
229 }
230
231 [[nodiscard]] float getUpperLimit() const {
232 return maxval;
233 }
234
235private:
236 std::vector<helios::RGBcolor> cmap;
237 unsigned int cmapsize;
238 float minval, maxval;
239};
240
242
254int read_JPEG_file(const char *filename, std::vector<unsigned char> &texture, uint &height, uint &width);
255
257
267int write_JPEG_file(const char *filename, uint width, uint height, bool buffers_swapped_since_render, bool print_messages);
268
270
282int write_JPEG_file(const char *filename, uint width, uint height, const std::vector<helios::RGBcolor> &data, bool print_messages);
283
285
297int write_PNG_file(const char *filename, uint width, uint height, bool buffers_swapped_since_render, bool transparent_background, bool print_messages);
298
300
312int write_PNG_file(const char *filename, uint width, uint height, const std::vector<helios::RGBAcolor> &data, bool print_messages);
313
315
324void read_png_file(const char *filename, std::vector<unsigned char> &texture, uint &height, uint &width);
325
328public:
330 Visualizer() = delete;
331
333
336 explicit Visualizer(uint Wdisplay);
337
339
343 Visualizer(uint Wdisplay, uint Hdisplay);
344
346
351 Visualizer(uint Wdisplay, uint Hdisplay, int aliasing_samples);
352
355
362 Visualizer(uint Wdisplay, uint Hdisplay, int aliasing_samples, bool window_decorations, bool headless);
363
365 ~Visualizer();
366
368 static int selfTest(int argc = 0, char **argv = nullptr);
369
371 void enableMessages();
372
374 void disableMessages();
375
385
405
407
411 void setCameraPosition(const helios::vec3 &cameraPosition, const helios::vec3 &lookAt);
412
414
418 void setCameraPosition(const helios::SphericalCoord &cameraAngle, const helios::vec3 &lookAt);
419
421
424 void setCameraFieldOfView(float angle_FOV);
425
427
430 void setLightDirection(const helios::vec3 &direction);
431
443
445
449 void setLightingModel(LightingModel lightingmodel);
450
452
455 void setLightIntensityFactor(float lightintensityfactor);
456
459
462
463
466
468
471 void setBackgroundColor(const helios::RGBcolor &color);
472
474
482
484
491 void setBackgroundImage(const char *texture_file);
492
494
503 void setBackgroundSkyTexture(const char *texture_file = nullptr, uint Ndivisions = 50);
504
506
513 size_t addRectangleByCenter(const helios::vec3 &center, const helios::vec2 &size, const helios::SphericalCoord &rotation, const helios::RGBcolor &color, CoordinateSystem coordFlag);
514
516
523 size_t addRectangleByCenter(const helios::vec3 &center, const helios::vec2 &size, const helios::SphericalCoord &rotation, const helios::RGBAcolor &color, CoordinateSystem coordFlag);
524
526
533 size_t addRectangleByCenter(const helios::vec3 &center, const helios::vec2 &size, const helios::SphericalCoord &rotation, const char *texture_file, CoordinateSystem coordFlag);
534
536
544 size_t addRectangleByCenter(const helios::vec3 &center, const helios::vec2 &size, const helios::SphericalCoord &rotation, const helios::RGBcolor &color, const char *texture_file, CoordinateSystem coordFlag);
545
547
555 size_t addRectangleByCenter(const helios::vec3 &center, const helios::vec2 &size, const helios::SphericalCoord &rotation, const helios::RGBcolor &color, const Glyph *glyph, CoordinateSystem coordFlag);
556
558
563 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const helios::RGBcolor &color, CoordinateSystem coordFlag);
564
566
571 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const helios::RGBAcolor &color, CoordinateSystem coordFlag);
572
574
579 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const char *texture_file, CoordinateSystem coordFlag);
580
582
588 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const char *texture_file, const std::vector<helios::vec2> &uvs, CoordinateSystem coordFlag);
589
591
598 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const helios::RGBcolor &color, const char *texture_file, const std::vector<helios::vec2> &uvs, CoordinateSystem coordFlag);
599
601
607 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const helios::RGBcolor &color, const char *texture_file, CoordinateSystem coordFlag);
608
610
616 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const helios::RGBcolor &color, const Glyph *glyph, CoordinateSystem coordFlag);
617
619
625 size_t addRectangleByVertices(const std::vector<helios::vec3> &vertices, const helios::RGBAcolor &color, const Glyph *glyph, CoordinateSystem coordFlag);
626
628
635 size_t addTriangle(const helios::vec3 &vertex0, const helios::vec3 &vertex1, const helios::vec3 &vertex2, const helios::RGBcolor &color, CoordinateSystem coordFlag);
636
638
645 size_t addTriangle(const helios::vec3 &vertex0, const helios::vec3 &vertex1, const helios::vec3 &vertex2, const helios::RGBAcolor &color, CoordinateSystem coordFlag);
646
648
658 size_t addTriangle(const helios::vec3 &vertex0, const helios::vec3 &vertex1, const helios::vec3 &vertex2, const char *texture_file, const helios::vec2 &uv0, const helios::vec2 &uv1, const helios::vec2 &uv2, CoordinateSystem coordFlag);
659
661
672 size_t addTriangle(const helios::vec3 &vertex0, const helios::vec3 &vertex1, const helios::vec3 &vertex2, const char *texture_file, const helios::vec2 &uv0, const helios::vec2 &uv1, const helios::vec2 &uv2, const helios::RGBAcolor &color,
673 CoordinateSystem coordFlag);
674
676
683 std::vector<size_t> addVoxelByCenter(const helios::vec3 &center, const helios::vec3 &size, const helios::SphericalCoord &rotation, const helios::RGBcolor &color, CoordinateSystem coordFlag);
684
686
693 std::vector<size_t> addVoxelByCenter(const helios::vec3 &center, const helios::vec3 &size, const helios::SphericalCoord &rotation, const helios::RGBAcolor &color, CoordinateSystem coordFlag);
694
696
702 size_t addLine(const helios::vec3 &start, const helios::vec3 &end, const helios::RGBcolor &color, CoordinateSystem coordinate_system);
703
705
711 size_t addLine(const helios::vec3 &start, const helios::vec3 &end, const helios::RGBAcolor &color, CoordinateSystem coordFlag);
712
714
722 size_t addLine(const helios::vec3 &start, const helios::vec3 &end, const helios::RGBcolor &color, float line_width, CoordinateSystem coordinate_system);
723
725
733 size_t addLine(const helios::vec3 &start, const helios::vec3 &end, const helios::RGBAcolor &color, float line_width, CoordinateSystem coordFlag);
734
736
742 size_t addPoint(const helios::vec3 &position, const helios::RGBcolor &color, float pointsize, CoordinateSystem coordinate_system);
743
745
751 size_t addPoint(const helios::vec3 &position, const helios::RGBAcolor &color, float pointsize, CoordinateSystem coordinate_system);
752
754
761 std::vector<size_t> addSphereByCenter(float radius, const helios::vec3 &center, uint Ndivisions, const helios::RGBcolor &color, CoordinateSystem coordinate_system);
762
764
771 std::vector<size_t> addSphereByCenter(float radius, const helios::vec3 &center, uint Ndivisions, const helios::RGBAcolor &color, CoordinateSystem coordinate_system);
772
774
782 [[deprecated]]
783 std::vector<size_t> addSkyDomeByCenter(float radius, const helios::vec3 &center, uint Ndivisions, const char *texture_file);
784
786
787 [[deprecated]]
788 void addSkyDomeByCenter(float radius, const helios::vec3 &center, uint Ndivisions, const char *texture_file, int layer);
789
791
799 std::vector<size_t> addTextboxByCenter(const char *textstring, const helios::vec3 &center, const helios::SphericalCoord &rotation, const helios::RGBcolor &fontcolor, uint fontsize, const char *fontname, CoordinateSystem coordinate_system);
800
802
805 void deleteGeometry(size_t geometry_id);
806
808
813 [[nodiscard]] std::vector<helios::vec3> getGeometryVertices(size_t geometry_id) const;
814
816
821 void setGeometryVertices(size_t geometry_id, const std::vector<helios::vec3> &vertices);
822
824 void addCoordinateAxes();
825
827
832 void addCoordinateAxes(const helios::vec3 &origin, const helios::vec3 &length, const std::string &sign);
833
836
838
843 void addGridWireFrame(const helios::vec3 &center, const helios::vec3 &size, const helios::int3 &subdiv);
844
846 void enableColorbar();
847
849 void disableColorbar();
850
852
855 void setColorbarPosition(helios::vec3 position);
856
858
861 void setColorbarSize(helios::vec2 size);
862
864
868 void setColorbarRange(float cmin, float cmax);
869
871
875 void setColorbarTicks(const std::vector<float> &ticks);
876
878
881 void setColorbarTitle(const char *title);
882
884
888
890
893 void setColorbarFontSize(uint font_size);
894
896
900 void setColormap(Ctable colormap_name);
901
903
907 void setColormap(const std::vector<helios::RGBcolor> &colors, const std::vector<float> &divisions);
908
910 [[nodiscard]] Colormap getCurrentColormap() const;
911
913
918 static double niceNumber(double value, bool round);
919
921
927 static std::string formatTickLabel(double value, double spacing, bool isIntegerData);
928
930
937 static std::vector<float> generateNiceTicks(float dataMin, float dataMax, bool isIntegerData, int targetTicks = 5);
938
940
943 void buildContextGeometry(helios::Context *context_ptr);
944
946
950 void buildContextGeometry(helios::Context *context_ptr, const std::vector<uint> &UUIDs);
951
953
959
961
965 void colorContextPrimitivesByData(const char *data_name);
966
968
973 void colorContextPrimitivesByData(const char *data_name, const std::vector<uint> &UUIDs);
974
976
980 void colorContextPrimitivesByObjectData(const char *data_name);
981
983
988 void colorContextPrimitivesByObjectData(const char *data_name, const std::vector<uint> &ObjIDs);
989
991
995 void colorContextPrimitivesRandomly(const std::vector<uint> &UUIDs);
996
998
1002
1004
1007 void colorContextObjectsRandomly(const std::vector<uint> &ObjIDs);
1008
1010
1014
1016 void hideWatermark();
1017
1019 void showWatermark();
1020
1022 void updateWatermark();
1023
1025 void hideNavigationGizmo();
1026
1028 void showNavigationGizmo();
1029
1031
1035 void handleGizmoClick(double screen_x, double screen_y);
1036
1038
1042 void handleGizmoHover(double screen_x, double screen_y);
1043
1045 std::vector<helios::vec3> plotInteractive();
1046
1048
1051 void plotOnce(bool getKeystrokes);
1052
1054
1057 void plotDepthMap();
1058
1060 void plotUpdate();
1061
1063
1066 void plotUpdate(bool hide_window);
1067
1069 void printWindow();
1070
1072
1078 void printWindow(const char *outfile, const std::string &image_format = "jpeg");
1079
1091 void displayImage(const std::vector<unsigned char> &pixel_data, uint width_pixels, uint height_pixels);
1092
1100 void displayImage(const std::string &file_name);
1101
1103
1107 void getWindowPixelsRGB(uint *buffer) const;
1108
1110
1113 [[deprecated]]
1114 void getDepthMap(float *buffer);
1115
1116 void getDepthMap(std::vector<float> &depth_pixels, uint &width_pixels, uint &height_pixels);
1117
1119
1123 void getWindowSize(uint &width, uint &height) const;
1124
1126
1130 void getFramebufferSize(uint &width, uint &height) const;
1131
1133 void clearGeometry();
1134
1136 void clearContextGeometry();
1137
1139 void closeWindow() const;
1140
1146 [[nodiscard]] helios::RGBcolor getBackgroundColor() const;
1147
1153 [[nodiscard]] std::vector<helios::vec3> getCameraPosition() const;
1154
1158 void clearColor();
1159
1165 [[nodiscard]] void *getWindow() const;
1166
1172 [[nodiscard]] glm::mat4 getPerspectiveTransformationMatrix() const;
1173
1175
1179 void setPointCullingEnabled(bool enabled);
1180
1185 void setPointCullingThreshold(size_t threshold);
1186
1191 void setPointMaxRenderDistance(float distance);
1192
1197 void setPointLODFactor(float factor);
1198
1205 void getPointRenderingMetrics(size_t &total_points, size_t &rendered_points, float &culling_time_ms) const;
1206
1207private:
1213 [[nodiscard]] std::vector<uint> getFrameBufferSize() const;
1214
1216 std::vector<helios::RGBcolor> readOffscreenPixels() const;
1217
1219
1223 std::vector<helios::RGBAcolor> readOffscreenPixelsRGBA(bool read_alpha) const;
1224
1231 void setFrameBufferSize(int width, int height);
1232
1238 [[nodiscard]] Shader getPrimaryShader() const;
1239
1245 [[nodiscard]] glm::mat4 getViewMatrix() const;
1246
1252 [[nodiscard]] LightingModel getPrimaryLightingModel();
1253
1259 [[nodiscard]] uint getDepthTexture() const;
1260
1261 void openWindow();
1262
1263 void createOffscreenContext();
1264
1266 void removeBackgroundRectangle();
1267
1269 void setBackgroundGradient();
1270
1272 static void framebufferResizeCallback(GLFWwindow *window, int width, int height);
1273
1281 static void windowResizeCallback(GLFWwindow *window, int width, int height);
1282
1292 void initialize(uint window_width_pixels, uint window_height_pixels, int aliasing_samples, bool window_decorations, bool headless_mode);
1293
1299 void render(bool shadow) const;
1300
1307 void transferBufferData();
1308
1310 void transferTextureData();
1311
1318 [[nodiscard]] uint registerTextureImage(const std::string &texture_file);
1319
1328 [[nodiscard]] uint registerTextureImage(const std::vector<unsigned char> &texture_data, const helios::uint2 &image_resolution);
1329
1336 [[nodiscard]] uint registerTextureTransparencyMask(const std::string &texture_file);
1337
1344 [[nodiscard]] uint registerTextureGlyph(const Glyph *glyph);
1345
1352 [[nodiscard]] helios::uint2 getTextureResolution(uint textureID) const;
1353
1354 //~~~~~~~~~~~~~~~~ Primitives ~~~~~~~~~~~~~~~~~~~~//
1355
1356 std::string colorPrimitivesByObjectData, colorPrimitivesByData;
1357 std::map<uint, uint> colorPrimitives_UUIDs, colorPrimitives_objIDs;
1358
1359 std::vector<uint> contextUUIDs_build;
1360
1361 std::vector<float> depth_buffer_data;
1362
1363 void getViewKeystrokes(helios::vec3 &eye, helios::vec3 &center);
1364
1375 std::vector<size_t> addColorbarByCenter(const char *title, const helios::vec2 &size, const helios::vec3 &center, const helios::RGBcolor &font_color, const Colormap &colormap);
1376
1377 void updateDepthBuffer();
1378
1380 uint Wdisplay;
1382 uint Hdisplay;
1383
1385 uint Wframebuffer;
1387 uint Hframebuffer;
1388
1389 helios::uint2 shadow_buffer_size;
1390
1391 uint frame_counter;
1392
1394 bool buffers_swapped_since_render;
1395
1397
1398 void *window;
1399
1401 helios::vec3 camera_lookat_center;
1402
1404 helios::vec3 camera_eye_location;
1405
1407 float minimum_view_radius;
1408
1410 Shader primaryShader;
1411
1413 Shader depthShader;
1414
1416 Shader lineShader;
1417
1418 Shader *currentShader;
1419
1420 uint framebufferID;
1421 uint depthTexture;
1422
1423 // Offscreen rendering support for CI testing
1424 uint offscreenFramebufferID;
1425 uint offscreenColorTexture;
1426 uint offscreenDepthTexture;
1427
1429 LightingModel primaryLightingModel;
1430
1431 float lightintensity = 1.f;
1432
1433 bool isWatermarkVisible;
1434
1436 size_t watermark_ID;
1437
1439 helios::RGBcolor backgroundColor;
1440
1442 bool background_is_transparent;
1443
1445 bool watermark_was_visible_before_transparent;
1446
1448 bool navigation_gizmo_was_enabled_before_image_display;
1449
1451 size_t background_rectangle_ID;
1452 std::vector<size_t> background_sky_IDs;
1453
1455 helios::vec3 light_direction;
1456
1458 std::vector<size_t> coordinate_axes_IDs;
1459
1461 bool navigation_gizmo_enabled;
1462
1464 helios::vec3 previous_camera_eye_location;
1465
1467 helios::vec3 previous_camera_lookat_center;
1468
1470 std::vector<size_t> navigation_gizmo_IDs;
1471
1473 int hovered_gizmo_bubble;
1474
1476
1478 uint colorbar_flag;
1479
1481 std::string colorbar_title;
1482
1484 uint colorbar_fontsize;
1485
1487 float point_width;
1488
1490 bool point_culling_enabled;
1491 size_t point_culling_threshold;
1492 float point_max_render_distance;
1493 float point_lod_factor;
1494
1496 mutable size_t points_total_count;
1497 mutable size_t points_rendered_count;
1498 mutable float last_culling_time_ms;
1499
1501 helios::RGBcolor colorbar_fontcolor;
1502
1504 helios::vec3 colorbar_position;
1505
1507 helios::vec2 colorbar_size;
1508
1510 float colorbar_intended_aspect_ratio;
1511
1513 std::vector<size_t> colorbar_IDs;
1514
1516 std::vector<GLuint> face_index_buffer, vertex_buffer, uv_buffer;
1518 std::vector<GLuint> color_buffer, normal_buffer, texture_flag_buffer, texture_ID_buffer, coordinate_flag_buffer, sky_geometry_flag_buffer, hidden_flag_buffer;
1520 std::vector<GLuint> color_texture_object, normal_texture_object, texture_flag_texture_object, texture_ID_texture_object, coordinate_flag_texture_object, sky_geometry_flag_texture_object, hidden_flag_texture_object;
1521
1523 GLuint uv_rescale_buffer;
1524 GLuint uv_rescale_texture_object;
1525
1527 std::vector<GLint> rectangle_vertex_group_firsts;
1528 std::vector<GLint> rectangle_vertex_group_counts;
1529
1535 [[nodiscard]] glm::mat4 computeShadowDepthMVP() const;
1536
1537 void updatePerspectiveTransformation(bool shadow);
1538
1540 void cullPointsByFrustum();
1541 void cullPointsByDistance(float maxDistance, float lodFactor);
1542 void updatePointCulling();
1543 std::vector<glm::vec4> extractFrustumPlanes() const;
1544
1545 glm::mat4 perspectiveTransformationMatrix;
1546
1547 glm::mat4 cameraViewMatrix;
1548 glm::mat4 cameraProjectionMatrix;
1549
1550 void updateCustomTransformation(const glm::mat4 &matrix);
1551
1552 glm::mat4 customTransformationMatrix;
1553
1555 float camera_FOV;
1556
1557 bool build_all_context_geometry = false;
1558
1559 bool primitiveColorsNeedUpdate;
1560
1561 helios::Context *context;
1562
1564 void buildContextGeometry_private();
1565
1567 void updateNavigationGizmo();
1568
1570 void updateColorbar();
1571
1573
1578 [[nodiscard]] bool testGizmoBubbleHit(const helios::vec2 &normalized_pos, int bubble_index) const;
1579
1581
1584 void reorientCameraToAxis(int axis_index);
1585
1587 [[nodiscard]] bool cameraHasChanged() const;
1588
1589 float colorbar_min;
1590 float colorbar_max;
1591 std::vector<float> colorbar_ticks;
1592 bool colorbar_integer_data;
1593
1595 Colormap colormap_current;
1596
1598 Colormap colormap_hot;
1599
1601 Colormap colormap_cool;
1602
1604 Colormap colormap_lava;
1605
1607 Colormap colormap_rainbow;
1608
1610 Colormap colormap_parula;
1611
1613 Colormap colormap_gray;
1614
1616 Colormap colormap_lines;
1617
1618 bool message_flag;
1619
1621 bool headless;
1622
1623 GeometryHandler geometry_handler;
1624
1625 GLuint texArray;
1626 size_t texture_array_layers;
1627 bool textures_dirty;
1628
1629 helios::uint2 maximum_texture_size;
1630
1631 const glm::mat4 biasMatrix = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0};
1632
1633 struct Texture {
1634
1651 explicit Texture(const std::string &texture_file, uint textureID, const helios::uint2 &maximum_texture_size, bool loadalphaonly = false);
1652
1665 explicit Texture(const Glyph *glyph_ptr, uint textureID, const helios::uint2 &maximum_texture_size);
1666
1678 explicit Texture(const std::vector<unsigned char> &pixel_data, uint textureID, const helios::uint2 &image_resolution, const helios::uint2 &maximum_texture_size);
1679
1681 std::string texture_file;
1683 Glyph glyph;
1685 helios::uint2 texture_resolution;
1687 uint textureID;
1689 std::vector<unsigned char> texture_data;
1691 unsigned char num_channels;
1692
1701 void resizeTexture(const helios::uint2 &new_image_resolution);
1702 };
1703
1709 std::unordered_map<uint, Texture> texture_manager;
1710
1711 friend struct Shader;
1712 friend struct Texture;
1713};
1714
1715inline glm::vec3 glm_vec3(const helios::vec3 &v) {
1716 return {v.x, v.y, v.z};
1717}
1718
1719
1720int checkerrors();
1721
1723void check_opengl_errors_safe(const std::string &context);
1724
1725
1726#endif