SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppGLFW.cpp
Go to the documentation of this file.
1 /**
2  * \file AppGLFW.cpp
3  * \brief App::run implementation from App.h for the GLFW platform
4  * \details The functions implement mostly the callbacks for the platform
5  * independent OpenGL window framework for desktop OS.
6  * For more info on how to create a new app with SLProject see:
7  * https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App
8  * For more info about App framework see:
9  * https://cpvrlab.github.io/SLProject4/app-framework.html
10  * \date June 2024
11  * \authors Marino von Wattenwyl
12  * \copyright http://opensource.org/licenses/GPL-3.0
13  * \remarks Please use clangformat to format the code. See more code style on
14  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
15 */
16 
17 #include <App.h>
18 #include <SLGLState.h>
19 #include <SLEnums.h>
20 #include <SLInterface.h>
21 #include <AppCommon.h>
22 #include <SLAssetManager.h>
23 #include <SLScene.h>
24 #include <SLSceneView.h>
25 #include <CVCapture.h>
26 #include <Profiler.h>
27 #include <SLAssetLoader.h>
28 
29 #define GLFW_INCLUDE_NONE
30 #include <GLFW/glfw3.h>
31 
32 //-----------------------------------------------------------------------------
33 // Global variables
34 App::Config App::config; //!< The configuration set in App::run
35 static GLFWwindow* window; //!< The global glfw window handle
36 static SLint svIndex; //!< Scene view index
37 static SLint scrWidth; //!< Window width at start up
38 static SLint scrHeight; //!< Window height at start up
39 static SLfloat contentScaleX; //!< Content scale in X direction
40 static SLfloat contentScaleY; //!< Content scale in Y direction
41 static SLint dpi = 142; //!< Dot per inch resolution of screen
42 static SLbool fixAspectRatio = false; //!< Flag if wnd aspect ratio should be fixed
43 static SLint startX; //!< start position x in pixels
44 static SLint startY; //!< start position y in pixels
45 static SLint mouseX; //!< Last mouse position x in pixels
46 static SLint mouseY; //!< Last mouse position y in pixels
47 static SLint lastWidth; //!< Last window width in pixels
48 static SLint lastHeight; //!< Last window height in pixels
49 static SLfloat lastMouseDownTime = 0.0f; //!< Last mouse press time
50 static SLKey modifiers = K_none; //!< last modifier keys
51 static SLbool fullscreen = false; //!< flag if window is in fullscreen mode
52 static SLVec2i windowPosBeforeFullscreen; //!< Window position before entering fullscreen mode
53 
54 //-----------------------------------------------------------------------------
55 // Function forward declarations
56 static SLbool onPaint();
57 static void onGLFWError(int error, const char* description);
58 static void onResize(GLFWwindow* myWindow, int width, int height);
59 static void onMouseButton(GLFWwindow* myWindow, int button, int action, int mods);
60 static void onMouseMove(GLFWwindow* myWindow, double x, double y);
61 static void onMouseWheel(GLFWwindow* myWindow, double xscroll, double yscroll);
62 static void onKey(GLFWwindow* myWindow, int GLFWKey, int scancode, int action, int mods);
63 static void onCharInput(GLFWwindow*, SLuint c);
64 static void onClose(GLFWwindow* myWindow);
65 static SLKey mapKeyToSLKey(int key);
66 
67 //-----------------------------------------------------------------------------
68 //! App::run implementation from App.h for the GLFW platform
69 int App::run(Config configuration)
70 {
71  App::config = configuration;
72 
73  // set command line arguments
74  SLVstring cmdLineArgs;
75  for (int i = 0; i < config.argc; i++)
76  cmdLineArgs.push_back(SLstring(config.argv[i]));
77 
78  // parse cmd line arguments
79  for (int i = 1; i < cmdLineArgs.size(); ++i)
80  if (cmdLineArgs[i] == "-onlyErrorLogs")
81  Utils::onlyErrorLogs = true;
82 
83  if (!glfwInit())
84  {
85  fprintf(stderr, "Failed to initialize GLFW\n");
86  exit(EXIT_FAILURE);
87  }
88 
89  glfwSetErrorCallback(onGLFWError);
90 
91  // Enable fullscreen anti aliasing with 4 samples
92  glfwWindowHint(GLFW_SAMPLES, config.numSamples);
93 
94 #ifdef __APPLE__
95  // You can enable or restrict newer OpenGL context here (read the GLFW documentation)
96  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
97  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
98  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
99  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
100  glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GL_FALSE);
101 #endif
102 
103  window = glfwCreateWindow(config.windowWidth,
105  config.windowTitle.c_str(),
106  nullptr,
107  nullptr);
108 
109  if (!window)
110  {
111  glfwTerminate();
112  exit(EXIT_FAILURE);
113  }
114 
115  // Get the current GL context. After this you can call GL
116  glfwMakeContextCurrent(window);
117 
118  // Init OpenGL access library gl3w
119  if (gl3wInit() != 0)
120  SL_EXIT_MSG("Failed to initialize OpenGL");
121 
122  // With GLFW ImGui draws the cursor
123  glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
124 
125  // Set number of monitor refreshes between 2 buffer swaps
126  glfwSwapInterval(1);
127 
128  // Get GL errors that occurred before our framework is involved
129  GET_GL_ERROR;
130 
131  // Set GLFW callback functions
132  glfwSetKeyCallback(window, onKey);
133  glfwSetCharCallback(window, onCharInput);
134  glfwSetWindowSizeCallback(window, onResize);
135  glfwSetMouseButtonCallback(window, onMouseButton);
136  glfwSetCursorPosCallback(window, onMouseMove);
137  glfwSetScrollCallback(window, onMouseWheel);
138  glfwSetWindowCloseCallback(window, onClose);
139 
140  // get real window size in pixels
141  glfwGetWindowSize(window, &scrWidth, &scrHeight);
142 
143  // get content scaling by OS
144  glfwGetWindowContentScale(window, &contentScaleX, &contentScaleY);
145 
146  // Set your own physical screen dpi
147  SL_LOG("------------------------------------------------------------------");
148  SL_LOG("%s", AppCommon::asciiLabel.c_str());
149  SL_LOG("Platform : GLFW (Version: %d.%d.%d)",
150  GLFW_VERSION_MAJOR,
151  GLFW_VERSION_MINOR,
152  GLFW_VERSION_REVISION);
153  SL_LOG("Resolution (DPI) : %d", dpi);
154  SL_LOG("Content Scaling : %d%%", (SLint)(contentScaleX * 100.0f));
155 
156  // get executable path
157  SLstring projectRoot = SLstring(SL_PROJECT_ROOT);
158  SLstring configDir = Utils::getAppsWritableDir();
159  slSetupExternalDir(projectRoot + "/data/");
160  // Utils::dumpFileSystemRec("SLProject", projectRoot + "/data");
161 
162  // setup platform dependent data path
163  AppCommon::calibFilePath = configDir;
164  AppCommon::calibIniPath = projectRoot + "/data/calibrations/";
167 
168  /////////////////////////////////////////////////////////
169  slCreateApp(cmdLineArgs,
170  projectRoot + "/data/",
171  projectRoot + "/data/shaders/",
172  projectRoot + "/data/models/",
173  projectRoot + "/data/images/textures/",
174  projectRoot + "/data/images/fonts/",
175  projectRoot + "/data/videos/",
176  configDir,
177  "AppDemoGLFW");
178  /////////////////////////////////////////////////////////
179 
181 
182  ///////////////////////////////////////////////////////////////////
185  scrWidth,
186  scrHeight,
189  reinterpret_cast<void*>(onPaint),
190  nullptr,
191  reinterpret_cast<void*>(config.onNewSceneView),
192  reinterpret_cast<void*>(config.onGuiBuild),
193  reinterpret_cast<void*>(config.onGuiLoadConfig),
194  reinterpret_cast<void*>(config.onGuiSaveConfig));
195  ///////////////////////////////////////////////////////////////////
196 
197  // Event loop
198  while (!slShouldClose())
199  {
200  /////////////////////////////
201  SLbool doRepaint = onPaint();
202  /////////////////////////////
203 
204  // Show the title generated by the scene library (FPS etc.)
205  glfwSetWindowTitle(window, slGetWindowTitle(svIndex).c_str());
206 
207  // if no updated occurred wait for the next event (power saving)
208  if (!doRepaint)
209  glfwWaitEvents();
210  else
211  glfwPollEvents();
212  }
213 
214  slTerminate();
215  glfwDestroyWindow(window);
216  glfwTerminate();
217 
218  return 0;
219 }
220 //-----------------------------------------------------------------------------
221 //! Static paint function that gets called once every frame
222 static SLbool onPaint()
223 {
224  PROFILE_SCOPE("AppGLFW::onPaint");
225 
226  if (AppCommon::sceneViews.empty())
227  return false;
228 
230 
232  {
234  AppCommon::sceneToLoad = {}; // sets optional to empty
235  }
236 
237  if (AppCommon::assetLoader->isLoading())
239 
240  ////////////////////////////////////////////////////////////////
241  SLbool appNeedsUpdate = App::config.onUpdate && App::config.onUpdate(sv);
242  SLbool jobIsRunning = slUpdateParallelJob();
243  SLbool isLoading = AppCommon::assetLoader->isLoading();
244  SLbool viewNeedsUpdate = slPaintAllViews();
245  ////////////////////////////////////////////////////////////////
246 
247  // Fast copy the back buffer to the front buffer. This is OS dependent.
248  glfwSwapBuffers(window);
249 
250  return appNeedsUpdate || viewNeedsUpdate || jobIsRunning || isLoading;
251 }
252 //-----------------------------------------------------------------------------
253 /*!
254 Error callback handler for GLFW.
255 */
256 static void onGLFWError(int error, const char* description)
257 {
258  fputs(description, stderr);
259 }
260 //-----------------------------------------------------------------------------
261 /*!
262 onResize: Event handler called on the resize event of the window. This event
263 should called once before the onPaint event.
264 */
265 static void onResize(GLFWwindow* myWindow, int width, int height)
266 {
267  if (AppCommon::sceneViews.empty()) return;
269 
270  if (fixAspectRatio)
271  {
272  float aspectRatio = (float)width / (float)height;
273 
274  // correct target width and height
275  if ((float)height * aspectRatio <= (float)width)
276  {
277  width = (int)((float)height * aspectRatio);
278  height = (int)((float)width / aspectRatio);
279  }
280  else
281  {
282  height = (int)((float)width / aspectRatio);
283  width = (int)((float)height * aspectRatio);
284  }
285  }
286 
287  lastWidth = width;
288  lastHeight = height;
289 
290  // width & height are in screen coords.
291  slResize(svIndex, width, height);
292 
293  onPaint();
294 }
295 //-----------------------------------------------------------------------------
296 /*!
297 Mouse button event handler forwards the events to the slMouseDown or slMouseUp.
298 Two finger touches of touch devices are simulated with ALT & CTRL modifiers.
299 */
300 static void onMouseButton(GLFWwindow* myWindow,
301  int button,
302  int action,
303  int mods)
304 {
305  SLint x = mouseX;
306  SLint y = mouseY;
307  startX = x;
308  startY = y;
309 
310  // Translate modifiers
311  modifiers = K_none;
312  if ((uint)mods & (uint)GLFW_MOD_SHIFT) modifiers = (SLKey)(modifiers | K_shift);
313  if ((uint)mods & (uint)GLFW_MOD_CONTROL) modifiers = (SLKey)(modifiers | K_ctrl);
314  if ((uint)mods & (uint)GLFW_MOD_ALT) modifiers = (SLKey)(modifiers | K_alt);
315 
316  if (action == GLFW_PRESS)
317  {
318  SLfloat mouseDeltaTime = (SLfloat)glfwGetTime() - lastMouseDownTime;
319  lastMouseDownTime = (SLfloat)glfwGetTime();
320 
321  // handle double click
322  if (mouseDeltaTime < 0.3f)
323  {
324  switch (button)
325  {
326  case GLFW_MOUSE_BUTTON_LEFT:
328  break;
329  case GLFW_MOUSE_BUTTON_RIGHT:
331  break;
332  case GLFW_MOUSE_BUTTON_MIDDLE:
334  break;
335  default: break;
336  }
337  }
338  else // normal mouse clicks
339  {
340  switch (button)
341  {
342  case GLFW_MOUSE_BUTTON_LEFT:
343  if (modifiers & K_alt && modifiers & K_ctrl)
344  slTouch2Down(svIndex, x - 20, y, x + 20, y);
345  else
347  break;
348  case GLFW_MOUSE_BUTTON_RIGHT:
350  break;
351  case GLFW_MOUSE_BUTTON_MIDDLE:
353  break;
354  default: break;
355  }
356  }
357  }
358  else
359  { // flag end of mouse click for long touches
360  startX = -1;
361  startY = -1;
362 
363  switch (button)
364  {
365  case GLFW_MOUSE_BUTTON_LEFT:
367  break;
368  case GLFW_MOUSE_BUTTON_RIGHT:
370  break;
371  case GLFW_MOUSE_BUTTON_MIDDLE:
373  break;
374  default: break;
375  }
376  }
377 }
378 //-----------------------------------------------------------------------------
379 /*!
380 Mouse move event handler forwards the events to slMouseMove or slTouch2Move.
381 */
382 static void onMouseMove(GLFWwindow* myWindow,
383  double x,
384  double y)
385 {
386  // x & y are in screen coords.
387  mouseX = (int)x;
388  mouseY = (int)y;
389 
390  if (modifiers & K_alt && modifiers & K_ctrl)
392  (int)(x - 20),
393  (int)y,
394  (int)(x + 20),
395  (int)y);
396  else
398  (int)x,
399  (int)y);
400 }
401 //-----------------------------------------------------------------------------
402 /*!
403 Mouse wheel event handler forwards the events to slMouseWheel
404 */
405 static void onMouseWheel(GLFWwindow* myWindow,
406  double xscroll,
407  double yscroll)
408 {
409  // make sure the delta is at least one integer
410  int dY = (int)yscroll;
411  if (dY == 0) dY = (int)(Utils::sign(yscroll));
412 
414 }
415 //-----------------------------------------------------------------------------
416 /*!
417 Key event handler sets the modifier key state & forwards the event to
418 the slKeyPress/slKeyRelease functions.
419 */
420 static void onKey(GLFWwindow* myWindow,
421  int GLFWKey,
422  int scancode,
423  int action,
424  int mods)
425 {
426  SLKey key = mapKeyToSLKey(GLFWKey);
427 
428  // Do not handle key events if scene is being loaded.
429  if (!AppCommon::scene) return;
430 
431  if (action == GLFW_PRESS)
432  {
433  switch (key)
434  {
435  case K_ctrl: modifiers = (SLKey)(modifiers | K_ctrl); return;
436  case K_alt: modifiers = (SLKey)(modifiers | K_alt); return;
437  case K_shift: modifiers = (SLKey)(modifiers | K_shift); return;
438  default: break;
439  }
440  }
441  else if (action == GLFW_RELEASE)
442  {
443  switch (key)
444  {
445  case K_ctrl: modifiers = (SLKey)(modifiers ^ K_ctrl); return;
446  case K_alt: modifiers = (SLKey)(modifiers ^ K_alt); return;
447  case K_shift: modifiers = (SLKey)(modifiers ^ K_shift); return;
448  default: break;
449  }
450  }
451 
452  // Special treatment for ESC key
453  if (key == K_esc && action == GLFW_RELEASE && fullscreen)
454  {
455  fullscreen = false;
456  glfwSetWindowSize(myWindow, scrWidth, scrHeight);
457  glfwSetWindowPos(myWindow, windowPosBeforeFullscreen.x, windowPosBeforeFullscreen.y);
458  }
459 
460  // Toggle fullscreen mode
461  if (key == K_F9 && action == GLFW_PRESS)
462  {
464 
465  if (fullscreen)
466  {
467  GLFWmonitor* primary = glfwGetPrimaryMonitor();
468  const GLFWvidmode* mode = glfwGetVideoMode(primary);
469  glfwSetWindowSize(myWindow, mode->width, mode->height);
470  glfwGetWindowPos(myWindow, &windowPosBeforeFullscreen.x, &windowPosBeforeFullscreen.y);
471  glfwSetWindowPos(myWindow, 0, 0);
472  }
473  else
474  {
475  glfwSetWindowSize(myWindow, scrWidth, scrHeight);
476  glfwSetWindowPos(myWindow, windowPosBeforeFullscreen.x, windowPosBeforeFullscreen.y);
477  }
478 
479  return;
480  }
481 
482  if (action == GLFW_PRESS)
484  else if (action == GLFW_RELEASE)
486 }
487 //-----------------------------------------------------------------------------
488 //! Event handler for GLFW character input
489 void onCharInput(GLFWwindow*, SLuint c)
490 {
491  slCharInput(svIndex, c);
492 }
493 //-----------------------------------------------------------------------------
494 /*!
495 onClose event handler for deallocation of the scene & sceneview. onClose is
496 called glfwPollEvents, glfwWaitEvents or glfwSwapBuffers.
497 */
498 void onClose(GLFWwindow* myWindow)
499 {
500  slShouldClose(true);
501 }
502 //-----------------------------------------------------------------------------
503 //! Maps the GLFW key codes to the SLKey codes
504 static SLKey mapKeyToSLKey(int key)
505 {
506  switch (key)
507  {
508  case GLFW_KEY_SPACE: return K_space;
509  case GLFW_KEY_ESCAPE: return K_esc;
510  case GLFW_KEY_F1: return K_F1;
511  case GLFW_KEY_F2: return K_F2;
512  case GLFW_KEY_F3: return K_F3;
513  case GLFW_KEY_F4: return K_F4;
514  case GLFW_KEY_F5: return K_F5;
515  case GLFW_KEY_F6: return K_F6;
516  case GLFW_KEY_F7: return K_F7;
517  case GLFW_KEY_F8: return K_F8;
518  case GLFW_KEY_F9: return K_F9;
519  case GLFW_KEY_F10: return K_F10;
520  case GLFW_KEY_F11: return K_F11;
521  case GLFW_KEY_F12: return K_F12;
522  case GLFW_KEY_UP: return K_up;
523  case GLFW_KEY_DOWN: return K_down;
524  case GLFW_KEY_LEFT: return K_left;
525  case GLFW_KEY_RIGHT: return K_right;
526  case GLFW_KEY_LEFT_SHIFT:
527  case GLFW_KEY_RIGHT_SHIFT: return K_shift;
528  case GLFW_KEY_LEFT_CONTROL:
529  case GLFW_KEY_RIGHT_CONTROL: return K_ctrl;
530  case GLFW_KEY_LEFT_ALT:
531  case GLFW_KEY_RIGHT_ALT: return K_alt;
532  case GLFW_KEY_LEFT_SUPER:
533  case GLFW_KEY_RIGHT_SUPER: return K_super; // Apple command key
534  case GLFW_KEY_TAB: return K_tab;
535  case GLFW_KEY_ENTER: return K_enter;
536  case GLFW_KEY_BACKSPACE: return K_backspace;
537  case GLFW_KEY_INSERT: return K_insert;
538  case GLFW_KEY_DELETE: return K_delete;
539  case GLFW_KEY_PAGE_UP: return K_pageUp;
540  case GLFW_KEY_PAGE_DOWN: return K_pageDown;
541  case GLFW_KEY_HOME: return K_home;
542  case GLFW_KEY_END: return K_end;
543  case GLFW_KEY_KP_0: return K_NP0;
544  case GLFW_KEY_KP_1: return K_NP1;
545  case GLFW_KEY_KP_2: return K_NP2;
546  case GLFW_KEY_KP_3: return K_NP3;
547  case GLFW_KEY_KP_4: return K_NP4;
548  case GLFW_KEY_KP_5: return K_NP5;
549  case GLFW_KEY_KP_6: return K_NP6;
550  case GLFW_KEY_KP_7: return K_NP7;
551  case GLFW_KEY_KP_8: return K_NP8;
552  case GLFW_KEY_KP_9: return K_NP9;
553  case GLFW_KEY_KP_DIVIDE: return K_NPDivide;
554  case GLFW_KEY_KP_MULTIPLY: return K_NPMultiply;
555  case GLFW_KEY_KP_SUBTRACT: return K_NPSubtract;
556  case GLFW_KEY_KP_ADD: return K_NPAdd;
557  case GLFW_KEY_KP_DECIMAL: return K_NPDecimal;
558  case GLFW_KEY_UNKNOWN: return K_none;
559  default: break;
560  }
561  return (SLKey)key;
562 }
563 //-----------------------------------------------------------------------------
The App namespace declares the App::Config struct and the App::run function.
The AppCommon class holds the top-level instances of the app-demo.
static SLint dpi
Dot per inch resolution of screen.
Definition: AppGLFW.cpp:41
static SLint svIndex
Scene view index.
Definition: AppGLFW.cpp:36
static SLfloat contentScaleY
Content scale in Y direction.
Definition: AppGLFW.cpp:40
static SLbool onPaint()
Static paint function that gets called once every frame.
Definition: AppGLFW.cpp:222
static SLint scrHeight
Window height at start up.
Definition: AppGLFW.cpp:38
static SLint startY
start position y in pixels
Definition: AppGLFW.cpp:44
static void onClose(GLFWwindow *myWindow)
Definition: AppGLFW.cpp:498
static SLKey modifiers
last modifier keys
Definition: AppGLFW.cpp:50
static void onMouseButton(GLFWwindow *myWindow, int button, int action, int mods)
Definition: AppGLFW.cpp:300
static SLfloat lastMouseDownTime
Last mouse press time.
Definition: AppGLFW.cpp:49
static SLbool fullscreen
flag if window is in fullscreen mode
Definition: AppGLFW.cpp:51
static SLint mouseX
Last mouse position x in pixels.
Definition: AppGLFW.cpp:45
static GLFWwindow * window
The global glfw window handle.
Definition: AppGLFW.cpp:35
static SLfloat contentScaleX
Content scale in X direction.
Definition: AppGLFW.cpp:39
static SLVec2i windowPosBeforeFullscreen
Window position before entering fullscreen mode.
Definition: AppGLFW.cpp:52
static SLint lastHeight
Last window height in pixels.
Definition: AppGLFW.cpp:48
static void onMouseWheel(GLFWwindow *myWindow, double xscroll, double yscroll)
Definition: AppGLFW.cpp:405
static SLint startX
start position x in pixels
Definition: AppGLFW.cpp:43
static void onResize(GLFWwindow *myWindow, int width, int height)
Definition: AppGLFW.cpp:265
static SLint lastWidth
Last window width in pixels.
Definition: AppGLFW.cpp:47
static SLint mouseY
Last mouse position y in pixels.
Definition: AppGLFW.cpp:46
static void onMouseMove(GLFWwindow *myWindow, double x, double y)
Definition: AppGLFW.cpp:382
static SLint scrWidth
Window width at start up.
Definition: AppGLFW.cpp:37
static SLbool fixAspectRatio
Flag if wnd aspect ratio should be fixed.
Definition: AppGLFW.cpp:42
static void onKey(GLFWwindow *myWindow, int GLFWKey, int scancode, int action, int mods)
Definition: AppGLFW.cpp:420
static void onGLFWError(int error, const char *description)
Definition: AppGLFW.cpp:256
static void onCharInput(GLFWwindow *, SLuint c)
Event handler for GLFW character input.
Definition: AppGLFW.cpp:489
static SLKey mapKeyToSLKey(int key)
Maps the GLFW key codes to the SLKey codes.
Definition: AppGLFW.cpp:504
#define PROFILE_SCOPE(name)
Definition: Instrumentor.h:40
float SLfloat
Definition: SL.h:173
#define SL_LOG(...)
Definition: SL.h:233
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
vector< SLstring > SLVstring
Definition: SL.h:201
#define SL_EXIT_MSG(message)
Definition: SL.h:240
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
@ MB_left
Definition: SLEnums.h:100
@ MB_right
Definition: SLEnums.h:102
@ MB_middle
Definition: SLEnums.h:101
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
@ K_down
Definition: SLEnums.h:25
@ K_NP5
Definition: SLEnums.h:38
@ K_delete
Definition: SLEnums.h:23
@ K_space
Definition: SLEnums.h:18
@ K_F2
Definition: SLEnums.h:50
@ K_F1
Definition: SLEnums.h:49
@ K_F12
Definition: SLEnums.h:60
@ K_NP9
Definition: SLEnums.h:42
@ K_F6
Definition: SLEnums.h:54
@ K_F4
Definition: SLEnums.h:52
@ K_up
Definition: SLEnums.h:24
@ K_enter
Definition: SLEnums.h:20
@ K_esc
Definition: SLEnums.h:21
@ K_none
Definition: SLEnums.h:17
@ K_tab
Definition: SLEnums.h:19
@ K_NP6
Definition: SLEnums.h:39
@ K_shift
Definition: SLEnums.h:62
@ K_end
Definition: SLEnums.h:29
@ K_insert
Definition: SLEnums.h:30
@ K_right
Definition: SLEnums.h:26
@ K_F9
Definition: SLEnums.h:57
@ K_NPDivide
Definition: SLEnums.h:43
@ K_pageDown
Definition: SLEnums.h:32
@ K_F8
Definition: SLEnums.h:56
@ K_F5
Definition: SLEnums.h:53
@ K_pageUp
Definition: SLEnums.h:31
@ K_NPMultiply
Definition: SLEnums.h:44
@ K_NPSubtract
Definition: SLEnums.h:46
@ K_NP8
Definition: SLEnums.h:41
@ K_NP1
Definition: SLEnums.h:34
@ K_NP3
Definition: SLEnums.h:36
@ K_ctrl
Definition: SLEnums.h:63
@ K_NP7
Definition: SLEnums.h:40
@ K_NP2
Definition: SLEnums.h:35
@ K_F10
Definition: SLEnums.h:58
@ K_F11
Definition: SLEnums.h:59
@ K_NP4
Definition: SLEnums.h:37
@ K_super
Definition: SLEnums.h:61
@ K_F3
Definition: SLEnums.h:51
@ K_F7
Definition: SLEnums.h:55
@ K_alt
Definition: SLEnums.h:64
@ K_left
Definition: SLEnums.h:27
@ K_NP0
Definition: SLEnums.h:33
@ K_backspace
Definition: SLEnums.h:22
@ K_home
Definition: SLEnums.h:28
@ K_NPDecimal
Definition: SLEnums.h:48
@ K_NPAdd
Definition: SLEnums.h:45
Singleton class for global render state.
#define GET_GL_ERROR
Definition: SLGLState.h:56
void slTouch2Move(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)
void slMouseDown(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)
void slSetupExternalDir(const SLstring &externalPath)
void slTouch2Down(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)
void slMouseMove(int sceneViewIndex, int x, int y)
void slSwitchScene(SLSceneView *sv, SLSceneID sceneID)
void slMouseWheel(int sceneViewIndex, int pos, SLKey modifier)
void slKeyRelease(int sceneViewIndex, SLKey key, SLKey modifier)
void slMouseUp(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)
void slCharInput(int sceneViewIndex, unsigned int character)
void slDoubleClick(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)
void slLoadCoreAssetsSync()
void slResize(int sceneViewIndex, int width, int height)
bool slPaintAllViews()
string slGetWindowTitle(int sceneViewIndex)
Global function to retrieve a window title generated by the scene library.
void slKeyPress(int sceneViewIndex, SLKey key, SLKey modifier)
void slTerminate()
bool slUpdateParallelJob()
void slCreateApp(SLVstring &cmdLineArgs, const SLstring &dataPath, const SLstring &shaderPath, const SLstring &modelPath, const SLstring &texturePath, const SLstring &fontPath, const SLstring &videoPath, const SLstring &configPath, const SLstring &applicationName)
Definition: SLInterface.cpp:57
SLint slCreateSceneView(SLAssetManager *am, SLScene *scene, int screenWidth, int screenHeight, int dotsPerInch, SLSceneID initScene, void *onWndUpdateCallback, void *onSelectNodeMeshCallback, void *onNewSceneViewCallback, void *onImGuiBuild, void *onImGuiLoadConfig, void *onImGuiSaveConfig)
bool slShouldClose()
Declaration of the main Scene Library C-Interface.
static WAI::ModeOrbSlam2 * mode
Definition: WAIInterface.cpp:5
static SLstring asciiLabel
SLProject ascii label string.
Definition: AppCommon.h:75
static SLstring calibIniPath
That's where data/calibrations folder is located.
Definition: AppCommon.h:108
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
Definition: AppCommon.h:90
static SLAssetManager * assetManager
asset manager is the owner of all assets
Definition: AppCommon.h:59
static SLVSceneView sceneViews
Vector of sceneview pointers.
Definition: AppCommon.h:62
static SLAssetLoader * assetLoader
Asset-loader for async asset loading.
Definition: AppCommon.h:60
static SLScene * scene
Pointer to the one and only SLScene instance.
Definition: AppCommon.h:61
static SLstring calibFilePath
That's where calibrations are stored and loaded from.
Definition: AppCommon.h:109
void loadCalibrations(const string &computerInfo, const string &configPath)
Definition: CVCapture.cpp:894
static CVCapture * instance()
Public static instance getter for singleton pattern.
Definition: CVCapture.h:65
void checkIfAsyncLoadingIsDone()
bool isLoading() const
Definition: SLAssetLoader.h:68
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
T y
Definition: SLVec2.h:30
T x
Definition: SLVec2.h:30
static std::string get()
Definition: Utils.cpp:1261
int run(Config config)
App::run implementation from App.h for the Emscripten platform.
Definition: AppAndroid.cpp:78
Config config
The configuration set in App::run.
Definition: AppAndroid.cpp:34
T sign(T a)
Definition: Utils.h:245
string getAppsWritableDir(string appName)
Returns the writable configuration directory.
Definition: Utils.cpp:942
bool onlyErrorLogs
if this flag is set to true all calls to log get ignored
Definition: Utils.cpp:84
App configuration struct to be passed to the App::run function.
Definition: App.h:57
OnGuiLoadConfigCallback onGuiLoadConfig
Definition: App.h:73
SLSceneID startSceneID
Definition: App.h:64
SLint windowWidth
Definition: App.h:60
SLint windowHeight
Definition: App.h:61
OnNewSceneViewCallback onNewSceneView
Definition: App.h:65
OnUpdateCallback onUpdate
Definition: App.h:71
OnGuiSaveConfigCallback onGuiSaveConfig
Definition: App.h:74
SLint numSamples
Definition: App.h:63
OnGuiBuildCallback onGuiBuild
Definition: App.h:72
int argc
Definition: App.h:58
char ** argv
Definition: App.h:59
SLstring windowTitle
Definition: App.h:62