SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppAndroid.cpp File Reference

App::run implementation from App.h for the Android platform. More...

#include <App.h>
#include <SLGLState.h>
#include <SLEnums.h>
#include <SLInterface.h>
#include <AppCommon.h>
#include <SLAssetManager.h>
#include <SLScene.h>
#include <SLSceneView.h>
#include <CVCapture.h>
#include <Profiler.h>
#include <SLAssetLoader.h>
#include "mediapipe.h"
#include <jni.h>
Include dependency graph for AppAndroid.cpp:

Go to the source code of this file.

Functions

int slAndroidMain (int argc, char *argv[])
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onInit (JNIEnv *env, jclass obj, jint width, jint height, jint dpi, jstring filePath)
 Creates the scene and sceneview instance. More...
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTerminate (JNIEnv *env, jclass obj)
 
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onPaintAllViews (JNIEnv *env, jclass obj)
 
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onUpdate (JNIEnv *env, jclass obj)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onResize (JNIEnv *env, jclass obj, jint width, jint height)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseDown (JNIEnv *env, jclass obj, jint button, jint x, jint y)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseUp (JNIEnv *env, jclass obj, jint button, jint x, jint y)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseMove (JNIEnv *env, jclass obj, jint x, jint y)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Down (JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Move (JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Up (JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onDoubleClick (JNIEnv *env, jclass obj, jint button, jint x, jint y)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onClose (JNIEnv *env, jclass obj)
 
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesRotation (JNIEnv *env, jclass obj)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onRotationQUAT (JNIEnv *env, jclass obj, jfloat quatX, jfloat quatY, jfloat quatZ, jfloat quatW)
 
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesLocation (JNIEnv *env, jclass obj)
 Asks the SLApplicaiton class if the GPS sensor data is requested. More...
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onLocationLatLonAlt (JNIEnv *env, jclass obj, jdouble latitudeDEG, jdouble longitudeDEG, jdouble altitudeM, jfloat accuracyM)
 Copies the GPS information to the SLApplicaiton class. More...
 
JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoType (JNIEnv *env, jclass obj)
 
JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoSizeIndex (JNIEnv *env, jclass obj)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_grabVideoFileFrame (JNIEnv *env, jclass obj)
 Grabs a frame from a video file using OpenCV. More...
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoImage (JNIEnv *env, jclass obj, jint imgWidth, jint imgHeight, jbyteArray imgBuffer)
 Copies the video image data to the CVCapture class. More...
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onSetupExternalDir (JNIEnv *env, jclass obj, jstring externalDirPath)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoYUVPlanes (JNIEnv *env, jclass obj, jint srcW, jint srcH, jbyteArray yBuf, jint ySize, jint yPixStride, jint yLineStride, jbyteArray uBuf, jint uSize, jint uPixStride, jint uLineStride, jbyteArray vBuf, jint vSize, jint vPixStride, jint vLineStride)
 This function is not in use and was an attempt to copy the data faster. More...
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setCameraSize (JNIEnv *env, jclass obj, jint sizeIndex, jint sizeIndexMax, jint width, jint height)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setDeviceParameter (JNIEnv *env, jclass obj, jstring parameter, jstring value)
 
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_initMediaPipeAssetManager (JNIEnv *env, jclass obj, jobject assetManager, jstring cacheDirPath)
 
bool Java_renderRaytracingCallback ()
 Native ray tracing callback function that calls the Java class method AppAndroidJNI.RaytracingCallback. More...
 
static void printGLString (const char *name, GLenum s)
 Native OpenGL info string print functions used in onInit. More...
 
std::string jstring2stdstring (JNIEnv *env, jstring jStr)
 

Variables

static JNIEnv * environment
 
static int svIndex = 0
 Pointer to JAVA environment used in ray tracing callback. More...
 

Detailed Description

App::run implementation from App.h for the Android platform.

The functions implement mostly the callbacks for the platform Android over the JNI interface into SLInterface.h. For more info on how to create a new app with SLProject see: https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App For more info about App framework see: https://cpvrlab.github.io/SLProject4/app-framework.html

Date
June 2024
Authors
Marino von Wattenwyl
Remarks
Please use clangformat to format the code. See more code style on https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style

Definition in file AppAndroid.cpp.

Function Documentation

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoImage()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoImage ( JNIEnv *  env,
jclass  obj,
jint  imgWidth,
jint  imgHeight,
jbyteArray  srcBuffer 
)

Copies the video image data to the CVCapture class.

Definition at line 296 of file AppAndroid.cpp.

297 {
298  SLuchar* srcLumaPtr = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(imgBuffer, 0));
299 
300  if (srcLumaPtr == nullptr)
301  SL_EXIT_MSG("copyVideoImage: No image data pointer passed!");
302 
304  CVCapture* capture = CVCapture::instance();
305  float videoImgWdivH = (float)imgWidth / (float)imgHeight;
306 
307  if (sv->viewportSameAsVideo())
308  {
309  // If video aspect has changed we need to tell the new viewport to the sceneview
310  if (Utils::abs(videoImgWdivH - sv->viewportWdivH()) > 0.01f)
311  sv->setViewportFromRatio(SLVec2i(imgWidth, imgHeight), sv->viewportAlign(), true);
312  }
313 
314  capture->loadIntoLastFrame(sv->viewportWdivH(), imgWidth, imgHeight, PF_yuv_420_888, srcLumaPtr, true);
315 }
@ PF_yuv_420_888
Definition: CVImage.h:26
unsigned char SLuchar
Definition: SL.h:163
#define SL_EXIT_MSG(message)
Definition: SL.h:240
static SLVSceneView sceneViews
Vector of sceneview pointers.
Definition: AppCommon.h:62
Encapsulation of the OpenCV Capture Device and holder of the last frame.
Definition: CVCapture.h:63
static CVCapture * instance()
Public static instance getter for singleton pattern.
Definition: CVCapture.h:65
void loadIntoLastFrame(float vieportWdivH, int camWidth, int camHeight, CVPixelFormatGL srcPixelFormat, const uchar *data, bool isContinuous)
Definition: CVCapture.cpp:301
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
void viewportSameAsVideo(bool sameAsVideo)
Definition: SLSceneView.h:155
void setViewportFromRatio(const SLVec2i &vpRatio, SLViewportAlign vpAlignment, SLbool vpSameAsVideo)
Sets the viewport ratio and the viewport rectangle.
SLViewportAlign viewportAlign() const
Definition: SLSceneView.h:181
SLfloat viewportWdivH() const
Definition: SLSceneView.h:178
T abs(T a)
Definition: Utils.h:249

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoYUVPlanes()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoYUVPlanes ( JNIEnv *  env,
jclass  obj,
jint  srcW,
jint  srcH,
jbyteArray  yBuf,
jint  ySize,
jint  yPixStride,
jint  yLineStride,
jbyteArray  uBuf,
jint  uSize,
jint  uPixStride,
jint  uLineStride,
jbyteArray  vBuf,
jint  vSize,
jint  vPixStride,
jint  vLineStride 
)

This function is not in use and was an attempt to copy the data faster.

Definition at line 318 of file AppAndroid.cpp.

319 {
320  // Cast jbyteArray to unsigned char pointer
321  SLuchar* y = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(yBuf, 0));
322  SLuchar* u = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(uBuf, 0));
323  SLuchar* v = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(vBuf, 0));
324 
325  if (y == nullptr) SL_EXIT_MSG("copyVideoYUVPlanes: No pointer for y-buffer passed!");
326  if (u == nullptr) SL_EXIT_MSG("copyVideoYUVPlanes: No pointer for u-buffer passed!");
327  if (v == nullptr) SL_EXIT_MSG("copyVideoYUVPlanes: No pointer for v-buffer passed!");
328 
329  // If viewportWdivH is negative the viewport aspect will be adapted to the video
330  // aspect ratio. No cropping will be applied.
331  float viewportWdivH = AppCommon::sceneViews[0]->viewportWdivH();
332  if (AppCommon::sceneViews[0]->viewportSameAsVideo())
333  viewportWdivH = -1;
334 
335  CVCapture::instance()->copyYUVPlanes(viewportWdivH, srcW, srcH, y, ySize, yPixStride, yLineStride, u, uSize, uPixStride, uLineStride, v, vSize, vPixStride, vLineStride);
336 }
void copyYUVPlanes(float scrWdivH, int srcW, int srcH, uchar *y, int ySize, int yPixStride, int yLineStride, uchar *u, int uSize, int uPixStride, int uLineStride, uchar *v, int vSize, int vPixStride, int vLineStride)
Copies and converts the video image in YUV_420 format to RGB and Grayscale.
Definition: CVCapture.cpp:695

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoSizeIndex()

JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoSizeIndex ( JNIEnv *  env,
jclass  obj 
)

Definition at line 264 of file AppAndroid.cpp.

265 {
267 }
int camSizeIndex()
Definition: CVCamera.h:27
CVCamera * activeCamera
Pointer to the active camera.
Definition: CVCapture.h:136

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoType()

JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoType ( JNIEnv *  env,
jclass  obj 
)

Definition at line 257 of file AppAndroid.cpp.

258 {
259  return (int)CVCapture::instance()->videoType();
260 }
void videoType(CVVideoType vt)
Setter for video type also sets the active calibration.
Definition: CVCapture.cpp:866

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_grabVideoFileFrame()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_grabVideoFileFrame ( JNIEnv *  env,
jclass  obj 
)

Grabs a frame from a video file using OpenCV.

Definition at line 270 of file AppAndroid.cpp.

271 {
273  CVCapture* capture = CVCapture::instance();
274 
275  // Get the current capture size of the videofile
276  CVSize videoSizeBefore = capture->captureSize;
277 
278  // If viewportWdivH is negative the viewport aspect will be adapted to the video
279  // aspect ratio. No cropping will be applied.
280  // Android doesn't know the video file frame size before grab
281  float viewportWdivH = sv->viewportWdivH();
282  if (sv->viewportSameAsVideo())
283  viewportWdivH = -1;
284 
285  capture->grabAndAdjustForSL(viewportWdivH);
286 
287  // If video aspect has changed we need to tell the new viewport to the sceneview
288  CVSize videoSizeAfter = capture->captureSize;
289  if (sv->viewportSameAsVideo() && videoSizeBefore != videoSizeAfter)
290  sv->setViewportFromRatio(SLVec2i(videoSizeAfter.width, videoSizeAfter.height),
291  sv->viewportAlign(),
293 }
cv::Size CVSize
Definition: CVTypedefs.h:55
SLVec2< SLint > SLVec2i
Definition: SLVec2.h:140
CVSize captureSize
size of captured frame
Definition: CVCapture.h:123
bool grabAndAdjustForSL(float viewportWdivH)
Definition: CVCapture.cpp:235

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_initMediaPipeAssetManager()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_initMediaPipeAssetManager ( JNIEnv *  env,
jclass  obj,
jobject  assetManager,
jstring  cacheDirPath 
)

Definition at line 383 of file AppAndroid.cpp.

387 {
388  mp_init_asset_manager(env, assetManager, cacheDirPath);
389 }

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onClose()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onClose ( JNIEnv *  env,
jclass  obj 
)

Definition at line 244 of file AppAndroid.cpp.

245 {
246  SL_LOG("onClose");
247  slTerminate();
248 }
#define SL_LOG(...)
Definition: SL.h:233
void slTerminate()

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onDoubleClick()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onDoubleClick ( JNIEnv *  env,
jclass  obj,
jint  button,
jint  x,
jint  y 
)

Definition at line 234 of file AppAndroid.cpp.

235 {
237 }
static int svIndex
Pointer to JAVA environment used in ray tracing callback.
Definition: AppAndroid.cpp:36
@ MB_left
Definition: SLEnums.h:100
@ K_none
Definition: SLEnums.h:17
void slDoubleClick(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onInit()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onInit ( JNIEnv *  env,
jclass  obj,
jint  width,
jint  height,
jint  dpi,
jstring  filePath 
)

Creates the scene and sceneview instance.

Java Native Interface (JNI) function declarations. These functions are called by the Java interface class AppAndroidJNI. The function name follows the pattern Java_{package name}_{JNI class name}_{function name}(JNIEnv* env,jclass obj,*); The functions mostly forward to the C-Interface functions of SLProject declared in SLInterface.h.

Definition at line 110 of file AppAndroid.cpp.

111 {
112  environment = env;
113  const char* nativeString = env->GetStringUTFChars(filePath, 0);
114  string devicePath(nativeString);
115  env->ReleaseStringUTFChars(filePath, nativeString);
116 
117  slAndroidMain(0, nullptr);
118  const App::Config& config = App::config;
119 
120  SLVstring* cmdLineArgs = new SLVstring();
121 
122  SL_LOG("GUI : Android");
123 
124  string device_path_msg = "Device path:" + devicePath;
125  SL_LOG(device_path_msg.c_str(), 0);
126 
127  AppCommon::calibFilePath = devicePath + "/data/config/"; //that's where calibrations are stored an loaded from
128  AppCommon::calibIniPath = devicePath + "/data/calibrations/";
130  AppCommon::calibFilePath); // for calibrations made
131 
132  ////////////////////////////////////////////////////
133  slCreateApp(*cmdLineArgs,
134  devicePath + "/data/",
135  devicePath + "/data/shaders/",
136  devicePath + "/data/models/",
137  devicePath + "/data/images/textures/",
138  devicePath + "/data/images/fonts/",
139  devicePath + "/data/videos/",
140  devicePath + "/",
141  "AppDemoAndroid");
142 
144 
145  ////////////////////////////////////////////////////////////////////
148  static_cast<int>(width),
149  static_cast<int>(height),
150  static_cast<int>(dpi),
152  nullptr,
153  nullptr,
154  reinterpret_cast<void*>(config.onNewSceneView),
155  reinterpret_cast<void*>(config.onGuiBuild),
156  reinterpret_cast<void*>(config.onGuiLoadConfig),
157  reinterpret_cast<void*>(config.onGuiSaveConfig));
158  ////////////////////////////////////////////////////////////////////
159 
160  delete cmdLineArgs;
161 }
static JNIEnv * environment
Definition: AppAndroid.cpp:35
int slAndroidMain(int argc, char *argv[])
static SLint dpi
Dot per inch resolution of screen.
Definition: AppGLFW.cpp:41
vector< SLstring > SLVstring
Definition: SL.h:201
void slLoadCoreAssetsSync()
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)
static SLstring calibIniPath
That's where data/calibrations folder is located.
Definition: AppCommon.h:108
static SLAssetManager * assetManager
asset manager is the owner of all assets
Definition: AppCommon.h:59
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 std::string get()
Definition: Utils.cpp:1261
Config config
The configuration set in App::run.
Definition: AppAndroid.cpp:34
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
OnNewSceneViewCallback onNewSceneView
Definition: App.h:65
OnGuiSaveConfigCallback onGuiSaveConfig
Definition: App.h:74
OnGuiBuildCallback onGuiBuild
Definition: App.h:72

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onLocationLatLonAlt()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onLocationLatLonAlt ( JNIEnv *  env,
jclass  obj,
jdouble  latitudeDEG,
jdouble  longitudeDEG,
jdouble  altitudeM,
jfloat  accuracyM 
)

Copies the GPS information to the SLApplicaiton class.

Definition at line 339 of file AppAndroid.cpp.

345 {
346  slLocationLatLonAlt(latitudeDEG, longitudeDEG, altitudeM, accuracyM);
347 }
void slLocationLatLonAlt(double latitudeDEG, double longitudeDEG, double altitudeM, float accuracyM)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseDown()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseDown ( JNIEnv *  env,
jclass  obj,
jint  button,
jint  x,
jint  y 
)

Definition at line 204 of file AppAndroid.cpp.

205 {
206  slMouseDown(svIndex, (SLMouseButton)button, x, y, K_none);
207 }
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
void slMouseDown(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseMove()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseMove ( JNIEnv *  env,
jclass  obj,
jint  x,
jint  y 
)

Definition at line 214 of file AppAndroid.cpp.

215 {
216  slMouseMove(svIndex, x, y);
217 }
void slMouseMove(int sceneViewIndex, int x, int y)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseUp()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseUp ( JNIEnv *  env,
jclass  obj,
jint  button,
jint  x,
jint  y 
)

Definition at line 209 of file AppAndroid.cpp.

210 {
211  slMouseUp(svIndex, (SLMouseButton)button, x, y, K_none);
212 }
void slMouseUp(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onPaintAllViews()

JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onPaintAllViews ( JNIEnv *  env,
jclass  obj 
)

Definition at line 168 of file AppAndroid.cpp.

169 {
170  return slPaintAllViews();
171 }
bool slPaintAllViews()

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onResize()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onResize ( JNIEnv *  env,
jclass  obj,
jint  width,
jint  height 
)

Definition at line 199 of file AppAndroid.cpp.

200 {
201  slResize(svIndex, width, height);
202 }
void slResize(int sceneViewIndex, int width, int height)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onRotationQUAT()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onRotationQUAT ( JNIEnv *  env,
jclass  obj,
jfloat  quatX,
jfloat  quatY,
jfloat  quatZ,
jfloat  quatW 
)

Definition at line 239 of file AppAndroid.cpp.

240 {
241  slRotationQUAT(quatX, quatY, quatZ, quatW);
242 }
void slRotationQUAT(float quatX, float quatY, float quatZ, float quatW)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onSetupExternalDir()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onSetupExternalDir ( JNIEnv *  env,
jclass  obj,
jstring  externalDirPath 
)

Definition at line 355 of file AppAndroid.cpp.

358 {
359  std::string externalDirPathNative = jstring2stdstring(env, externalDirPath);
360  slSetupExternalDir(externalDirPathNative);
361 }
std::string jstring2stdstring(JNIEnv *env, jstring jStr)
Definition: AppAndroid.cpp:99
void slSetupExternalDir(const SLstring &externalPath)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onTerminate()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTerminate ( JNIEnv *  env,
jclass  obj 
)

Definition at line 163 of file AppAndroid.cpp.

164 {
165  slTerminate();
166 }

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Down()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Down ( JNIEnv *  env,
jclass  obj,
jint  x1,
jint  y1,
jint  x2,
jint  y2 
)

Definition at line 219 of file AppAndroid.cpp.

220 {
221  slTouch2Down(svIndex, x1, y1, x2, y2);
222 }
void slTouch2Down(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Move()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Move ( JNIEnv *  env,
jclass  obj,
jint  x1,
jint  y1,
jint  x2,
jint  y2 
)

Definition at line 224 of file AppAndroid.cpp.

225 {
226  slTouch2Move(svIndex, x1, y1, x2, y2);
227 }
void slTouch2Move(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Up()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Up ( JNIEnv *  env,
jclass  obj,
jint  x1,
jint  y1,
jint  x2,
jint  y2 
)

Definition at line 229 of file AppAndroid.cpp.

230 {
231  slTouch2Up(svIndex, x1, y1, x2, y2);
232 }
void slTouch2Up(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_onUpdate()

JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onUpdate ( JNIEnv *  env,
jclass  obj 
)

Definition at line 173 of file AppAndroid.cpp.

174 {
175  if (AppCommon::sceneViews.empty())
176  return false;
177 
179 
181  {
183  AppCommon::sceneToLoad = {}; // sets optional to empty
184  }
185 
186  if (AppCommon::assetLoader->isLoading())
188 
189  ////////////////////////////////////////////////////////////////
190  SLbool appNeedsUpdate = App::config.onUpdate && App::config.onUpdate(sv);
191  SLbool jobIsRunning = slUpdateParallelJob();
192  SLbool isLoading = AppCommon::assetLoader->isLoading();
193  SLbool viewNeedsUpdate = slPaintAllViews();
194  ////////////////////////////////////////////////////////////////
195 
196  return appNeedsUpdate || viewNeedsUpdate || jobIsRunning || isLoading;
197 }
bool SLbool
Definition: SL.h:175
void slSwitchScene(SLSceneView *sv, SLSceneID sceneID)
bool slUpdateParallelJob()
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
Definition: AppCommon.h:90
static SLAssetLoader * assetLoader
Asset-loader for async asset loading.
Definition: AppCommon.h:60
void checkIfAsyncLoadingIsDone()
bool isLoading() const
Definition: SLAssetLoader.h:68
OnUpdateCallback onUpdate
Definition: App.h:71

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_setCameraSize()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setCameraSize ( JNIEnv *  env,
jclass  obj,
jint  sizeIndex,
jint  sizeIndexMax,
jint  width,
jint  height 
)

Definition at line 363 of file AppAndroid.cpp.

369 {
370  CVCapture::instance()->setCameraSize(sizeIndex, sizeIndexMax, width, height);
371 }
void setCameraSize(int sizeIndex, int sizeIndexMax, int width, int height)
Definition: CVCapture.cpp:969

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_setDeviceParameter()

JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setDeviceParameter ( JNIEnv *  env,
jclass  obj,
jstring  parameter,
jstring  value 
)

Definition at line 373 of file AppAndroid.cpp.

377 {
378  std::string par = jstring2stdstring(env, parameter);
379  std::string val = jstring2stdstring(env, value);
380  slSetDeviceParameter(par.c_str(), val.c_str());
381 }
void slSetDeviceParameter(const SLstring &parameter, SLstring value)
Adds a value to the applications device parameter map.

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_usesLocation()

JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesLocation ( JNIEnv *  env,
jclass  obj 
)

Asks the SLApplicaiton class if the GPS sensor data is requested.

Definition at line 350 of file AppAndroid.cpp.

351 {
352  return slUsesLocation();
353 }
bool slUsesLocation()

◆ Java_ch_bfh_cpvrlab_AppAndroidJNI_usesRotation()

JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesRotation ( JNIEnv *  env,
jclass  obj 
)

Definition at line 250 of file AppAndroid.cpp.

251 {
252  return slUsesRotation();
253 }
bool slUsesRotation()

◆ Java_renderRaytracingCallback()

bool Java_renderRaytracingCallback ( )

Native ray tracing callback function that calls the Java class method AppAndroidJNI.RaytracingCallback.

Definition at line 85 of file AppAndroid.cpp.

86 {
87  jclass klass = environment->FindClass("ch/bfh/cpvrlab/AppAndroidJNI");
88  jmethodID method = environment->GetStaticMethodID(klass, "RaytracingCallback", "()Z");
89  return environment->CallStaticBooleanMethod(klass, method);
90 }

◆ jstring2stdstring()

std::string jstring2stdstring ( JNIEnv *  env,
jstring  jStr 
)

Definition at line 99 of file AppAndroid.cpp.

100 {
101  if (!jStr) return "";
102  jboolean isCopy;
103  const char* chars = env->GetStringUTFChars(jStr, &isCopy);
104  std::string stdString(chars);
105  env->ReleaseStringUTFChars(jStr, chars);
106  return stdString;
107 }

◆ printGLString()

static void printGLString ( const char *  name,
GLenum  s 
)
static

Native OpenGL info string print functions used in onInit.

Definition at line 93 of file AppAndroid.cpp.

94 {
95  const char* v = (const char*)glGetString(s);
96  SL_LOG("GL %s = %s\n", name, v);
97 }
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47

◆ slAndroidMain()

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

Variable Documentation

◆ environment

JNIEnv* environment
static

Definition at line 35 of file AppAndroid.cpp.

◆ svIndex

int svIndex = 0
static

Pointer to JAVA environment used in ray tracing callback.

SceneView index

Definition at line 36 of file AppAndroid.cpp.