Exemplo n.º 1
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Initialisation
        //---------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of a particle system.
        /// </summary>
        /// <param name="size">The max number of particles.</param>
        public ParticleSystem2d(int size) : base( )
        {
            textures  = new Textures();
            particles = new Purple.Collections.FixedBag(size);

            // Create a new format
            VertexFormat format = new VertexFormat(
                new Type[] { typeof(PositionStream2), typeof(ColorStream), typeof(TextureStream) });

            // create VertexUnit and IndexStream
            vertexUnit  = new VertexUnit(format, size * 4);
            indexStream = IndexStream.FromQuads(size);

            // load shaders from the resource files
            using (System.IO.Stream fxStream = Purple.IO.ResourceFileSystem.Instance.Open("Purple/Graphics/Particles/Particle2d.fx")) {
                Effect = EffectCompiler.Instance.Compile(fxStream);
            }
        }