コード例 #1
0
ファイル: RenderContext.cs プロジェクト: HippoAR/DemoPowerUI
        public RenderContext(SVGSVGElement drawing)
        {
            Drawing = drawing;

            // Create the tex too:
            Filter = new Loonim.SurfaceTexture();

            // Create the draw surface:
            DrawInfo = new Loonim.DrawInfo();
        }
コード例 #2
0
        /// <summary>Connects a filter to the camera's output.
        /// Fires an imagechange event too as this updates Texture to the filtered version.</summary>
        private void ConnectFilter()
        {
            if (Filter_ != null)
            {
                if (FilterDrawInfo == null)
                {
                    FilterDrawInfo = new Loonim.DrawInfo();
                }

                // Update draw info:
                FilterDrawInfo.SetSize(pixelWidth, pixelHeight);

                // Update source:
                Filter_.Set("source0", SourceCamera.targetTexture);

                // Reallocate the filter:
                Filter_.PreAllocate(FilterDrawInfo);

                // Grab the main output (always a RT):
                Texture = Filter_.Texture as RenderTexture;

                if (Texture == null)
                {
                    // This isn't a valid filter!
                    // It either had no nodes or e.g. e.g. a solid colour.
                    Debug.Log("Invalid filter was set to a FlatWorldUI - removed it.");
                    Filter_ = null;
                }
            }

            if (Filter_ == null)
            {
                // Clear draw info:
                FilterDrawInfo = null;

                // Revert to the camera's output:
                Texture = SourceCamera.targetTexture;
            }

            // Fire an imagechange event into the window:
            Dom.Event e = new Dom.Event("imagechange");
            e.SetTrusted(false);
            document.window.dispatchEvent(e);
        }
コード例 #3
0
        /// <summary>Sets a filter to apply. This is what rasterising elements is all for!</summary>
        public void SetFilter(Loonim.SurfaceTexture tex)
        {
            Filter = tex;

            if (tex == null)
            {
                if (FilterDrawInfo != null)
                {
                    // Tidy it up:
                    tex.Clear();

                    FilterDrawInfo = null;
                }

                if (Renderer != null)
                {
                    // Update it now:
                    Output = Renderer.Texture;

                    if (Material != null)
                    {
                        // Hook up the output:
                        Material.SetTexture("_MainTex", Output);
                    }
                }
            }
            else
            {
                // Create the draw info (for GPU mode):
                FilterDrawInfo = new Loonim.DrawInfo();

                if (Renderer != null)
                {
                    // Update it now:
                    Filter.Set("source0", Renderer.Texture);

                    // Note that the next draw will update Output for us.
                }
            }
        }