Example #1
0
        protected override void Dispose(bool disposing)
        {
            if (m_Renderer != null)
            {
                m_Renderer.Dispose();
                m_Renderer = null;
            }

            base.Dispose(disposing);
        }
Example #2
0
        protected override void UpdateIfNeed(Int64 currentTime)
        {
            if (!IsImageAlive)
            {
                KillTexture();
                return;
            }


            Alt.Sketch.RenderImage renderImage = ImageSourceAsRenderImage;
            if (renderImage == null)
            {
                return;
            }

            CheckTexture();


            if (ModificationTime != renderImage.ModificationTime)
            {
                //UpdateTexture();

                RenderTexture renderTexture = m_Texture as RenderTexture;
                if (renderTexture != null)
                {
                    if (m_Renderer == null)
                    {
                        m_Renderer = new Unity_Renderer(m_RenderManager, renderTexture);
                        m_Renderer.DefaultSmoothingMode = Alt.Sketch.SmoothingMode.None;
                    }

                    RenderTexture oldRenderTexture = RenderTexture.active;
                    RenderTexture.active = renderTexture;
                    try
                    {
                        m_Renderer.BeginRender(null, null, renderTexture.width, renderTexture.height);
                        GL.Clear(true, true, new Color(0.5f, 0.5f, 0.5f, 0));                        //Color.clear);
                        {
                            renderImage.Render(Alt.Sketch.Graphics.FromRenderer(m_Renderer));
                        }
                        m_Renderer.EndRender();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                    finally
                    {
                        RenderTexture.active = oldRenderTexture;
                    }
                }

                ModificationTime = renderImage.ModificationTime;
            }
        }