SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLInterface.cpp
Go to the documentation of this file.
1 /**
2  * \file SLInterface.cpp
3  * \brief Implementation of the main Scene Library C-Interface.
4  * \details The SLInterface.cpp has all implementations of the SLProject
5  * C-Interface. Only these functions should called by the
6  * OS-dependent GUI applications. These functions can be called from
7  * any C, C++ or ObjectiveC GUI framework or by a native API such
8  * as Java Native Interface (JNI).
9  * For more info on how to create a new app with SLProject see:
10  * https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App
11  * For more info about App framework see:
12  * https://cpvrlab.github.io/SLProject4/app-framework.html
13  * \date July 2014
14  * \authors Marcus Hudritsch
15  * \copyright http://opensource.org/licenses/GPL-3.0
16  * \remarks Please use clangformat to format the code. See more code style on
17  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
18  */
19 
20 #include <SLInterface.h>
21 #include <AppCommon.h>
22 #include <SLAssimpImporter.h>
23 #include <SLAssetManager.h>
24 #include <SLAssetLoader.h>
25 #include <SLInputManager.h>
26 #include <SLScene.h>
27 #include <SLSceneView.h>
28 #include <SLImGui.h>
29 #include <Profiler.h>
30 #include <ZipUtils.h>
31 
32 //-----------------------------------------------------------------------------
33 //! global flag that determines if the application should be closed
34 bool gShouldClose = false;
35 
36 //-----------------------------------------------------------------------------
37 /*! Global creation function for a app instance. This function should be
38 called only once per application. The SLScene constructor call is delayed until
39 the first SLSceneView is created to guarantee, that the OpenGL context is
40 present.<br>
41 /param cmdLineArgs Command line arguments (not used yet)
42 /param shaderPath Path to the shader files (readonly)
43 /param modelPath Path to the 3D model files (readonly)
44 /param texturePath Path to the texture image files (readonly)
45 /param fontPath Path to the font image files (readonly)
46 /param calibrationPath Path to the calibration ini files (readonly)
47 /param configPath Path where the config files are stored (read-write)
48 /param applicationName The apps name
49 /param onSceneLoadCallback C Callback function as void* pointer for the scene creation.
50 <br>
51 See examples usages in:
52  - apps/source/platforms/android /AppAndroid.cpp > Java_ch_bfh_cpvrlab_AppAndroidJNI_onInit
53  - apps/source/platforms/emscripten/AppEmscripten.cpp > App::run
54  - apps/source/platforms/glfw /AppGLFW > App::run
55  - apps/source/platforms/ios /ViewController.mm > viewDidLoad
56 */
57 void slCreateApp(SLVstring& cmdLineArgs,
58  const SLstring& dataPath,
59  const SLstring& shaderPath,
60  const SLstring& modelPath,
61  const SLstring& texturePath,
62  const SLstring& fontPath,
63  const SLstring& videoPath,
64  const SLstring& configPath,
65  const SLstring& applicationName)
66 {
67  assert(AppCommon::scene == nullptr && "SLScene is already created!");
68 
69  // For more info on PROFILING read Utils/lib-utils/source/Profiler.h
70 #if PROFILING
72  {
73  SLstring computerInfo = Utils::ComputerInfos::get();
74  SLstring profileFile = AppCommon::externalPath + "Profile_" + computerInfo + ".slt";
75  BEGIN_PROFILING_SESSION(profileFile);
76  PROFILE_THREAD("Main Thread");
77  }
78 #endif
79 
80  // Default paths for all loaded resources
81  SLstring exe = Utils::unifySlashes(cmdLineArgs.size() ? cmdLineArgs[0] : "", false);
84  AppCommon::shaderPath = shaderPath;
85  AppCommon::modelPath = modelPath;
86  AppCommon::texturePath = texturePath;
87  AppCommon::fontPath = fontPath;
88  AppCommon::videoPath = videoPath;
89  AppCommon::configPath = configPath;
90 
91  SLGLState* stateGL = SLGLState::instance();
92  SL_LOG("Path to exe : %s", AppCommon::exePath.c_str());
93  SL_LOG("Path to Models : %s", modelPath.c_str());
94  SL_LOG("Path to Shaders : %s", shaderPath.c_str());
95  SL_LOG("Path to Textures : %s", texturePath.c_str());
96  SL_LOG("Path to Fonts : %s", fontPath.c_str());
97  SL_LOG("Path to Config. : %s", configPath.c_str());
98  SL_LOG("Path to Documents: %s", AppCommon::externalPath.c_str());
99  SL_LOG("OpenCV Version : %d.%d.%d", CV_MAJOR_VERSION, CV_MINOR_VERSION, CV_VERSION_REVISION);
100  SL_LOG("OpenCV has OpenCL: %s", cv::ocl::haveOpenCL() ? "yes" : "no");
101  SL_LOG("OpenGL Ver. Str. : %s", stateGL->glVersion().c_str());
102  SL_LOG("OpenGL Ver. No. : %s", stateGL->glVersionNO().c_str());
103  SL_LOG("OpenGL Vendor : %s", stateGL->glVendor().c_str());
104  SL_LOG("OpenGL Renderer : %s", stateGL->glRenderer().c_str());
105  SL_LOG("OpenGL GLSL Ver. : %s (%s) ", stateGL->glSLVersion().c_str(), stateGL->getSLVersionNO().c_str());
106  SL_LOG("------------------------------------------------------------------");
107 
108  AppCommon::createApp(applicationName);
109 }
110 //-----------------------------------------------------------------------------
111 /*! Global creation function for a SLSceneview instance returning the index of
112 the sceneview. It creates the new SLSceneView instance by calling the callback
113 function slNewSceneView. If you have a custom SLSceneView inherited class you
114 have to provide a similar function and pass it function pointer to
115 slCreateSceneView. You can create multiple sceneview per application.<br>
116 <br>
117 See examples usages in:
118  - app_demo_slproject/glfw: AppDemoMainGLFW.cpp in function main()
119  - app-demo/android: AppDemoAndroidJNI.cpp in Java_ch_fhnw_comgr_GLES3Lib_onInit()
120  - app_demo_slproject/ios: ViewController.m in viewDidLoad()
121 */
123  SLScene* scene,
124  int screenWidth,
125  int screenHeight,
126  int dotsPerInch,
127  SLSceneID initScene,
128  void* onWndUpdateCallback,
129  void* onSelectNodeMeshCallback,
130  void* onNewSceneViewCallback,
131  void* onImGuiBuild,
132  void* onImGuiLoadConfig,
133  void* onImGuiSaveConfig)
134 {
135  // assert(scene && "No valid scene!");
136 
137  // Use our own sceneview creator callback or the passed one.
138  cbOnNewSceneView newSVCallback;
139  if (onNewSceneViewCallback == nullptr)
140  newSVCallback = &slNewSceneView;
141  else
142  newSVCallback = (cbOnNewSceneView)onNewSceneViewCallback;
143 
144  // Create the sceneview & get the pointer with the sceneview index
145  SLSceneView* sv = newSVCallback(scene, dotsPerInch, AppCommon::inputManager);
146 
147  // maintain multiple scene views in AppCommon
148  AppCommon::sceneViews.push_back(sv);
149 
150  // Scale for proportional and fixed size fonts
151  SLfloat dpiScaleProp = (float)dotsPerInch / 120.0f;
152  SLfloat dpiScaleFixed = (float)dotsPerInch / 142.0f;
153 
154  // Default settings for the first time
155  SLImGui::fontPropDots = std::max(16.0f * dpiScaleProp, 16.0f);
156  SLImGui::fontFixedDots = std::max(13.0f * dpiScaleFixed, 13.0f);
157 
158  // Create gui renderer
159  AppCommon::gui = new SLImGui((cbOnImGuiBuild)onImGuiBuild,
160  (cbOnImGuiLoadConfig)onImGuiLoadConfig,
161  (cbOnImGuiSaveConfig)onImGuiSaveConfig,
162  dotsPerInch,
165 
166  sv->init("SceneView",
167  screenWidth,
168  screenHeight,
169  onWndUpdateCallback,
170  onSelectNodeMeshCallback,
173 
174  // Set active sceneview and load scene. This is done for the first sceneview
175  if (!scene)
176  {
178  AppCommon::sceneToLoad = initScene;
179  else
181  }
182  else
183  sv->onInitialize();
184 
185  // return the identifier index
186  return (SLint)AppCommon::sceneViews.size() - 1;
187 }
188 //-----------------------------------------------------------------------------
189 /*! Global C function for synchronous asset loading used by all platforms
190 except on emscripten where slLoadCoreAssetsAsync is used.
191 */
193 {
196 }
197 //-----------------------------------------------------------------------------
198 /*! Global C function for asynchronous asset loading used on emscripten
199 platform.
200 */
202 {
205 }
206 //-----------------------------------------------------------------------------
207 /*! Global C function for scene switching with a sceneID
208  */
210 {
212 }
213 //-----------------------------------------------------------------------------
214 /*! Global sceneview construction function returning the index of the created
215 sceneview instance. If you have a custom SLSceneView inherited class you
216 have to provide a similar function and pass it function pointer to
217 slCreateSceneView.
218 */
220  int dotsPerInch,
221  SLInputManager& inputManager)
222 {
223  return new SLSceneView(s, dotsPerInch, inputManager);
224 }
225 //-----------------------------------------------------------------------------
226 /*! Global closing function that deallocates the sceneview and scene instances.
227 All the scenegraph deallocation is started from here and has to be done before
228 the GUI app terminates.
229 */
231 {
232  return gShouldClose;
233 }
234 //-----------------------------------------------------------------------------
235 /*! Global closing function that sets our global running flag. This lets
236 the windowing system know that we want to terminate.
237 */
238 void slShouldClose(bool val)
239 {
240  gShouldClose = val;
241 }
242 //-----------------------------------------------------------------------------
243 /*! Global closing function that deallocates the sceneview and scene instances.
244 All the scenegraph deallocation is started from here and has to be done before
245 the GUI app terminates.
246 */
248 {
249  SL_LOG("Begin of Terminate");
250 
251  // Deletes all remaining sceneviews and the current scene instance
253 
254  // For more info on PROFILING read Utils/lib-utils/source/Profiler.h
255 #if PROFILING
256  SLstring filePathName = PROFILER_TRACE_FILE_PATH;
257 
258  SL_LOG("Before END_PROFILING_SESSION");
260  SL_LOG("After END_PROFILING_SESSION");
261 
263 
264  if (Utils::fileExists(filePathName))
265  SL_LOG("Profile written : %s", filePathName.c_str());
266  else
267  SL_LOG("No Profile written: %s", filePathName.c_str());
268 #else
269  SL_LOG("No Profiling");
270 #endif
271 
272  SL_LOG("End of Terminate");
273  SL_LOG("------------------------------------------------------------------");
274 }
275 //-----------------------------------------------------------------------------
276 /*!
277  * Updates the parallel running job an allowes the update of a progress bar.
278  * \return Returns true if parallel jobs are still running.
279  */
281 {
284 }
285 //-----------------------------------------------------------------------------
286 /*!
287  * Draws all scene views
288  * \return return true if another repaint is needed.
289  */
291 {
292  bool needUpdate = false;
293 
294  for (auto sv : AppCommon::sceneViews)
295  {
296  // Save previous frame as image
298  {
299  SLstring path = AppCommon::externalPath + "screenshots/";
300  Utils::makeDirRecurse(path);
301  SLstring filename = "Screenshot_" +
302  Utils::getDateTime2String() + ".png";
303  SLstring pathFilename = path + filename;
304  sv->saveFrameBufferAsImage(pathFilename);
305  }
306 
307  if (sv->onPaint() && !needUpdate)
308  needUpdate = true;
309  }
310 
311  return needUpdate;
312 }
313 //-----------------------------------------------------------------------------
314 /*! Global resize function that must be called whenever the OpenGL frame
315 changes it's size.
316 */
317 void slResize(int sceneViewIndex, int width, int height)
318 {
319  SLResizeEvent* e = new SLResizeEvent;
320  e->svIndex = sceneViewIndex;
321  e->width = width;
322  e->height = height;
324 }
325 //-----------------------------------------------------------------------------
326 /*! Global event handler for mouse button down events.
327  */
328 void slMouseDown(int sceneViewIndex,
329  SLMouseButton button,
330  int xpos,
331  int ypos,
332  SLKey modifier)
333 {
335  e->svIndex = sceneViewIndex;
336  e->button = button;
337  e->x = xpos;
338  e->y = ypos;
339  e->modifier = modifier;
341 }
342 //-----------------------------------------------------------------------------
343 /*! Global event handler for mouse move events.
344  */
345 void slMouseMove(int sceneViewIndex,
346  int x,
347  int y)
348 {
350  e->svIndex = sceneViewIndex;
351  e->x = x;
352  e->y = y;
354 }
355 //-----------------------------------------------------------------------------
356 /*! Global event handler for mouse button up events.
357  */
358 void slMouseUp(int sceneViewIndex,
359  SLMouseButton button,
360  int xpos,
361  int ypos,
362  SLKey modifier)
363 {
365  e->svIndex = sceneViewIndex;
366  e->button = button;
367  e->x = xpos;
368  e->y = ypos;
369  e->modifier = modifier;
371 }
372 //-----------------------------------------------------------------------------
373 /*! Global event handler for double click events.
374  */
375 void slDoubleClick(int sceneViewIndex,
376  SLMouseButton button,
377  int xpos,
378  int ypos,
379  SLKey modifier)
380 {
382  e->svIndex = sceneViewIndex;
383  e->button = button;
384  e->x = xpos;
385  e->y = ypos;
386  e->modifier = modifier;
388 }
389 //-----------------------------------------------------------------------------
390 /*! Global event handler for the two finger touch down events of touchscreen
391 devices.
392 */
393 void slTouch2Down(int sceneViewIndex,
394  int xpos1,
395  int ypos1,
396  int xpos2,
397  int ypos2)
398 {
400  e->svIndex = sceneViewIndex;
401  e->x1 = xpos1;
402  e->y1 = ypos1;
403  e->x2 = xpos2;
404  e->y2 = ypos2;
405 
407 }
408 //-----------------------------------------------------------------------------
409 /*! Global event handler for the two finger move events of touchscreen devices.
410  */
411 void slTouch2Move(int sceneViewIndex,
412  int xpos1,
413  int ypos1,
414  int xpos2,
415  int ypos2)
416 {
418  e->svIndex = sceneViewIndex;
419  e->x1 = xpos1;
420  e->y1 = ypos1;
421  e->x2 = xpos2;
422  e->y2 = ypos2;
424 }
425 //-----------------------------------------------------------------------------
426 /*! Global event handler for the two finger touch up events of touchscreen
427 devices.
428 */
429 void slTouch2Up(int sceneViewIndex,
430  int xpos1,
431  int ypos1,
432  int xpos2,
433  int ypos2)
434 {
436  e->svIndex = sceneViewIndex;
437  e->x1 = xpos1;
438  e->y1 = ypos1;
439  e->x2 = xpos2;
440  e->y2 = ypos2;
442 }
443 //-----------------------------------------------------------------------------
444 /*! Global event handler for mouse wheel events.
445  */
446 void slMouseWheel(int sceneViewIndex,
447  int pos,
448  SLKey modifier)
449 {
451  e->svIndex = sceneViewIndex;
452  e->y = pos;
453  e->modifier = modifier;
455 }
456 //-----------------------------------------------------------------------------
457 /*! Global event handler for keyboard key press events.
458  */
459 void slKeyPress(int sceneViewIndex,
460  SLKey key,
461  SLKey modifier)
462 {
464  e->svIndex = sceneViewIndex;
465  e->key = key;
466  e->modifier = modifier;
468 }
469 //-----------------------------------------------------------------------------
470 /*! Global event handler for keyboard key release events.
471  */
472 void slKeyRelease(int sceneViewIndex,
473  SLKey key,
474  SLKey modifier)
475 {
477  e->svIndex = sceneViewIndex;
478  e->key = key;
479  e->modifier = modifier;
481 }
482 
483 //-----------------------------------------------------------------------------
484 /*! Global event handler for unicode character input.
485  */
486 void slCharInput(int sceneViewIndex,
487  unsigned int character)
488 {
490  e->svIndex = sceneViewIndex;
491  e->character = character;
493 }
494 //-----------------------------------------------------------------------------
496 {
497  if (AppCommon::scene)
498  return AppCommon::devRot.isUsed();
499  return false;
500 }
501 //-----------------------------------------------------------------------------
502 /*! Global event handler for device rotation change with angle & and axis.
503  */
504 void slRotationQUAT(float quatX,
505  float quatY,
506  float quatZ,
507  float quatW)
508 {
509  AppCommon::devRot.onRotationQUAT(quatX, quatY, quatZ, quatW);
510 }
511 //-----------------------------------------------------------------------------
513 {
514  return AppCommon::devLoc.isUsed();
515 }
516 //-----------------------------------------------------------------------------
517 /*! Global event handler for device GPS location with longitude and latitude in
518 degrees and altitude in meters. This location uses the World Geodetic System
519 1984 (WGS 84). The accuracy in meters is a radius in which the location is with
520 a probability of 68% (2 sigma).
521 */
522 void slLocationLatLonAlt(double latitudeDEG,
523  double longitudeDEG,
524  double altitudeM,
525  float accuracyM)
526 {
528  longitudeDEG,
529  altitudeM,
530  accuracyM);
531 }
532 //-----------------------------------------------------------------------------
533 //! Global function to retrieve a window title generated by the scene library.
534 string slGetWindowTitle(int sceneViewIndex)
535 {
536  SLSceneView* sv = AppCommon::sceneViews[(SLuint)sceneViewIndex];
537  return sv->windowTitle();
538 }
539 //-----------------------------------------------------------------------------
540 // Get available external directories and inform slproject about them
541 void slSetupExternalDir(const SLstring& externalPath)
542 {
543  if (Utils::dirExists(externalPath))
544  {
545  SL_LOG("Ext. directory : %s", externalPath.c_str());
546  AppCommon::externalPath = Utils::trimRightString(externalPath, "/") + "/";
547  }
548  else
549  {
550  SL_LOG("ERROR: external directory does not exists: %s", externalPath.c_str());
551  }
552 }
553 //-----------------------------------------------------------------------------
554 //! Adds a value to the applications device parameter map
555 void slSetDeviceParameter(const SLstring& parameter,
556  SLstring value)
557 {
558  AppCommon::deviceParameter[parameter] = std::move(value);
559 }
560 //-----------------------------------------------------------------------------
The AppCommon class holds the top-level instances of the app-demo.
#define END_PROFILING_SESSION
Definition: Instrumentor.h:39
#define BEGIN_PROFILING_SESSION(name, storeInMemory, outputPath)
Definition: Instrumentor.h:38
#define PROFILE_THREAD(name)
Definition: Profiler.h:38
#define PROFILER_TRACE_FILE_PATH
Definition: Profiler.h:39
float SLfloat
Definition: SL.h:173
#define SL_LOG(...)
Definition: SL.h:233
unsigned int SLuint
Definition: SL.h:171
vector< SLstring > SLVstring
Definition: SL.h:201
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
int SLSceneID
Scene identifier.
Definition: SLEnums.h:91
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
constexpr SLSceneID SL_EMPTY_SCENE_ID
SLSceneID for an empty scene.
Definition: SLEnums.h:94
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
void(SL_STDCALL * cbOnImGuiSaveConfig)()
Callback function typedef for ImGui save config function.
Definition: SLGLImGui.h:34
void(SL_STDCALL * cbOnImGuiLoadConfig)(int dpi)
Callback function typedef for ImGui load config function.
Definition: SLGLImGui.h:31
Wrapper Class around the external ImGui GUI-framework.
void slRotationQUAT(float quatX, float quatY, float quatZ, float quatW)
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 slLoadCoreAssetsAsync()
bool slUsesRotation()
void slMouseMove(int sceneViewIndex, int x, int y)
void slSwitchScene(SLSceneView *sv, SLSceneID sceneID)
bool slUsesLocation()
void slLocationLatLonAlt(double latitudeDEG, double longitudeDEG, double altitudeM, float accuracyM)
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 slTouch2Up(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)
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
SLSceneView * slNewSceneView(SLScene *s, int dotsPerInch, SLInputManager &inputManager)
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 gShouldClose
global flag that determines if the application should be closed
Definition: SLInterface.cpp:34
void slSetDeviceParameter(const SLstring &parameter, SLstring value)
Adds a value to the applications device parameter map.
bool slShouldClose()
Declaration of the main Scene Library C-Interface.
SLScene SLSceneView SLint sceneID
Definition: SLScene.h:33
SLSceneView *SL_STDCALL * cbOnNewSceneView(SLScene *s, int dotsPerInch, SLInputManager &inputManager)
Callback function typedef for custom SLSceneView derived creator function.
Definition: SLSceneView.h:43
static void handleParallelJob()
Starts parallel job if one is queued.
Definition: AppCommon.cpp:359
static SLDeviceRotation devRot
Mobile device rotation from IMU.
Definition: AppCommon.h:64
static void registerCoreAssetsLoad()
Definition: AppCommon.cpp:143
static SLIOBuffer fontDataProp
Definition: AppCommon.h:111
static SLstring fontPath
Path to font images.
Definition: AppCommon.h:87
static SLstring configPath
Default path for calibration files.
Definition: AppCommon.h:81
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
Definition: AppCommon.h:90
static SLstring exePath
executable root path
Definition: AppCommon.h:80
static atomic< bool > jobIsRunning
True if a parallel job is running.
Definition: AppCommon.h:104
static SLDeviceLocation devLoc
Mobile device location from GPS.
Definition: AppCommon.h:65
static SLUiInterface * gui
Pointer to the GUI.
Definition: AppCommon.h:63
static SLstring modelPath
Path to 3D models.
Definition: AppCommon.h:85
static SLVSceneView sceneViews
Vector of sceneview pointers.
Definition: AppCommon.h:62
static SLIOBuffer fontDataFixed
Definition: AppCommon.h:112
static SLstring texturePath
Path to texture images.
Definition: AppCommon.h:86
static void switchScene(SLSceneView *sv, SLSceneID sceneID)
Definition: AppCommon.cpp:175
static SLstring videoPath
Path to video files.
Definition: AppCommon.h:88
static void createApp(SLstring appName)
Application creation function.
Definition: AppCommon.cpp:111
static SLstring shaderPath
Path to GLSL shader programs.
Definition: AppCommon.h:84
static SLAssetLoader * assetLoader
Asset-loader for async asset loading.
Definition: AppCommon.h:60
static SLInputManager inputManager
Input events manager.
Definition: AppCommon.h:58
static SLstring externalPath
Default path for external file storage.
Definition: AppCommon.h:82
static SLSceneID sceneID
ID of currently loaded scene.
Definition: AppCommon.h:89
static SLScene * scene
Pointer to the one and only SLScene instance.
Definition: AppCommon.h:61
static map< string, string > deviceParameter
Generic device parameter.
Definition: AppCommon.h:101
static SLstring dataPath
Path to data directory (it is set platform dependent)
Definition: AppCommon.h:83
static void deleteApp()
Calls the destructor of the single scene instance.
Definition: AppCommon.cpp:298
void endSession()
Definition: Profiler.cpp:57
static Profiler & instance()
Definition: Profiler.h:70
void loadAssetsAsync(function< void()> onDone)
Toplevel holder of the assets meshes, materials, textures and shaders.
Specialized SLInput class for unicode character input.
Definition: SLInputEvent.h:116
void isUsed(SLbool isUsed)
Setter that turns on the device rotation sensor.
void onLocationLatLonAlt(SLdouble latDEG, SLdouble lonDEG, SLdouble altM, SLfloat accuracyM)
Event handler for mobile device location update.
void isUsed(SLbool isUsed)
Setter that turns on the device rotation sensor.
void onRotationQUAT(SLfloat quatX, SLfloat quatY, SLfloat quatZ, SLfloat quatW)
Singleton class holding all OpenGL states.
Definition: SLGLState.h:71
SLstring glVersionNO()
Definition: SLGLState.h:128
static SLGLState * instance()
Public static instance getter for singleton pattern.
Definition: SLGLState.h:74
SLstring glVersion()
Definition: SLGLState.h:127
SLstring getSLVersionNO()
Returns the OpenGL Shading Language version number as a string.
Definition: SLGLState.cpp:575
SLstring glRenderer()
Definition: SLGLState.h:131
SLstring glVendor()
Definition: SLGLState.h:130
SLstring glSLVersion()
Definition: SLGLState.h:132
ImGui Interface class for forwarding all events to the original ImGui Handlers.
Definition: SLImGui.h:62
static SLfloat fontPropDots
Default font size of proportional font.
Definition: SLImGui.h:91
static SLfloat fontFixedDots
Default font size of fixed size font.
Definition: SLImGui.h:92
SLint svIndex
index of the receiving scene view for this event
Definition: SLInputEvent.h:46
SLInputManager. manages system input and custom input devices.
void queueEvent(const SLInputEvent *e)
Specialized SLInput class for all keypress related input events.
Definition: SLInputEvent.h:67
SLKey modifier
Definition: SLInputEvent.h:70
Specialized SLInput class for all mouse related input events.
Definition: SLInputEvent.h:54
SLKey modifier
Definition: SLInputEvent.h:59
SLMouseButton button
Definition: SLInputEvent.h:58
Specialized SLInput class for window resize events.
Definition: SLInputEvent.h:101
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
SLstring windowTitle()
void init(SLstring name, SLint screenWidth, SLint screenHeight, void *onWndUpdateCallback, void *onSelectNodeMeshCallback, SLUiInterface *gui, const string &configPath)
Definition: SLSceneView.cpp:64
void saveFrameBufferAsImage(SLstring pathFilename, cv::Size targetSize=cv::Size(-1, -1))
Saves after n wait frames the front frame buffer as a PNG image.
void onInitialize()
SLbool onPaint()
void screenCaptureIsRequested(bool doScreenCap)
Definition: SLSceneView.h:156
Specialized SLInput class for touch related input events.
Definition: SLInputEvent.h:78
static std::string get()
Definition: Utils.cpp:1261
string getDateTime2String()
Returns local time as string like "20190213-154611".
Definition: Utils.cpp:289
string unifySlashes(const string &inputDir, bool withTrailingSlash)
Returns the inputDir string with unified forward slashes, e.g.: "dirA/dirB/".
Definition: Utils.cpp:368
bool fileExists(const string &pathfilename)
Returns true if a file exists.
Definition: Utils.cpp:897
bool dirExists(const string &path)
Returns true if a directory exists.
Definition: Utils.cpp:790
string getDirName(const string &pathFilename)
Strip last component from file name.
Definition: Utils.cpp:598
string trimRightString(const string &s, const string &drop)
trims a string at the right end
Definition: Utils.cpp:136
bool makeDirRecurse(std::string path)
Definition: Utils.cpp:826