Пример #1
0
        public override void Draw()
        {
            if (Texture == null)
            {
                return;
            }

            // For billboarding
            Shader.SetGlobalProperty("g_InverseViewMatrix", InverseViewMatrix);

            // Taken from DrawNode3D, since we don't need the world transform for particle systems
            GLWrapper.SetBlend(Blending);

            Shader.Bind();

            // Force create a separate batch so we can use instanced rendering
            if (particleInstancedBatch == null)
            {
                particleInstancedBatch = new QuadBatch <TexturedVertex2D>(TexturedVertex2D.Stride * 4, 1);
            }

            var colourInfo = new ColourInfo {
                Colour = Color4.White
            };

            Texture.DrawQuad(new Quad(-0.5f, -0.5f, 1.0f, 1.0f), colourInfo, vertexAction: v => particleInstancedBatch.Add(v));

            // Set GPU buffer data
            Buffer.SetData(BufferData);

            Buffer.Bind();

            // Render instanced
            particleInstancedBatch.DrawInstanced(InstanceCount);

            Shader.Unbind();
        }