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);
}
}