예제 #1
0
 public void Clear()
 {
     TimeSource.Clear();
     Shaders.Clear();
     Textures.Clear();
     uniforms.Clear();
     ShaderKeyframes.Clear();
 }
예제 #2
0
        public void InitByMgr(BaseSurfaceMgr mgr, string matName = "", bool isInstance = true)
        {
            IsInstance = isInstance;
            SurfaceMgr = mgr;
            SourceMats.Clear();
            SourceMatsArray.Clear();
            Shaders.Clear();

            var renders = GetRenderers();

            if (renders != null)
            {
                for (int i = 0; i < renders.Length; ++i)
                {
                    GetMaterial(renders[i], out Material material);
                    SourceMats.Add(renders[i], material);
                }

                for (int i = 0; i < renders.Length; ++i)
                {
                    GetMaterials(renders[i], out Material[] materials);
                    SourceMatsArray.Add(renders[i], materials);
                    if (materials != null)
                    {
                        foreach (var item in materials)
                        {
                            if (!Shaders.Contains(item.shader))
                            {
                                Shaders.Add(item.shader);
                            }
                        }
                    }
                }
                //获得材质
                string tempMatName = matName.IsInv() ? GetDefaultMatName() : matName;
                if (UsedMaterials.Count == 0 && !tempMatName.IsInv())
                {
                    foreach (var key in Shaders)
                    {
                        var mat = GRMgr.Material.Spawn(tempMatName);
                        if (DefaultUsedMaterial == null)
                        {
                            DefaultUsedMaterial = mat;
                        }
                        UsedMaterials.Add(key, mat);
                    }
                }
            }
            OnInit();
        }
예제 #3
0
        /// <summary>
        /// For derived class implementers.
        /// <para>This method is called with argument true when class user calls Dispose(), while with argument false when
        /// the Garbage Collector invokes the finalizer, or Finalize() method.</para>
        /// <para>You must reclaim all used unmanaged resources in both cases, and can use this chance to call Dispose on disposable fields if the argument is true.</para>
        /// <para>Also, you must call the base virtual method within your overriding method.</para>
        /// </summary>
        /// <param name="disposing">true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer.</param>
        protected virtual void Dispose(bool disposing)
        {
            // Free unmanaged resources...

            // Free managed resources...but only if called from Dispose
            // (If called from Finalize then the objects might not exist anymore)
            if (disposing)
            {
                if (Model != null)
                {
                    Model.Dispose();
                    Model = null;
                }

                Frame = System.Drawing.RectangleF.Empty;

                if (Viewport != null)
                {
                    Viewport.Dispose();
                    Viewport = null;
                }

                CurrentMaterial = null;

                if (ActiveShader != null)
                {
                    GL.DeleteProgram(ActiveShader.Handle);
                    ActiveShader.Disable();
                    m_activeShader = null;
                }

                if (Shaders != null)
                {
                    Shaders.Clear();
                    Shaders = null;
                }
            }
        }