SLProject 4.0.000
AppDemoMainGLFW.cpp File Reference
#include <SLGLState.h>
#include <SLEnums.h>
#include <SLInterface.h>
#include <AppDemo.h>
#include <SLAssetManager.h>
#include <SLScene.h>
#include <SLSceneView.h>
#include <CVCapture.h>
#include <AppDemoGui.h>
#include <AppDemoSceneView.h>
#include <GLFW/glfw3.h>
#include <Profiler.h>
Include dependency graph for AppDemoMainGLFW.cpp:

Functions

void appDemoLoadScene (SLAssetManager *am, SLScene *s, SLSceneView *sv, SLSceneID sceneID)
 Forward declaration of the scene definition function from AppDemoLoad.cpp. More...
 
bool onUpdateVideo ()
 Implements the update per frame for video update and feature tracking. More...
 
void onClose (GLFWwindow *myWindow)
 
SLbool onPaint ()
 
SLKey mapKeyToSLKey (SLint key)
 Maps the GLFW key codes to the SLKey codes. More...
 
static void onResize (GLFWwindow *myWindow, int width, int height)
 
static void onMouseButton (GLFWwindow *myWindow, int button, int action, int mods)
 
static void onMouseMove (GLFWwindow *myWindow, double x, double y)
 
static void onMouseWheel (GLFWwindow *myWindow, double xscroll, double yscroll)
 
static void onKeyPress (GLFWwindow *myWindow, int GLFWKey, int scancode, int action, int mods)
 
void onCharInput (GLFWwindow *, SLuint c)
 Event handler for GLFW character input. More...
 
void onGLFWError (int error, const char *description)
 
SLSceneViewcreateAppDemoSceneView (SLScene *scene, int curDPI, SLInputManager &inputManager)
 Alternative SceneView creation C-function passed by slCreateSceneView. More...
 
void initGLFW (int screenWidth, int screenHeight)
 Initialises all GLFW and GL3W stuff. More...
 
void initSL (SLVstring &cmdLineArgs)
 Inits all for SLProject library. More...
 
int main (int argc, char *argv[])
 

Variables

static GLFWwindow * window
 The global glfw window handle. More...
 
static SLint svIndex
 SceneView index. More...
 
static SLint scrWidth
 Window width at start up. More...
 
static SLint scrHeight
 Window height at start up. More...
 
static SLbool fixAspectRatio
 Flag if wnd aspect ratio should be fixed. More...
 
static SLfloat scrWdivH
 aspect ratio screen width divided by height More...
 
static SLint dpi = 142
 Dot per inch resolution of screen. More...
 
static SLint startX
 start position x in pixels More...
 
static SLint startY
 start position y in pixels More...
 
static SLint mouseX
 Last mouse position x in pixels. More...
 
static SLint mouseY
 Last mouse position y in pixels. More...
 
static SLVec2i touch2
 Last finger touch 2 position in pixels. More...
 
static SLVec2i touchDelta
 Delta between two fingers in x. More...
 
static SLint lastWidth
 Last window width in pixels. More...
 
static SLint lastHeight
 Last window height in pixels. More...
 
static SLfloat lastMouseDownTime = 0.0f
 Last mouse press time. More...
 
static SLKey modifiers = K_none
 last modifier keys More...
 
static SLbool fullscreen = false
 flag if window is in fullscreen mode More...
 

Function Documentation

◆ appDemoLoadScene()

void appDemoLoadScene ( SLAssetManager am,
SLScene s,
SLSceneView sv,
SLSceneID  sceneID 
)

Forward declaration of the scene definition function from AppDemoLoad.cpp.

Forward declaration of the scene definition function from AppDemoLoad.cpp.

appDemoLoadScene builds a scene from source code. Such a function must be passed as a void*-pointer to slCreateScene. It will be called from within slCreateSceneView as soon as the view is initialized. You could separate different scene by a different sceneID.
The purpose is to assemble a scene by creating scenegraph objects with nodes (SLNode) and meshes (SLMesh). See the scene with SID_Minimal for a minimal example of the different steps.

◆ createAppDemoSceneView()

SLSceneView * createAppDemoSceneView ( SLScene scene,
int  curDPI,
SLInputManager inputManager 
)

Alternative SceneView creation C-function passed by slCreateSceneView.

◆ initGLFW()

void initGLFW ( int  screenWidth,
int  screenHeight 
)

Initialises all GLFW and GL3W stuff.

◆ initSL()

void initSL ( SLVstring cmdLineArgs)

Inits all for SLProject library.

◆ main()

int main ( int  argc,
char *  argv[] 
)

The C main procedure running the GLFW GUI application.

◆ mapKeyToSLKey()

SLKey mapKeyToSLKey ( SLint  key)

Maps the GLFW key codes to the SLKey codes.

◆ onCharInput()

void onCharInput ( GLFWwindow *  ,
SLuint  c 
)

Event handler for GLFW character input.

◆ onClose()

void onClose ( GLFWwindow *  myWindow)

onClose event handler for deallocation of the scene & sceneview. onClose is called glfwPollEvents, glfwWaitEvents or glfwSwapBuffers.

◆ onGLFWError()

void onGLFWError ( int  error,
const char *  description 
)

Error callback handler for GLFW.

◆ onKeyPress()

static void onKeyPress ( GLFWwindow *  myWindow,
int  GLFWKey,
int  scancode,
int  action,
int  mods 
)
static

Key event handler sets the modifier key state & forwards the event to the slKeyPress function.

◆ onMouseButton()

static void onMouseButton ( GLFWwindow *  myWindow,
int  button,
int  action,
int  mods 
)
static

Mouse button event handler forwards the events to the slMouseDown or slMouseUp. Two finger touches of touch devices are simulated with ALT & CTRL modifiers.

◆ onMouseMove()

static void onMouseMove ( GLFWwindow *  myWindow,
double  x,
double  y 
)
static

Mouse move event handler forwards the events to slMouseMove or slTouch2Move.

◆ onMouseWheel()

static void onMouseWheel ( GLFWwindow *  myWindow,
double  xscroll,
double  yscroll 
)
static

Mouse wheel event handler forwards the events to slMouseWheel

◆ onPaint()

SLbool onPaint ( )

onPaint: Paint event handler that passes the event to the slPaint function.

◆ onResize()

static void onResize ( GLFWwindow *  myWindow,
int  width,
int  height 
)
static

onResize: Event handler called on the resize event of the window. This event should called once before the onPaint event.

◆ onUpdateVideo()

bool onUpdateVideo ( )

Implements the update per frame for video update and feature tracking.

This routine is called once per frame before any other update within the the main rendering loop (see: AppDemoMainGLFW::onPaint or GLES3View::onDrawFrame). See the documentation within SLCVTracked and in all of its inheritants.

Variable Documentation

◆ dpi

SLint dpi = 142
static

Dot per inch resolution of screen.

◆ fixAspectRatio

SLbool fixAspectRatio
static

Flag if wnd aspect ratio should be fixed.

◆ fullscreen

SLbool fullscreen = false
static

flag if window is in fullscreen mode

◆ lastHeight

SLint lastHeight
static

Last window height in pixels.

◆ lastMouseDownTime

SLfloat lastMouseDownTime = 0.0f
static

Last mouse press time.

◆ lastWidth

SLint lastWidth
static

Last window width in pixels.

◆ modifiers

SLKey modifiers = K_none
static

last modifier keys

◆ mouseX

SLint mouseX
static

Last mouse position x in pixels.

◆ mouseY

SLint mouseY
static

Last mouse position y in pixels.

◆ scrHeight

SLint scrHeight
static

Window height at start up.

◆ scrWdivH

SLfloat scrWdivH
static

aspect ratio screen width divided by height

◆ scrWidth

SLint scrWidth
static

Window width at start up.

◆ startX

SLint startX
static

start position x in pixels

◆ startY

SLint startY
static

start position y in pixels

◆ svIndex

SLint svIndex
static

SceneView index.

◆ touch2

SLVec2i touch2
static

Last finger touch 2 position in pixels.

◆ touchDelta

SLVec2i touchDelta
static

Delta between two fingers in x.

◆ window

GLFWwindow* window
static

The global glfw window handle.