// JVM load the .so and calls this native function
        public static jstring stringFromJNI(JNIEnv env, jobject thiz, jobject fields)
        {
            //ConsoleExtensions.trace("enter stringFromJNI");

            // what about jobject dynamic?

            //dynamic locfields = fields;
            //locfields.foo = "foo";

            // pickerwengs.blogspot.com/2011/12/android-programming-objects-between.html

            //System.NullReferenceException: Object reference not set to an instance of an object.
            //   at jsc.Languages.C.CCompiler.WriteDecoratedMethodName(MethodBase z) in x:\jsc.internal.git\compiler\jsc\Languages\C\CCompiler.WriteDecoratedMethodName.cs:line 60
            //   at jsc.Languages.C.CCompiler.WriteDecoratedMethodName(MethodBase z, Boolean q) in x:\jsc.internal.git\compiler\jsc\Languages\C\CCompiler.WriteDecoratedMethodName.cs:line 31

            // journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/field.html



            // generic / per field variables?

            // do we need our own GC?

            if (aI64 == null)
            {
                aByteArray = new argsByteArray { env = env, fields = fields };
                aI64 = new argsI64 { env = env, fields = fields };
                aI = new argsI { env = env, fields = fields };
                aF = new argsF { env = env, fields = fields };
            }


            var m = malloc_h.mallinfo();
            var total = VrCubeWorld.ovrAppThread.__uordblks(m);

            aI64["total_allocated_space"] = total;

            if (total > GLES3JNILib.safemodeMemoryLimitMB * 1024 * 1024)
            {
                //ConsoleExtensions.trace("HUD safe mode...");

                //System.Threading.Thread.Sleep(1000);

                //GC.Collect(

                // should jsc call the finalizer too?
                //stdlib_h.free(aI64);
                //aI64 = null;

                return null;
            }



            GLES3JNILib.fields_xvalue = aI["x"];
            GLES3JNILib.fields_yvalue = aI["y"];

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150703/mousex
            GLES3JNILib.fields_mousex = aI["mousex"];
            GLES3JNILib.fields_mousey = aI["mousey"];

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150704
            GLES3JNILib.fields_ad = aI["ad"];
            GLES3JNILib.fields_ws = aI["ws"];
            GLES3JNILib.fields_c = aI["c"];
            GLES3JNILib.fields_mousewheel = aI["mousewheel"];

            if (appThread == null)
                return null;
            if (appThread.appState == null)
                return null;

            GLES3JNILib.fields_px = aF["px"];
            GLES3JNILib.fields_py = aF["py"];
            GLES3JNILib.fields_pz = aF["pz"];


            //ConsoleExtensions.trace("get fields_vertexTransform");

            GLES3JNILib.fields_vertexTransform = aByteArray["vertexTransform"];

            appThread.appState.Scene.Update();


            aF["tracking_HeadPose_Pose_Orientation_x"] = appThread.tracking.HeadPose.Pose.Orientation.x;
            aF["tracking_HeadPose_Pose_Orientation_y"] = appThread.tracking.HeadPose.Pose.Orientation.y;
            aF["tracking_HeadPose_Pose_Orientation_z"] = appThread.tracking.HeadPose.Pose.Orientation.z;
            aF["tracking_HeadPose_Pose_Orientation_w"] = appThread.tracking.HeadPose.Pose.Orientation.w;



            //void ScriptCoreLibNative_BCLImplementation_System___Action_2_Invoke(LPScriptCoreLibNative_BCLImplementation_System___Action_2, void*, void*);


            // can we do lambdas?
            //Action<string, float> set = (fname, f) =>
            //ActionStringFloat set = (fname, f) =>
            //{

            //};

            //set("tracking_HeadPose_Pose_Orientation_x", appThread.tracking.HeadPose.Pose.Orientation.x);

            //var fields_tracking_HeadPose_Pose_Orientation_x = env.GetFieldID(env, fields_GetType, "tracking_HeadPose_Pose_Orientation_x", "F");

            //env.SetFloatField(env, fields, fields_tracking_HeadPose_Pose_Orientation_x,
            //    appThread.tracking.HeadPose.Pose.Orientation.x
            //);


            // what about sending back a variable_

            //appThread.tracking.HeadPose.Pose.Orientation.x;


            // GetIntField
            // if we add a field how can we inspect it?

            // called by
            // X:\jsc.svn\examples\java\android\synergy\OVRVrCubeWorldSurfaceView\OVRVrCubeWorldSurfaceViewX\ApplicationActivity.cs

            // jstring Java_com_oculus_gles3jni_GLES3JNILib_stringFromJNI(JNIEnv* env, jobject thiz)
            // X:\jsc.svn\examples\c\Test\TestNamespaceFixup\TestNamespaceFixup\Class1.cs

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150607-1/vrcubeworld
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150525


            // look almost the same file!

            // OVR_VRAPI_EXPORT const char * vrapi_GetVersionString();

            //if (fields == null)
            //{
            //    return env.NewStringUTF(env, "dynamic fields null?");

            //}

            //// if we change our NDK code, will nuget packaing work on the background, and also upgrade running apps?
            //var v = env.NewStringUTF(env,
            //    //"hey! XNDK!"

            //    VrApi.vrapi_GetVersionString()
            //);

            //v = env.JNIEnv_NewStringUTF(VrApi.vrapi_GetVersionString());
            // the other option is to have a debugger send the updated MSIL via edit and continue, and we would have to patch the function on the fly.

            //ConsoleExtensions.trace("exit stringFromJNI");
            return null;
        }
Example #2
0
        // JVM load the .so and calls this native function
        public static jstring stringFromJNI(JNIEnv env, jobject thiz, jobject fields)
        {
            //ConsoleExtensions.trace("enter stringFromJNI");

            // what about jobject dynamic?

            //dynamic locfields = fields;
            //locfields.foo = "foo";

            // pickerwengs.blogspot.com/2011/12/android-programming-objects-between.html

            //System.NullReferenceException: Object reference not set to an instance of an object.
            //   at jsc.Languages.C.CCompiler.WriteDecoratedMethodName(MethodBase z) in x:\jsc.internal.git\compiler\jsc\Languages\C\CCompiler.WriteDecoratedMethodName.cs:line 60
            //   at jsc.Languages.C.CCompiler.WriteDecoratedMethodName(MethodBase z, Boolean q) in x:\jsc.internal.git\compiler\jsc\Languages\C\CCompiler.WriteDecoratedMethodName.cs:line 31

            // journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/field.html



            // generic / per field variables?

            // do we need our own GC?

            if (aI64 == null)
            {
                aByteArray = new argsByteArray {
                    env = env, fields = fields
                };
                aI64 = new argsI64 {
                    env = env, fields = fields
                };
                aI = new argsI {
                    env = env, fields = fields
                };
                aF = new argsF {
                    env = env, fields = fields
                };
            }


            var m     = malloc_h.mallinfo();
            var total = VrCubeWorld.ovrAppThread.__uordblks(m);

            aI64["total_allocated_space"] = total;

            if (total > GLES3JNILib.safemodeMemoryLimitMB * 1024 * 1024)
            {
                //ConsoleExtensions.trace("HUD safe mode...");

                //System.Threading.Thread.Sleep(1000);

                //GC.Collect(

                // should jsc call the finalizer too?
                //stdlib_h.free(aI64);
                //aI64 = null;

                return(null);
            }



            GLES3JNILib.fields_xvalue = aI["x"];
            GLES3JNILib.fields_yvalue = aI["y"];

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150703/mousex
            GLES3JNILib.fields_mousex = aI["mousex"];
            GLES3JNILib.fields_mousey = aI["mousey"];

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150704
            GLES3JNILib.fields_ad         = aI["ad"];
            GLES3JNILib.fields_ws         = aI["ws"];
            GLES3JNILib.fields_c          = aI["c"];
            GLES3JNILib.fields_mousewheel = aI["mousewheel"];

            if (appThread == null)
            {
                return(null);
            }
            if (appThread.appState == null)
            {
                return(null);
            }

            GLES3JNILib.fields_px = aF["px"];
            GLES3JNILib.fields_py = aF["py"];
            GLES3JNILib.fields_pz = aF["pz"];


            //ConsoleExtensions.trace("get fields_vertexTransform");

            GLES3JNILib.fields_vertexTransform = aByteArray["vertexTransform"];

            appThread.appState.Scene.Update();


            aF["tracking_HeadPose_Pose_Orientation_x"] = appThread.tracking.HeadPose.Pose.Orientation.x;
            aF["tracking_HeadPose_Pose_Orientation_y"] = appThread.tracking.HeadPose.Pose.Orientation.y;
            aF["tracking_HeadPose_Pose_Orientation_z"] = appThread.tracking.HeadPose.Pose.Orientation.z;
            aF["tracking_HeadPose_Pose_Orientation_w"] = appThread.tracking.HeadPose.Pose.Orientation.w;



            //void ScriptCoreLibNative_BCLImplementation_System___Action_2_Invoke(LPScriptCoreLibNative_BCLImplementation_System___Action_2, void*, void*);


            // can we do lambdas?
            //Action<string, float> set = (fname, f) =>
            //ActionStringFloat set = (fname, f) =>
            //{

            //};

            //set("tracking_HeadPose_Pose_Orientation_x", appThread.tracking.HeadPose.Pose.Orientation.x);

            //var fields_tracking_HeadPose_Pose_Orientation_x = env.GetFieldID(env, fields_GetType, "tracking_HeadPose_Pose_Orientation_x", "F");

            //env.SetFloatField(env, fields, fields_tracking_HeadPose_Pose_Orientation_x,
            //    appThread.tracking.HeadPose.Pose.Orientation.x
            //);


            // what about sending back a variable_

            //appThread.tracking.HeadPose.Pose.Orientation.x;


            // GetIntField
            // if we add a field how can we inspect it?

            // called by
            // X:\jsc.svn\examples\java\android\synergy\OVRVrCubeWorldSurfaceView\OVRVrCubeWorldSurfaceViewX\ApplicationActivity.cs

            // jstring Java_com_oculus_gles3jni_GLES3JNILib_stringFromJNI(JNIEnv* env, jobject thiz)
            // X:\jsc.svn\examples\c\Test\TestNamespaceFixup\TestNamespaceFixup\Class1.cs

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150607-1/vrcubeworld
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150525


            // look almost the same file!

            // OVR_VRAPI_EXPORT const char * vrapi_GetVersionString();

            //if (fields == null)
            //{
            //    return env.NewStringUTF(env, "dynamic fields null?");

            //}

            //// if we change our NDK code, will nuget packaing work on the background, and also upgrade running apps?
            //var v = env.NewStringUTF(env,
            //    //"hey! XNDK!"

            //    VrApi.vrapi_GetVersionString()
            //);

            //v = env.JNIEnv_NewStringUTF(VrApi.vrapi_GetVersionString());
            // the other option is to have a debugger send the updated MSIL via edit and continue, and we would have to patch the function on the fly.

            //ConsoleExtensions.trace("exit stringFromJNI");
            return(null);
        }