コード例 #1
0
        protected bool Init()
        {
            _shaderDeinterlace      = Shader.Find("AVProDeckLink/Deinterlace");
            _shader_ARGB_8bpp_444   = Shader.Find("AVProDeckLink/CompositeARGB");
            _shader_BGRA_8bpp_444   = Shader.Find("AVProDeckLink/CompositeBGRA");
            _shader_RGB_10bpp_444   = Shader.Find("AVProDeckLink/CompositeRGB10bpp");
            _shader_YCbCr_10bpp_422 = Shader.Find("AVProDeckLink/CompositeV210");
            _shader_YCbCr_8bpp_422  = Shader.Find("AVProDeckLink/CompositeUYVY");
#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 || UNITY_5_4_OR_NEWER
            _renderEventFunctor = DeckLinkPlugin.GetRenderEventFunc();
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
            try
            {
                bool unitySupportsExternalTextures = false;
#if AVPRODECKLINK_UNITYFEATURE_EXTERNALTEXTURES
                unitySupportsExternalTextures = true;
#endif
                DeckLinkPlugin.SetUnityFeatures(unitySupportsExternalTextures);
            }
            catch (System.DllNotFoundException e)
            {
                Debug.LogError("[AVProDeckLink] Unity couldn't find the DLL, did you move the 'Plugins' folder to the root of your project?");
                throw e;
            }

            _isOpenGL = SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL");

            bool swapRedBlue = false;
            if (SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11"))
            {
                swapRedBlue = true;
            }

            if (swapRedBlue)
            {
                Shader.DisableKeyword("SWAP_RED_BLUE_OFF");
                Shader.EnableKeyword("SWAP_RED_BLUE_ON");
            }
            else
            {
                Shader.DisableKeyword("SWAP_RED_BLUE_ON");
                Shader.EnableKeyword("SWAP_RED_BLUE_OFF");
            }

            SetChromaInterpolation(ChromaLerp.Lerp);

            EnumDevices();

            //_frameTime = GetFrameInterval(Screen.currentResolution.refreshRate);
            //Debug.Log("[AVProDeckLink] Using frame interval " + _frameTime + " for rate of " + Screen.currentResolution.refreshRate.ToString("F3"));

            _isInitialised = true;
            StartCoroutine("FinalRenderCapture");

            return(_isInitialised);
#else
            return(false);
#endif
        }