Exemple #1
0
        /// <summary>
        /// Render the background texture when called.
        /// </summary>
        /// <returns>Is background updated.</returns>
        public bool RenderBackgoundTextureOnDemand()
        {
            // if Background is not initialized we are not rendering
            if (m_videoOverlayRendererHandler == System.IntPtr.Zero)
            {
                return(false);
            }

            // render next frame to texture
            Tango.Common.RetCodes ret =
                (Tango.Common.RetCodes)TangoVideoOverlayAPI.VideoOverlayRenderFrame(m_videoOverlayRendererHandler,
                                                                                    m_backgroundTexture.GetNativeTextureID(),
                                                                                    m_backgroundTexture.width,
                                                                                    m_backgroundTexture.height);

            if (ret != Tango.Common.RetCodes.kCAPISuccess)
            {
                DebugLogger.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR,
                                       "Failed to render video overlay texture with error code:" + ret);
                return(false);
            }
                        #if (UNITY_EDITOR || UNITY_STANDALONE_OSX)
            //issue plugin event to render right after rendering thread finished rendering
            Plugin.IssuePluginEvent(Plugin.PluginEvents.RenderFrameEvent);
                        #elif (UNITY_IPHONE || UNITY_ANDROID)
            GL.InvalidateState();
                        #else
                        #error platform is not supported
                        #endif
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Render the background texture at the end of frame.
        /// </summary>
        /// <returns>Yield return.</returns>
        private IEnumerator RenderBackgoundTexture()
        {
            while (is_runningBackgroundRenderLoop)
            {
                // if Background is not initialized we are not rendering
                if (m_videoOverlayRendererHandler == System.IntPtr.Zero)
                {
                    yield return(null);
                }

                // wait for end of frame to not interfere with rendering thread on mac
                yield return(new WaitForEndOfFrame());

                // render next frame to texture
                Tango.Common.RetCodes ret = (Tango.Common.RetCodes)TangoVideoOverlayAPI.VideoOverlayRenderFrame(m_videoOverlayRendererHandler,
                                                                                                                m_backgroundTexture.GetNativeTextureID(),
                                                                                                                m_backgroundTexture.width,
                                                                                                                m_backgroundTexture.height);

                if (ret != Tango.Common.RetCodes.kCAPISuccess)
                {
                    DebugLogger.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR,
                                           "Failed to render video overlay texture with error code:" + ret);
                }

                                #if (UNITY_EDITOR || UNITY_STANDALONE_OSX)
                // issue plugin event to render right after rendering thread finished rendering
                Plugin.IssuePluginEvent(Plugin.PluginEvents.RenderFrameEvent);
                                #elif (UNITY_IPHONE || UNITY_ANDROID)
                GL.InvalidateState();
                                #else
                                #error platform is not supported
                                #endif
                // yield now to let class stop this coroutine if needed
                yield return(null);
            }
        }