29 #define GLFW_INCLUDE_NONE 
   30 #include <GLFW/glfw3.h> 
   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);
 
   64 static void   onClose(GLFWwindow* myWindow);
 
   79     for (
int i = 1; i < cmdLineArgs.size(); ++i)
 
   80         if (cmdLineArgs[i] == 
"-onlyErrorLogs")
 
   85         fprintf(stderr, 
"Failed to initialize GLFW\n");
 
   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);
 
  116     glfwMakeContextCurrent(
window);
 
  123     glfwSetInputMode(
window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
 
  147     SL_LOG(
"------------------------------------------------------------------");
 
  149     SL_LOG(
"Platform         : GLFW (Version: %d.%d.%d)",
 
  152            GLFW_VERSION_REVISION);
 
  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/",
 
  189                       reinterpret_cast<void*
>(
onPaint),
 
  215     glfwDestroyWindow(
window);
 
  250     return appNeedsUpdate || viewNeedsUpdate || jobIsRunning || isLoading;
 
  258     fputs(description, stderr);
 
  265 static void onResize(GLFWwindow* myWindow, 
int width, 
int height)
 
  272         float aspectRatio = (float)width / (
float)height;
 
  275         if ((
float)height * aspectRatio <= (float)width)
 
  277             width  = (int)((
float)height * aspectRatio);
 
  278             height = (int)((
float)width / aspectRatio);
 
  282             height = (int)((
float)width / aspectRatio);
 
  283             width  = (int)((
float)height * aspectRatio);
 
  316     if (action == GLFW_PRESS)
 
  322         if (mouseDeltaTime < 0.3f)
 
  326                 case GLFW_MOUSE_BUTTON_LEFT:
 
  329                 case GLFW_MOUSE_BUTTON_RIGHT:
 
  332                 case GLFW_MOUSE_BUTTON_MIDDLE:
 
  342                 case GLFW_MOUSE_BUTTON_LEFT:
 
  348                 case GLFW_MOUSE_BUTTON_RIGHT:
 
  351                 case GLFW_MOUSE_BUTTON_MIDDLE:
 
  365             case GLFW_MOUSE_BUTTON_LEFT:
 
  368             case GLFW_MOUSE_BUTTON_RIGHT:
 
  371             case GLFW_MOUSE_BUTTON_MIDDLE:
 
  410     int dY = (int)yscroll;
 
  420 static void onKey(GLFWwindow* myWindow,
 
  431     if (action == GLFW_PRESS)
 
  441     else if (action == GLFW_RELEASE)
 
  461     if (key == 
K_F9 && action == GLFW_PRESS)
 
  467             GLFWmonitor*       primary = glfwGetPrimaryMonitor();
 
  468             const GLFWvidmode* 
mode    = glfwGetVideoMode(primary);
 
  469             glfwSetWindowSize(myWindow, 
mode->width, 
mode->height);
 
  471             glfwSetWindowPos(myWindow, 0, 0);
 
  482     if (action == GLFW_PRESS)
 
  484     else if (action == GLFW_RELEASE)
 
  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; 
 
  534         case GLFW_KEY_TAB: 
return K_tab;
 
  535         case GLFW_KEY_ENTER: 
return K_enter;
 
  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;
 
  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;
 
  556         case GLFW_KEY_KP_ADD: 
return K_NPAdd;
 
  558         case GLFW_KEY_UNKNOWN: 
return K_none;
 
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.
 
static SLint svIndex
Scene view index.
 
static SLfloat contentScaleY
Content scale in Y direction.
 
static SLbool onPaint()
Static paint function that gets called once every frame.
 
static SLint scrHeight
Window height at start up.
 
static SLint startY
start position y in pixels
 
static void onClose(GLFWwindow *myWindow)
 
static SLKey modifiers
last modifier keys
 
static void onMouseButton(GLFWwindow *myWindow, int button, int action, int mods)
 
static SLfloat lastMouseDownTime
Last mouse press time.
 
static SLbool fullscreen
flag if window is in fullscreen mode
 
static SLint mouseX
Last mouse position x in pixels.
 
static GLFWwindow * window
The global glfw window handle.
 
static SLfloat contentScaleX
Content scale in X direction.
 
static SLVec2i windowPosBeforeFullscreen
Window position before entering fullscreen mode.
 
static SLint lastHeight
Last window height in pixels.
 
static void onMouseWheel(GLFWwindow *myWindow, double xscroll, double yscroll)
 
static SLint startX
start position x in pixels
 
static void onResize(GLFWwindow *myWindow, int width, int height)
 
static SLint lastWidth
Last window width in pixels.
 
static SLint mouseY
Last mouse position y in pixels.
 
static void onMouseMove(GLFWwindow *myWindow, double x, double y)
 
static SLint scrWidth
Window width at start up.
 
static SLbool fixAspectRatio
Flag if wnd aspect ratio should be fixed.
 
static void onKey(GLFWwindow *myWindow, int GLFWKey, int scancode, int action, int mods)
 
static void onGLFWError(int error, const char *description)
 
static void onCharInput(GLFWwindow *, SLuint c)
Event handler for GLFW character input.
 
static SLKey mapKeyToSLKey(int key)
Maps the GLFW key codes to the SLKey codes.
 
#define PROFILE_SCOPE(name)
 
vector< SLstring > SLVstring
 
#define SL_EXIT_MSG(message)
 
SLKey
Keyboard key codes enumeration.
 
Singleton class for global render state.
 
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)
 
string slGetWindowTitle(int sceneViewIndex)
Global function to retrieve a window title generated by the scene library.
 
void slKeyPress(int sceneViewIndex, SLKey key, SLKey modifier)
 
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)
 
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)
 
Declaration of the main Scene Library C-Interface.
 
static WAI::ModeOrbSlam2 * mode
 
static SLstring asciiLabel
SLProject ascii label string.
 
static SLstring calibIniPath
That's where data/calibrations folder is located.
 
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
 
static SLAssetManager * assetManager
asset manager is the owner of all assets
 
static SLVSceneView sceneViews
Vector of sceneview pointers.
 
static SLAssetLoader * assetLoader
Asset-loader for async asset loading.
 
static SLScene * scene
Pointer to the one and only SLScene instance.
 
static SLstring calibFilePath
That's where calibrations are stored and loaded from.
 
void loadCalibrations(const string &computerInfo, const string &configPath)
 
static CVCapture * instance()
Public static instance getter for singleton pattern.
 
void checkIfAsyncLoadingIsDone()
 
SceneView class represents a dynamic real time 3D view onto the scene.
 
int run(Config config)
App::run implementation from App.h for the Emscripten platform.
 
Config config
The configuration set in App::run.
 
string getAppsWritableDir(string appName)
Returns the writable configuration directory.
 
bool onlyErrorLogs
if this flag is set to true all calls to log get ignored
 
App configuration struct to be passed to the App::run function.
 
OnGuiLoadConfigCallback onGuiLoadConfig
 
OnNewSceneViewCallback onNewSceneView
 
OnUpdateCallback onUpdate
 
OnGuiSaveConfigCallback onGuiSaveConfig
 
OnGuiBuildCallback onGuiBuild