예제 #1
0
    public void DestroySyphonClient()
    {
//		UnityEngine.Debug.Log("destroying syphon client" + syphonClientPointer + " " + BoundAppName + " " + boundName);
        if (attachedTexture != null)
        {
            RenderTexture.active = null;
            attachedTexture.Release();
            //RenderTexture.active = null;
            UnityEngine.Object.DestroyImmediate(attachedTexture);
            attachedTexture = null;
        }

        if (syphonClientPointer != IntPtr.Zero && initialized)
        {
            Syphon.QueueToKillTexture(syphonClientPointer);
            GL.IssuePluginEvent(Syphon.SyphonGetRenderEventFunc(), (int)syphonClientPointer);
            syphonClientPointer = IntPtr.Zero;
            initialized         = false;

            //let anySyphonClientTextures who's registered for updates know that we've retired.
            if (RetireClient != null)
            {
                RetireClient(this);
            }
        }
        else
        {
//			Debug.Log("syphon client: " + boundAppName + " " + boundName + " was not initialized, so not cleaning up the plugin on exit.");
        }
    }
예제 #2
0
 public void OnDestroy()
 {
     if (syphonServerTextureInstance != IntPtr.Zero)
     {
         Syphon.QueueToKillTexture(syphonServerTextureInstance);
         GL.IssuePluginEvent(Syphon.SyphonGetRenderEventFunc(), (int)syphonServerTextureInstance);
     }
     syphonServerTextureInstance     = IntPtr.Zero;
     syphonServerTextureValuesCached = false;
     cachedTexID = IntPtr.Zero;
 }
예제 #3
0
    public void OnRenderObject()
    {
        if (!testCameraExists())
        {
            return;
        }

        if (renderWidth != _renderWidth || renderHeight != _renderHeight)
        {
            if (renderWidth <= 4)
            {
                renderWidth = 4;
            }
            if (renderHeight <= 4)
            {
                renderHeight = 4;
            }

            if (renderWidth > 8192)
            {
                renderWidth = 8192;
            }

            if (renderHeight > 8192)
            {
                renderHeight = 8192;
            }

            _renderWidth  = renderWidth;
            _renderHeight = renderHeight;
            createOrResizeRenderTexture();
        }

        // Update texture data on Syphon server
        if (!syphonServerTextureValuesCached || cachedTexID != cameraInstance.targetTexture.GetNativeTexturePtr() ||
            cameraInstance.targetTexture.width != cachedWidth || cameraInstance.targetTexture.height != cachedHeight)
        {
            cacheTextureValues(cameraInstance.targetTexture);
        }

        Syphon.SafeMaterial.SetPass(0);
        // Publish texture to Syphon Server
        if (syphonServerTextureInstance != IntPtr.Zero && cachedTexID != IntPtr.Zero)
        {
            GL.IssuePluginEvent(Syphon.SyphonGetRenderEventFunc(), (int)syphonServerTextureInstance);
        }


        if (_renderMe != renderMe)
        {
            TestIfShouldRender();
        }
    }
예제 #4
0
    //////////////////////////////////////////////////////////////
    //
    // GAME LOOP CALLBACKS -- In order they are called
    //

    //
    // OnRenderImage() is called after all rendering is complete to render image, but the GUI is not rendered yet
    // http://docs.unity3d.com/Documentation/ScriptReference/Camera.OnRenderImage.html
    public virtual void OnRenderImage(RenderTexture src, RenderTexture dst)
    {
        // Update texture data on Syphon server
        if (!syphonServerTextureValuesCached || cachedTexID != src.GetNativeTexturePtr() || src.width != cachedWidth || src.height != cachedHeight)
        {
            cacheTextureValues(src);
        }

        // Copy src to dst
        Syphon.SafeMaterial.SetPass(0);
        Graphics.Blit(src, dst);
        // Publish texture to Syphon Server
        if (syphonServerTextureInstance != IntPtr.Zero && cachedTexID != IntPtr.Zero)
        {
            GL.IssuePluginEvent(Syphon.SyphonGetRenderEventFunc(), (int)syphonServerTextureInstance);
        }
    }
예제 #5
0
    public void Render()
    {
        if (attachedTexture.GetNativeTexturePtr() != cachedTexID)
        {
            cachedTexID = attachedTexture.GetNativeTexturePtr();
            Syphon.CacheClientTextureValues(attachedTexture.GetNativeTexturePtr(), attachedTexture.width, attachedTexture.height, syphonClientPointer);
            initialized = true;
        }

        if (syphonClientPointer != IntPtr.Zero && initialized)
        {
            //you need to render once per frame for each texture.
            Syphon.SafeMaterial.SetPass(0);
            RenderTexture.active = attachedTexture;
//			UnityEngine.Debug.Log ("ISSUING EVENT?" + (int)syphonClientPointer) ;
            GL.IssuePluginEvent(Syphon.SyphonGetRenderEventFunc(), (int)syphonClientPointer);
            RenderTexture.active = null;
        }
    }