Aiv.Fast2D.Mesh.Draw C# (CSharp) Метод

Draw() публичный Метод

public Draw ( ShaderSetupHook hook = null ) : void
hook ShaderSetupHook
Результат void
        public void Draw(ShaderSetupHook hook = null)
        {
            if (this.v == null)
                return;
            // upload fake uvs (if required) to avoid crashes
            if (this.uv == null)
            {
                this.uv = new float[this.v.Length];
                this.UpdateUV();
            }
            // upload fake vcs (if required) to avoid crashes
            if (this.vc == null && this.hasVertexColors)
            {
                this.vc = new float[this.v.Length * 2];
                this.UpdateVertexColor();
            }
            this.Bind();
            // clear current texture
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            if (this.requireUseTexture)
                this.shader.SetUniform("use_texture", -1f);

            this.shader.Use();
            if (hook != null)
            {
                hook(this);
            }
            else if (this.shaderSetupHook != null)
            {
                this.shaderSetupHook(this);
            }

            this.ApplyMatrix();
            if (instances <= 1)
            {
            #if !__MOBILE__
                GL.DrawArrays(PrimitiveType.Triangles, 0, this.v.Length / 2);
            #else
                GL.DrawArrays(BeginMode.Triangles, 0, this.v.Length / 2);
            #endif
            }
            else
            {
                GL.DrawArraysInstanced(PrimitiveType.Triangles, 0, this.v.Length / 2, instances);
            }
        }

Usage Example

Пример #1
0
        public void Apply(RenderTexture inRenderTexture = null)
        {
            if (inRenderTexture == null)
            {
                inRenderTexture = renderTexture;
            }

            if (textures != null)
            {
                int texture_unit = 2;
                foreach (string uniform in textures.Keys)
                {
                    Graphics.BindTextureToUnit(textures[uniform].Id, texture_unit);
                    screenMesh.shader.SetUniform(uniform, texture_unit);
                    texture_unit++;
                }
            }

            if (!this.useDepth)
            {
                screenMesh.DrawRenderTexture(inRenderTexture);
            }
            else
            {
                screenMesh.Draw((m) =>
                {
                    Graphics.BindTextureToUnit(inRenderTexture.TextureId, 0);
                    Graphics.BindTextureToUnit(inRenderTexture.DepthTextureId, 1);
                    m.shader.SetUniform("tex", 0);
                    m.shader.SetUniform("depth_tex", 1);
                });
            }
        }
All Usage Examples Of Aiv.Fast2D.Mesh::Draw