// vrapi_GetHmdInfo
            // called by AppThreadFunction
            public void ovrRenderer_Create(ref ovrHmdInfo hmdInfo)
            {
                ConsoleExtensions.trace("enter ovrRenderer_Create");

                fixed(int *hmdInfo_SuggestedEyeResolution = hmdInfo.SuggestedEyeResolution)
                fixed(float *hmdInfo_SuggestedEyeFov = hmdInfo.SuggestedEyeFov)
                {
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:89 hmdInfo_SuggestedEyeResolution width  1024
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:90 hmdInfo_SuggestedEyeResolution height  1024
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:91 NUM_MULTI_SAMPLES  4
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:95 hmdInfo_SuggestedEyeFov[0]  90
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:96 hmdInfo_SuggestedEyeFov[1]  90
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:97 DisplayRefreshRate  60


                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeResolution width ", hmdInfo_SuggestedEyeResolution[0]);
                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeResolution height ", hmdInfo_SuggestedEyeResolution[1]);
                    ConsoleExtensions.tracei("NUM_MULTI_SAMPLES ", NUM_MULTI_SAMPLES);


                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeFov[0] ", (int)hmdInfo_SuggestedEyeFov[0]);
                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeFov[1] ", (int)hmdInfo_SuggestedEyeFov[1]);
                    ConsoleExtensions.tracei("DisplayRefreshRate ", (int)hmdInfo.DisplayRefreshRate);


                    // 1012
                    // Create the render Textures.
                    for (int i = 0; i < NUM_BUFFERS; i++)
                    {
                        for (int eye = 0; eye < NUM_EYES; eye++)
                        {
                            //ConsoleExtensions.tracei("call ovrRenderTexture_Create i ", i);

                            this.RenderTextures[i, eye].ovrRenderTexture_Create(
                                hmdInfo_SuggestedEyeResolution[0],
                                hmdInfo_SuggestedEyeResolution[1],
                                NUM_MULTI_SAMPLES,

                                i, eye
                                );
                        }
                    }

                    this.BufferIndex = 0;

                    // https://www.kickstarter.com/projects/wearality/wearality-sky-limitless-vr
                    // jsc first pass should be a diff, to see if UDP patch can be issued instead of full build.

                    ConsoleExtensions.trace("call CreateProjectionFov");

                    // Setup the projection matrix.
                    this.ProjectionMatrix = __Matrix4x4.CreateProjectionFov(
                        hmdInfo_SuggestedEyeFov[0] * ((float)Math.PI / 180.0f),
                        hmdInfo_SuggestedEyeFov[1] * ((float)Math.PI / 180.0f),
                        0.0f, 0.0f,
                        //nearZ: 1.0f,
                        //nearZ: 2.0f,
                        //nearZ: 0.5f,

                        // this feels close
                        nearZ: 0.01f,

                        //farZ: 0.1f
                        farZ: 0.0f
                        );

                    ConsoleExtensions.trace("call TanAngleMatrixFromProjection");
                    //this.TanAngleMatrix = VrApi_Helpers.ovrMatrix4f_TanAngleMatrixFromProjection(ref this.ProjectionMatrix);
                    this.TanAngleMatrix = __Matrix4x4.TanAngleMatrixFromProjection(this.ProjectionMatrix);
                    ConsoleExtensions.trace("after call TanAngleMatrixFromProjection");
                }

                ConsoleExtensions.trace("exit ovrRenderer_Create");
            }
            // vrapi_GetHmdInfo
            // called by AppThreadFunction
            public void ovrRenderer_Create(ref ovrHmdInfo hmdInfo)
            {
                ConsoleExtensions.trace("enter ovrRenderer_Create");

                fixed (int* hmdInfo_SuggestedEyeResolution = hmdInfo.SuggestedEyeResolution)
                fixed (float* hmdInfo_SuggestedEyeFov = hmdInfo.SuggestedEyeFov)
                {
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:89 hmdInfo_SuggestedEyeResolution width  1024
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:90 hmdInfo_SuggestedEyeResolution height  1024
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:91 NUM_MULTI_SAMPLES  4
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:95 hmdInfo_SuggestedEyeFov[0]  90
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:96 hmdInfo_SuggestedEyeFov[1]  90
                    //I/xNativeActivity(26905): \VrCubeWorld.Renderer.cs:97 DisplayRefreshRate  60


                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeResolution width ", hmdInfo_SuggestedEyeResolution[0]);
                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeResolution height ", hmdInfo_SuggestedEyeResolution[1]);
                    ConsoleExtensions.tracei("NUM_MULTI_SAMPLES ", NUM_MULTI_SAMPLES);


                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeFov[0] ", (int)hmdInfo_SuggestedEyeFov[0]);
                    ConsoleExtensions.tracei("hmdInfo_SuggestedEyeFov[1] ", (int)hmdInfo_SuggestedEyeFov[1]);
                    ConsoleExtensions.tracei("DisplayRefreshRate ", (int)hmdInfo.DisplayRefreshRate);


                    // 1012
                    // Create the render Textures.
                    for (int i = 0; i < NUM_BUFFERS; i++)
                        for (int eye = 0; eye < NUM_EYES; eye++)
                        {
                            //ConsoleExtensions.tracei("call ovrRenderTexture_Create i ", i);

                            this.RenderTextures[i, eye].ovrRenderTexture_Create(
                                hmdInfo_SuggestedEyeResolution[0],
                                hmdInfo_SuggestedEyeResolution[1],
                                NUM_MULTI_SAMPLES,

                                i, eye
                            );
                        }

                    this.BufferIndex = 0;

                    // https://www.kickstarter.com/projects/wearality/wearality-sky-limitless-vr
                    // jsc first pass should be a diff, to see if UDP patch can be issued instead of full build.

                    ConsoleExtensions.trace("call CreateProjectionFov");

                    // Setup the projection matrix.
                    this.ProjectionMatrix = __Matrix4x4.CreateProjectionFov(
                        hmdInfo_SuggestedEyeFov[0] * ((float)Math.PI / 180.0f),
                        hmdInfo_SuggestedEyeFov[1] * ((float)Math.PI / 180.0f),
                        0.0f, 0.0f,
                        //nearZ: 1.0f, 
                        //nearZ: 2.0f,
                        //nearZ: 0.5f,

                        // this feels close
                        nearZ: 0.01f,

                        //farZ: 0.1f
                        farZ: 0.0f
                    );

                    ConsoleExtensions.trace("call TanAngleMatrixFromProjection");
                    //this.TanAngleMatrix = VrApi_Helpers.ovrMatrix4f_TanAngleMatrixFromProjection(ref this.ProjectionMatrix);
                    this.TanAngleMatrix = __Matrix4x4.TanAngleMatrixFromProjection(this.ProjectionMatrix);
                    ConsoleExtensions.trace("after call TanAngleMatrixFromProjection");
                }

                ConsoleExtensions.trace("exit ovrRenderer_Create");
            }