ux-window.cpp
Go to the documentation of this file.
1 #ifndef NOMINMAX
2 #define NOMINMAX
3 #endif
4 #include <glad/glad.h>
5 
6 #include "ux-window.h"
7 
8 #include "model-views.h"
9 #include "os.h"
10 
11 // We use STB image to load the splash-screen from memory
12 #define STB_IMAGE_IMPLEMENTATION
13 #include <stb_image.h>
14 // int-rs-splash.hpp contains the PNG image from res/int-rs-splash.png
15 #include "res/int-rs-splash.hpp"
16 #include "res/icon.h"
17 
18 #include "ux-alignment.h"
19 
20 #include <opengl3.h>
21 
22 #include <iostream>
23 
24 void glfw_error_callback(int error, const char* description)
25 {
26  std::cerr << "GLFW Driver Error: " << description << "\n";
27 }
28 
29 namespace rs2
30 {
32  GLenum type,
33  GLuint id,
36  const GLchar* message,
37  const void* userParam)
38  {
39  if (type == GL_DEBUG_TYPE_ERROR)
40  {
41  fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
42  (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
43  type, severity, message);
44  }
45  }
46 
48  {
54 
58 
65 
68 
72 
76 
79 
81  try
82  {
84  }
85  catch (const std::exception&)
86  {
87  std::string msg = "Failed to get Documents folder";
88  rs2::log(RS2_LOG_SEVERITY_INFO, msg.c_str());
89  path = "";
90  }
93 
94 #ifdef __APPLE__
95 
99  // On Mac-OS, mixing OpenGL 2 with OpenGL 3 is not supported by the driver
100  // while this can be worked-around, this will take more development time,
101  // so for now Macs should not use the GLSL stuff
104 #else
105  auto vendor = (const char*)glGetString(GL_VENDOR);
106  auto renderer = (const char*)glGetString(GL_RENDERER);
107  auto version = (const char*)glGetString(GL_VERSION);
108  auto glsl = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
109 
110  bool use_glsl = false;
111 
112  // Absolutely arbitrary list of manufacturers that are likely to benefit from GLSL optimisation
113  if (starts_with(to_lower(vendor), "intel") ||
114  starts_with(to_lower(vendor), "ati") ||
115  starts_with(to_lower(vendor), "nvidia"))
116  {
117  use_glsl = true;
118  }
119 
120  // Double-check that GLSL 1.3+ is supported
121  if (starts_with(to_lower(vendor), "1.1") || starts_with(to_lower(vendor), "1.2"))
122  {
123  use_glsl = false;
124  }
125 
126  if (use_glsl)
127  {
135  }
136  else
137  {
145  }
146 #endif
147  }
148 
150  {
151  _reload = true;
152  }
153 
155  {
158 
161 
164  }
165 
167  {
168  _link_hovered = true;
169  }
170 
172  {
173  _cross_hovered = true;
174  }
175 
177  {
178  GLFWimage icon[4];
179 
180  int x, y, comp;
181 
182  auto icon_16 = stbi_load_from_memory(icon_16_png_data, (int)icon_16_png_size, &x, &y, &comp, false);
183  icon[0].width = x; icon[0].height = y;
184  icon[0].pixels = icon_16;
185 
186  auto icon_24 = stbi_load_from_memory(icon_24_png_data, (int)icon_24_png_size, &x, &y, &comp, false);
187  icon[1].width = x; icon[1].height = y;
188  icon[1].pixels = icon_24;
189 
190  auto icon_64 = stbi_load_from_memory(icon_64_png_data, (int)icon_64_png_size, &x, &y, &comp, false);
191  icon[2].width = x; icon[2].height = y;
192  icon[2].pixels = icon_64;
193 
194  auto icon_256 = stbi_load_from_memory(icon_256_png_data, (int)icon_256_png_size, &x, &y, &comp, false);
195  icon[3].width = x; icon[3].height = y;
196  icon[3].pixels = icon_256;
197 
198  glfwSetWindowIcon(_win, 4, icon);
199 
200  stbi_image_free(icon_16);
201  stbi_image_free(icon_24);
202  stbi_image_free(icon_64);
203  stbi_image_free(icon_256);
204  }
205 
206 
208  {
209  if (_win)
210  {
213 
214  ImGui::GetIO().Fonts->ClearFonts(); // To be refactored into Viewer theme object
219  glfwTerminate();
220  }
221 
222  if (!glfwInit())
223  exit(1);
224 
226 
229 
230  {
232  auto ctx = glfwCreateWindow(640, 480, "Offscreen Context", nullptr, nullptr);
233  if (!ctx) throw std::runtime_error("Could not initialize offscreen context!");
235 
237 
238  // OpenGL 2.1 backward-compatibility fixes.
239  // On macOS, the compatibility profile is OpenGL 2.1 + extensions.
246  } else {
247  throw std::runtime_error("OpenGL 3.0 or ARB_vertex_array_object extension required!");
248  }
249  }
250 
252 
254  }
255 
258 
261 
263 
264  rs2_error* e = nullptr;
266  auto debug = is_debug();
267  if (debug)
268  {
269  _title_str = _title_str + ", DEBUG";
270  }
271 
272  _width = 1024;
273  _height = 768;
274 
275  // Dynamically adjust new window size (by detecting monitor resolution)
276  auto primary = glfwGetPrimaryMonitor();
277  if (primary)
278  {
279  const auto mode = glfwGetVideoMode(primary);
280  if (_fullscreen)
281  {
282  _width = mode->width;
283  _height = mode->height;
284  }
285  else
286  {
287  _width = int(mode->width * 0.7f);
288  _height = int(mode->height * 0.7f);
289  }
290  }
291 
292  if (_enable_msaa)
294 
296 
297  // Create GUI Windows
299  (_fullscreen ? primary : nullptr), nullptr);
300  if (!_win)
301  throw std::runtime_error("Could not open OpenGL window, please check your graphic drivers or use the textual SDK tools");
302 
304  {
307 
308  int count;
310  if (count > 0)
311  {
312  bool legal_position = false;
313  for (int i = 0; i < count; i++)
314  {
315  auto rect = get_monitor_rect(monitors[i]);
316  if (rect.contains({ (float)x, (float)y }))
317  {
318  legal_position = true;
319  }
320  }
321  if (legal_position) glfwSetWindowPos(_win, x, y);
322  }
323  }
324 
326  {
329  glfwSetWindowSize(_win, w, h);
330 
333  }
334 
337 
339  {
340  // During init, enable debug output
343  }
344 
345  glfwSetWindowPosCallback(_win, [](GLFWwindow* w, int x, int y)
346  {
350  });
351 
353  {
358  });
359 
360  setup_icon();
361 
362  ImGui_ImplGlfw_Init(_win, true);
363 
364  if (_use_glsl_render)
365  _2d_vis = std::make_shared<visualizer_2d>(std::make_shared<splash_screen_shader>());
366 
367  // Load fonts to be used with the ImGui - TODO move to RAII
369 
370  // Register for UI-controller events
372 
373 
374  glfwSetCursorPosCallback(_win, [](GLFWwindow* w, double cx, double cy)
375  {
376  auto data = reinterpret_cast<ux_window*>(glfwGetWindowUserPointer(w));
377  data->_mouse.cursor = { (float)cx / data->_scale_factor,
378  (float)cy / data->_scale_factor };
379  });
380  glfwSetMouseButtonCallback(_win, [](GLFWwindow* w, int button, int action, int mods)
381  {
382  auto data = reinterpret_cast<ux_window*>(glfwGetWindowUserPointer(w));
383  data->_mouse.mouse_down[0] = (button == GLFW_MOUSE_BUTTON_1) && (action != GLFW_RELEASE);
384  data->_mouse.mouse_down[1] = (button == GLFW_MOUSE_BUTTON_2) && (action != GLFW_RELEASE);
385  });
386  glfwSetScrollCallback(_win, [](GLFWwindow * w, double xoffset, double yoffset)
387  {
388  auto data = reinterpret_cast<ux_window*>(glfwGetWindowUserPointer(w));
389  data->_mouse.mouse_wheel = static_cast<int>(yoffset);
390  data->_mouse.ui_wheel += static_cast<int>(yoffset);
391  });
392 
393  glfwSetDropCallback(_win, [](GLFWwindow* w, int count, const char** paths)
394  {
395  auto data = reinterpret_cast<ux_window*>(glfwGetWindowUserPointer(w));
396 
397  if (count <= 0) return;
398 
399  for (int i = 0; i < count; i++)
400  {
401  data->on_file_drop(paths[i]);
402  }
403  });
404 
407 
410 
413 
414  // Prepare the splash screen and do some initialization in the background
415  int x, y, comp;
416  auto r = stbi_load_from_memory(splash, (int)splash_size, &x, &y, &comp, false);
417  _splash_tex.upload_image(x, y, r);
419  }
420 
421  ux_window::ux_window(const char* title, context &ctx) :
422  _win(nullptr), _width(0), _height(0), _output_height(0),
423  _font_14(nullptr), _font_18(nullptr), _monofont(nullptr), _app_ready(false),
424  _first_frame(true), _query_devices(true), _missing_device(false),
426  {
427  open_window();
428 
429  // Apply initial UI state
430  reset();
431  }
432 
434  {
435  std::lock_guard<std::mutex> lock(_on_load_message_mtx);
436  _on_load_message.push_back(msg);
437  }
438 
440  {
441  ImGui::PopFont();
442  ImGui::End();
443 
446  end_frame();
447 
448  glPopMatrix();
449  }
450 
452  {
453  glPushMatrix();
455  glClearColor(0.036f, 0.044f, 0.051f, 1.f);
457 
458  glLoadIdentity();
459  glOrtho(0, _width, _height, 0, -1, +1);
460 
461  // Fade-in the logo
462  auto opacity = smoothstep(float(_splash_timer.get_elapsed_ms()), 100.f, 2500.f);
463  auto ox = 0.7f - smoothstep(float(_splash_timer.get_elapsed_ms()), 200.f, 1900.f) * 0.4f;
464  auto oy = 0.5f;
465  auto power = std::sin(smoothstep(float(_splash_timer.get_elapsed_ms()), 150.f, 2200.f) * 3.14f) * 0.96f;
466 
467  if (_use_glsl_render)
468  {
469  auto shader = ((splash_screen_shader*)&_2d_vis->get_shader());
470  shader->begin();
471  shader->set_power(power);
472  shader->set_ray_center(float2{ ox, oy });
473  shader->end();
474  _2d_vis->draw_texture(_splash_tex.get_gl_handle(), opacity);
475  }
476  else
477  {
478  _splash_tex.show({ 0.f,0.f,float(_width),float(_height) }, opacity);
479  }
480 
481  std::string hourglass = u8"\uf251";
482  static utilities::time::periodic_timer every_200ms(std::chrono::milliseconds(200));
483  bool do_200ms = every_200ms;
484  if (_query_devices && do_200ms)
485  {
488 
489  if (!_missing_device)
490  {
491  _dev_stat_message = u8"\uf287 RealSense device detected.";
492  _query_devices = false;
493  }
494  }
495 
496  hourglass[2] += _hourglass_index;
497 
502 
503  auto text_color = light_grey;
504  text_color.w = opacity;
510  ImGui::SetNextWindowPos({ (float)_width / 2 - 150, (float)_height / 2 + 70 });
511 
512  ImGui::SetNextWindowSize({ (float)_width, (float)_height });
513  ImGui::Begin("Splash Screen Banner", nullptr, flags);
515 
516  ImGui::Text("%s Loading %s...", hourglass.c_str(), _title_str.c_str());
517  }
518 
519  // Check that the graphic subsystem is valid and start a new frame
520  ux_window::operator bool()
521  {
522  end_frame();
523 
524  if (_show_fps)
525  {
526  std::stringstream temp_title;
527  temp_title << _title_str;
528 
529  auto fps = ImGui::GetIO().Framerate;
530 
531  temp_title << ", FPS: " << fps;
532  glfwSetWindowTitle(_win, temp_title.str().c_str());
533  }
534 
535  // Yield the CPU
536  if (!_vsync)
537  {
538  std::this_thread::yield();
539  glfwSwapInterval(0);
540  }
541  else
542  {
543  std::this_thread::sleep_for(std::chrono::milliseconds(10));
544  }
545 
546  auto res = !glfwWindowShouldClose(_win);
547 
548 
549  if (_first_frame)
550  {
551  assert(!_first_load.joinable()); // You must call to reset() before initiate new thread
552 
553 
554  _first_load = std::thread([&]() {
555  while (_keep_alive && !_app_ready)
556  {
557  try
558  {
559  _app_ready = on_load();
560  }
561  catch (...)
562  {
563  std::this_thread::sleep_for(std::chrono::seconds(1)); // Wait for connect event and retry
564  }
565  }
566  });
567  }
568 
569  // If we are just getting started, render the Splash Screen instead of normal UI
570  while (res && (!_app_ready || _splash_timer.get_elapsed_ms() < 2000.f))
571  {
573  glfwPollEvents();
574 
575  begin_frame();
576 
577  if (_first_frame)
578  {
580  _first_frame = false;
581  }
582 
584 
585  {
586  std::lock_guard<std::mutex> lock(_on_load_message_mtx);
587  if (_on_load_message.empty())
588  {
589  ImGui::Text("%s", _dev_stat_message.c_str());
590  }
591  else if (!_on_load_message.empty())
592  {
593  ImGui::Text("%s", _dev_stat_message.c_str());
594  for (auto& msg : _on_load_message)
595  {
596  auto is_last_msg = (msg == _on_load_message.back());
597  if (is_last_msg)
598  ImGui::Text("%s", msg.c_str());
599  else if (!is_last_msg)
600  ImGui::Text("%s", msg.c_str());
601  }
602  }
603  }
604 
606 
607 
608  // Yield the CPU
609  std::this_thread::sleep_for(std::chrono::milliseconds(10));
610  }
611 
612  // reset graphic pipe
613  begin_frame();
614 
615  if (_link_hovered)
617  else if (_cross_hovered)
619  else
620  glfwSetCursor(_win, nullptr);
621  _cross_hovered = false;
622  _link_hovered = false;
623  _hovers_any_input_window = false;
624 
625  return res;
626  }
627 
629  {
630  if (_first_load.joinable())
631  {
632  _keep_alive = false;
633  _first_load.join();
634  }
635 
636  end_frame();
637 
640 
641  ImGui::GetIO().Fonts->ClearFonts(); // To be refactored into Viewer theme object
644 
647 
648  glfwTerminate();
649  }
650 
652  {
653  glfwPollEvents();
654 
656  if (state == GLFW_PRESS)
657  {
658  _fullscreen_pressed = true;
659  }
660  else
661  {
663  {
666  open_window();
667  }
668  _fullscreen_pressed = false;
669  }
670 
671  if (_reload)
672  {
673  open_window();
674  _reload = false;
676  }
677 
678  int w = _width; int h = _height;
679 
681 
682  // Set minimum size 1
683  if (_width <= 0) _width = 1;
684  if (_height <= 0) _height = 1;
685 
686  int fw = _fb_width;
687  int fh = _fb_height;
688 
690 
691  // Set minimum size 1
692  if (_fb_width <= 0) _fb_width = 1;
693  if (_fb_height <= 0) _fb_height = 1;
694 
695  if (fw != _fb_width || fh != _fb_height)
696  {
697  std::string msg = to_string() << "Framebuffer size changed to " << _fb_width << " x " << _fb_height;
698  rs2::log(RS2_LOG_SEVERITY_INFO, msg.c_str());
699  }
700 
701  auto sf = _scale_factor;
702 
703  // Update the scale factor each frame
704  // based on resolution and physical display size
705  _scale_factor = static_cast<float>(pick_scale_factor(_win));
706  _width = static_cast<int>(_width / _scale_factor);
707  _height = static_cast<int>(_height / _scale_factor);
708 
709  if (w != _width || h != _height)
710  {
711  std::string msg = to_string() << "Window size changed to " << _width << " x " << _height;
712  rs2::log(RS2_LOG_SEVERITY_INFO, msg.c_str());
713  }
714 
715  if (_scale_factor != sf)
716  {
717  std::string msg = to_string() << "Scale Factor is now " << _scale_factor;
718  rs2::log(RS2_LOG_SEVERITY_INFO, msg.c_str());
719  }
720 
721  // Reset ImGui state
723  glLoadIdentity();
724 
726  _mouse.ui_wheel = 0.f;
727 
729  //ImGui::NewFrame();
730  }
731 
733  {
734  // Rendering
735  glViewport(0, 0,
736  static_cast<int>(ImGui::GetIO().DisplaySize.x * _scale_factor),
737  static_cast<int>(ImGui::GetIO().DisplaySize.y * _scale_factor));
738 
741 
742  glClearColor(0, 0, 0, 1);
744  }
745 
747  {
748  if (!_first_frame)
749  {
750  ImGui::Render();
751 
753  _mouse.mouse_wheel = 0;
754  }
755  }
756 
758  {
759  if (_first_load.joinable())
760  {
761  _keep_alive = false;
762  _first_load.join();
763  _keep_alive = true;
764  }
765 
766  _query_devices = true;
767  _missing_device = false;
768  _hourglass_index = 0;
769  _first_frame = true;
770  _app_ready = false;
772  _dev_stat_message = u8"\uf287 Please connect Intel RealSense device!";
773 
774  {
775  std::lock_guard<std::mutex> lock(_on_load_message_mtx);
776  _on_load_message.clear();
777  }
778  }
779 
780 }
GLAPI int GLAD_GL_APPLE_vertex_array_object
float smoothstep(float x, float min, float max)
Definition: rendering.h:108
static const textual_icon lock
Definition: model-views.h:218
void init_processing(bool use_glsl=true)
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
Definition: imgui.cpp:4650
static uint8_t splash[]
static const ImVec4 transparent
Definition: model-views.h:44
GLenum GLuint GLenum GLsizei const GLchar * message
GLuint get_gl_handle() const
Definition: rendering.h:893
float Framerate
Definition: imgui.h:863
static const ImVec4 white
Definition: model-views.h:45
void begin_frame()
Definition: ux-window.cpp:651
GLFWAPI void glfwFocusWindow(GLFWwindow *window)
Brings the specified window to front and sets input focus.
Definition: window.c:794
GLint y
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
Definition: window.c:544
GLenum GLuint GLenum severity
static const char * is_measuring
Definition: model-views.h:156
std::string to_lower(std::string x)
Definition: parser.hpp:217
int rs2_get_api_version(rs2_error **error)
Definition: rs.cpp:1184
ImFont * _font_14
Definition: ux-window.h:100
GLFWcursor * _hand_cursor
Definition: ux-window.h:131
GLFWAPI int glfwGetWindowAttrib(GLFWwindow *window, int attrib)
Returns an attribute of the specified window.
Definition: window.c:804
static const char * position_y
Definition: model-views.h:179
GLFWAPI void glfwSetWindowTitle(GLFWwindow *window, const char *title)
Sets the title of the specified window.
Definition: window.c:495
unsigned char * pixels
Definition: glfw3.h:1598
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow *window, GLFWwindowsizefun cbfun)
Sets the size callback for the specified window.
Definition: window.c:984
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
Definition: context.c:741
bool _is_ui_aligned
Definition: ux-window.h:139
IMGUI_API void ClearFonts()
bool _hovers_any_input_window
Definition: ux-window.h:115
#define glOrtho
void *(* GLADloadproc)(const char *name)
std::function< bool()> on_load
Definition: ux-window.h:36
#define GL_RENDERER
static uint32_t icon_64_png_size
Definition: icon.h:5
static const ImVec4 light_grey
Definition: model-views.h:40
char GLchar
context & _ctx
Definition: ux-window.h:137
static const char * recommend_calibration
Definition: model-views.h:137
static config_file & instance()
Definition: rs-config.cpp:80
#define GL_DEBUG_TYPE_ERROR
ImVec2 DisplaySize
Definition: imgui.h:786
#define glPopMatrix
constexpr const char * server_versions_db_url
Definition: model-views.h:84
#define GLAPIENTRY
static const char * commands_xml
Definition: model-views.h:169
#define GL_PROJECTION
GLsizei const GLchar *const * path
Definition: glext.h:4276
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *monitor)
Returns the current mode of the specified monitor.
Definition: monitor.c:417
GLFWAPI void * glfwGetWindowUserPointer(GLFWwindow *window)
Returns the user pointer of the specified window.
Definition: window.c:964
device_list query_devices() const
Definition: rs_context.hpp:112
GLsizei const GLuint * paths
Definition: glext.h:10532
int height
Definition: glfw3.h:1595
struct GLFWmonitor GLFWmonitor
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiSetCond cond=0)
Definition: imgui.cpp:4923
static uint8_t icon_64_png_data[]
Definition: icon.h:6
void ImGui_ImplGlfw_Shutdown()
UINT8_TYPE u8
Definition: sqlite3.c:11450
static const char * log_to_file
Definition: model-views.h:161
std::string get_folder_path(special_folder f)
Definition: os.cpp:247
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
Definition: init.c:309
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow *window, GLFWmousebuttonfun cbfun)
Sets the mouse button callback.
Definition: input.c:821
void log(rs2_log_severity severity, const char *message)
Definition: rs.hpp:149
static const char * saved_pos
Definition: model-views.h:177
uint32_t size() const
Definition: rs_device.hpp:711
float _scale_factor
Definition: ux-window.h:103
std::mutex _on_load_message_mtx
Definition: ux-window.h:113
void imgui_easy_theming(ImFont *&font_14, ImFont *&font_18, ImFont *&monofont)
int GLsizei
static uint8_t icon_16_png_data[]
Definition: icon.h:10
#define GLFW_KEY_F8
Definition: glfw3.h:438
STBIDEF stbi_uc * stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
rect get_monitor_rect(GLFWmonitor *monitor)
Definition: os.cpp:107
void add_on_load_message(const std::string &msg)
Definition: ux-window.cpp:433
#define GLFW_CROSSHAIR_CURSOR
The crosshair shape.
Definition: glfw3.h:1040
#define GL_MULTISAMPLE
bool _cross_hovered
Definition: ux-window.h:132
Definition: cah-model.h:10
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
static const char * log_filename
Definition: model-views.h:162
bool _use_glsl_render
Definition: ux-window.h:126
bool is_debug()
Definition: os.cpp:368
#define glIsVertexArrayAPPLE
#define glLoadIdentity
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:1960
e
Definition: rmse.py:177
void shutdown_processing()
static const char * hwlogger_xml
Definition: model-views.h:170
#define glGenVertexArraysAPPLE
ux_window(const char *title, context &ctx)
Definition: ux-window.cpp:421
#define glEnable
static const char * mesh
Definition: model-views.h:199
#define GL_VENDOR
std::shared_ptr< visualizer_2d > _2d_vis
Definition: ux-window.h:136
static const char * show_fps
Definition: model-views.h:191
void imgui_config_pop()
Definition: ux-window.cpp:439
void prepare_config_file()
Definition: ux-window.cpp:47
#define GLFW_RELEASE
The key or mouse button was released.
Definition: glfw3.h:297
#define glDeleteVertexArrays
static const char * log_to_console
Definition: model-views.h:160
static const char * msaa_samples
Definition: model-views.h:190
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
Definition: init.c:198
GLdouble f
#define glGenVertexArrays
#define GL_SHADING_LANGUAGE_VERSION
GLenum mode
static const char * glsl_for_processing
Definition: model-views.h:188
GLFWAPI GLFWmonitor ** glfwGetMonitors(int *count)
Returns the currently connected monitors.
Definition: monitor.c:296
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow *window, void *pointer)
Sets the user pointer of the specified window.
Definition: window.c:955
static const char * metric_system
Definition: model-views.h:167
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:3772
void glfw_error_callback(int error, const char *description)
Definition: ux-window.cpp:24
IMGUI_API void PopStyleVar(int count=1)
Definition: imgui.cpp:4675
static const char * saved_size
Definition: model-views.h:180
#define GL_COLOR_BUFFER_BIT
#define glBindVertexArray
void open_window()
Definition: ux-window.cpp:207
void end_frame()
Definition: ux-window.cpp:746
void reset(clock::time_point start_time=clock::now()) const
Definition: stopwatch.h:24
bool _fullscreen
Definition: ux-window.h:121
GLAPI int GLAD_GL_VERSION_3_0
float w
Definition: imgui.h:100
GLdouble GLdouble r
GLdouble x
void shutdown_rendering()
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
Definition: context.c:658
#define GLFW_HAND_CURSOR
The hand shape.
Definition: glfw3.h:1045
#define glPushMatrix
GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow *window, GLFWwindowposfun cbfun)
Sets the position callback for the specified window.
Definition: window.c:973
#define glDeleteVertexArraysAPPLE
bool _fullscreen_pressed
Definition: ux-window.h:120
bool ImGui_ImplGlfw_Init(GLFWwindow *window, bool install_callbacks)
std::string get(const char *key, const char *def) const
Definition: rs-config.cpp:32
#define glClear
double get_elapsed_ms() const
Definition: stopwatch.h:30
void imgui_config_push()
Definition: ux-window.cpp:451
std::vector< std::string > _on_load_message
Definition: ux-window.h:112
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:2014
void GLAPIENTRY MessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
Definition: ux-window.cpp:31
GLint GLsizei GLsizei height
static uint8_t icon_256_png_data[]
Definition: icon.h:18
bool is_gui_aligned(GLFWwindow *win)
static const char * sw_updates_url
Definition: model-views.h:138
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiSetCond cond=0)
Definition: imgui.cpp:4937
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
Definition: context.c:641
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
Definition: context.c:611
static const char * compression_mode
Definition: model-views.h:131
std::function< void()> on_reload_complete
Definition: ux-window.h:37
GLbitfield flags
GLFWAPI void glfwMaximizeWindow(GLFWwindow *window)
Maximizes the specified window.
Definition: window.c:742
#define glDebugMessageCallback
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow *window, GLFWcursorposfun cbfun)
Sets the cursor position callback.
Definition: input.c:832
static const char * use_normals
Definition: model-views.h:200
IMGUI_API void Text(const char *fmt,...) IM_PRINTFARGS(1)
Definition: imgui.cpp:5223
ImFont * _font_18
Definition: ux-window.h:100
bool _enable_msaa
Definition: ux-window.h:127
IMGUI_API void End()
Definition: imgui.cpp:4330
void begin_viewport()
Definition: ux-window.cpp:732
GLenum GLuint GLenum GLsizei const GLchar const void * userParam
#define RS2_PRODUCT_LINE_ANY_INTEL
Definition: rs_context.h:92
GLuint * monitors
Definition: glext.h:5686
void init_rendering(bool use_glsl=true)
int _output_height
Definition: ux-window.h:95
static size_t splash_size
action
Definition: enums.py:62
#define glViewport
GLAPI int gladLoadGLLoader(GLADloadproc)
Definition: glad/glad.c:1697
static uint8_t icon_24_png_data[]
Definition: icon.h:14
GLFWAPI void glfwSetWindowSize(GLFWwindow *window, int width, int height)
Sets the size of the client area of the specified window.
Definition: window.c:558
void show(const rect &r, float alpha, const rect &normalized_zoom=rect{0, 0, 1, 1}) const
Definition: rendering.h:1456
static const textual_icon exit
Definition: model-views.h:254
GLFWAPI void glfwSetWindowPos(GLFWwindow *window, int xpos, int ypos)
Sets the position of the client area of the specified window.
Definition: window.c:531
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
Definition: imgui.cpp:4599
std::atomic< bool > _keep_alive
Definition: ux-window.h:108
IMGUI_API void PushFont(ImFont *font)
Definition: imgui.cpp:4539
float y
Definition: imgui.h:90
static const char * glsl_for_rendering
Definition: model-views.h:187
static const char * font_oversample
Definition: model-views.h:193
#define GL_DEBUG_OUTPUT
int width
Definition: glfw3.h:1592
int pick_scale_factor(GLFWwindow *window)
Definition: os.cpp:119
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
Definition: window.c:151
std::string _dev_stat_message
Definition: ux-window.h:119
GLFWAPI void glfwSetCursor(GLFWwindow *window, GLFWcursor *cursor)
Sets the cursor for the window.
Definition: input.c:778
static uint32_t icon_16_png_size
Definition: icon.h:9
void ImGui_ImplGlfw_NewFrame(float scale_factor)
#define GLFW_MOUSE_BUTTON_1
Definition: glfw3.h:537
static const char * is_fullscreen
Definition: model-views.h:176
void set(const char *key, const char *value)
Definition: rs-config.cpp:15
GLFWAPI void glfwDestroyCursor(GLFWcursor *cursor)
Destroys a cursor.
Definition: input.c:743
static const char * show_skybox
Definition: model-views.h:194
#define GLFW_MAXIMIZED
Window maximization window hint and attribute.
Definition: glfw3.h:804
static const char * log_severity
Definition: model-views.h:163
unsigned int GLuint
GLint GLint GLint yoffset
ImFont * _monofont
Definition: ux-window.h:100
GLenum type
bool _first_frame
Definition: ux-window.h:106
int _hourglass_index
Definition: ux-window.h:118
#define glBindVertexArrayAPPLE
GLAPI int GLAD_GL_ARB_vertex_array_object
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow *window, GLFWscrollfun cbfun)
Sets the scroll callback.
Definition: input.c:854
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow *window, GLFWdropfun cbfun)
Sets the file drop callback.
Definition: input.c:865
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
Definition: monitor.c:308
std::thread _first_load
Definition: ux-window.h:105
GLFWAPI void glfwDestroyWindow(GLFWwindow *window)
Destroys the specified window and its context.
Definition: window.c:444
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
Definition: window.c:647
static const char * maximized
Definition: model-views.h:183
GLFWAPI void glfwShowWindow(GLFWwindow *window)
Makes the specified window visible.
Definition: window.c:755
GLint GLsizei count
static const char * ground_truth_r
Definition: model-views.h:148
STBIDEF void stbi_image_free(void *retval_from_stbi_load)
bool contains(const float2 &p) const
Definition: rendering.h:583
GLFWwindow * _win
Definition: ux-window.h:94
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
Definition: init.c:243
#define glGetString
static const char * enable_msaa
Definition: model-views.h:189
static uint32_t icon_24_png_size
Definition: icon.h:13
bool _use_glsl_proc
Definition: ux-window.h:125
#define GLFW_MOUSE_BUTTON_2
Definition: glfw3.h:538
#define GLFW_VISIBLE
Window visibility window hint and attribute.
Definition: glfw3.h:780
static const char * position_x
Definition: model-views.h:178
#define glClearColor
void setup_icon()
Definition: ux-window.cpp:176
std::string api_version_to_string(int version)
Definition: rendering.h:1590
#define GLFW_SAMPLES
Framebuffer MSAA samples hint.
Definition: glfw3.h:893
std::ostream & cerr()
GLsizei GLsizei GLchar * source
rs2::mouse_info _mouse
Definition: ux-window.h:101
bool starts_with(const std::string &s, const std::string &prefix)
Definition: os.cpp:343
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
Definition: window.c:1072
static const char * shading_mode
Definition: model-views.h:168
static uint32_t icon_256_png_size
Definition: icon.h:17
static const char * encoding
Definition: model-views.h:201
float MouseWheel
Definition: imgui.h:842
std::string _title
Definition: ux-window.h:135
unsigned int GLenum
int i
GLenum GLuint GLenum GLsizei length
static const char * sw_updates_official_server
Definition: model-views.h:139
GLuint res
Definition: glext.h:8856
Image data.
Definition: glfw3.h:1588
void set_default(const char *key, const char *calculate)
Definition: rs-config.cpp:21
#define GL_VERSION
bool _link_hovered
Definition: ux-window.h:130
GLFWAPI GLFWcursor * glfwCreateStandardCursor(int shape)
Creates a cursor with a standard shape.
Definition: input.c:713
void cross_hovered()
Definition: ux-window.cpp:171
std::string _title_str
Definition: ux-window.h:111
static const char * recommend_updates
Definition: model-views.h:136
std::atomic< bool > _app_ready
Definition: ux-window.h:107
bool _missing_device
Definition: ux-window.h:117
#define GLFW_PRESS
The key or mouse button was pressed.
Definition: glfw3.h:304
GLFWAPI int glfwGetKey(GLFWwindow *window, int key)
Returns the last reported state of a keyboard key for the specified window.
Definition: input.c:591
ImFontAtlas * Fonts
Definition: imgui.h:799
void link_hovered()
Definition: ux-window.cpp:166
texture_buffer _splash_tex
Definition: ux-window.h:109
GLint GLint xoffset
static const char * occlusion_invalidation
Definition: model-views.h:195
static const char * default_path
Definition: model-views.h:130
static const char * height
Definition: model-views.h:182
void upload_image(int w, int h, void *data, int format=GL_RGBA)
Definition: rendering.h:906
#define glMatrixMode
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
Definition: window.c:291
Definition: parser.hpp:150
static const char * file_save_mode
Definition: model-views.h:129
GLFWcursor * _cross_cursor
Definition: ux-window.h:133
GLFWAPI void glfwSetWindowIcon(GLFWwindow *window, int count, const GLFWimage *images)
Sets the icon for the specified window.
Definition: window.c:505
static const char * allow_rc_firmware
Definition: model-views.h:135
GLint GLsizei width
IMGUI_API void PopFont()
Definition: imgui.cpp:4549
utilities::time::stopwatch _splash_timer
Definition: ux-window.h:110
IMGUI_API void Render()
Definition: imgui.cpp:2619
static const char * width
Definition: model-views.h:181
IMGUI_API void PopStyleColor(int count=1)
Definition: imgui.cpp:4609
bool _query_devices
Definition: ux-window.h:116
#define glDisable
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.
Definition: window.c:477
#define glIsVertexArray
std::string to_string(T value)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:14