/// <summary> /// Unity update function, we update our texture from here. /// </summary> private void Update() { m_screenUpdateTime = VideoOverlayProvider.RenderLatestFrame(TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR); // Rendering the latest frame changes a bunch of OpenGL state. Ensure Unity knows the current OpenGL state. GL.InvalidateState(); }
/// <summary> /// Render the background texture at the end of frame. /// </summary> /// <returns>Yield return.</returns> private IEnumerator RenderBackgoundTexture() { // Wait until init background finished. while (!is_initBackgroundFinished) { yield return(new WaitForSeconds(0.1f)); } while (true) { // 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()); VideoOverlayProvider.RenderLatestFrame( m_backgroundTexture.GetNativeTextureID(), m_backgroundTexture.width, m_backgroundTexture.height, ref timestamp); #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); } }
/// <summary> /// Update mesh texture. /// </summary> private void _UpdateTexture() { VideoOverlayProvider.RenderLatestFrame( m_texture.GetNativeTextureID(), m_texture.width, m_texture.height, ref m_textureTimestamp); GL.InvalidateState(); this.renderer.material.mainTexture = m_texture; }
/// <summary> /// Perform any Camera.OnPreRender() logic /// here. /// </summary> public sealed override void OnPreRender() { VideoOverlayProvider.RenderLatestFrame(m_texture.GetNativeTextureID(), TEX_WIDTH, TEX_HEIGHT, ref m_timestamp); GL.InvalidateState(); }
/// <summary> /// This will be called when a new frame is available from the camera. /// /// The first scan-line of the color image is reserved for metadata instead of image pixels. /// </summary> /// <param name="cameraId">Camera identifier.</param> public void OnExperimentalTangoImageAvailable(TangoEnums.TangoCameraId cameraId) { if (cameraId == TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR) { m_screenUpdateTime = VideoOverlayProvider.RenderLatestFrame(TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR); // Rendering the latest frame changes a bunch of OpenGL state. Ensure Unity knows the current OpenGL state. GL.InvalidateState(); } }
/// <summary> /// Update is called once per frame, /// pass both color texture and depth texture into shader. /// </summary> private void Update() { renderer.material.SetTexture("_ColorTex", m_texture); renderer.material.SetTexture("_DepthTex", m_depthTexture.GetDepthTexture(m_isUsingFilter, m_depthTexMaxLength, m_filterLevel)); renderer.material.SetFloat("_BlendValue", m_blendValue); VideoOverlayProvider.RenderLatestFrame( m_texture.GetNativeTextureID(), m_texture.width, m_texture.height, ref m_timestamp); GL.InvalidateState(); }
/// <summary> /// Update is called once per frame. /// Pass the color texture and depth texture into the post process shader. /// </summary> private void Update() { VideoOverlayProvider.RenderLatestFrame(m_texture.GetNativeTextureID(), TEX_WIDTH, TEX_HEIGHT, ref m_timestamp); m_depthOcclusionMaterial.SetTexture("_ColorTex", m_texture); m_depthOcclusionMaterial.SetTexture("_DepthTex", m_depthTexture.GetDepthTexture(m_isUsingFilter, Camera.main.farClipPlane, 1)); GL.InvalidateState(); }
/// <summary> /// Unity update function, we update our texture from here. /// </summary> private void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (m_tangoApplication != null) { m_tangoApplication.Shutdown(); } // This is a temporary fix for a lifecycle issue where calling // Application.Quit() here, and restarting the application immediately, // results in a hard crash. AndroidHelper.AndroidQuit(); } double timestamp = VideoOverlayProvider.RenderLatestFrame(TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR); _UpdateTransformation(timestamp); GL.InvalidateState(); }
/// <summary> /// Render the background texture when called. /// </summary> /// <returns>Is background updated.</returns> public bool RenderBackgoundTextureOnDemand() { if (!is_initBackgroundFinished) { return(false); } VideoOverlayProvider.RenderLatestFrame( m_backgroundTexture.GetNativeTextureID(), m_backgroundTexture.width, m_backgroundTexture.height, ref timestamp); #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); }
/// <summary> /// Perform any Camera.OnPreRender() logic /// here. /// </summary> public sealed override void OnPreRender() { VideoOverlayProvider.RenderLatestFrame(TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR); GL.InvalidateState(); }
void Update() { double timestamp = VideoOverlayProvider.RenderLatestFrame(TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR); GL.InvalidateState(); }