using OpenTK;
using OpenTK.Graphics.OpenGL;

namespace Blackjack
{
    class Card
    {
        public float X { get; set; }
        public float Y { get; set; }
        public float Angle { get; set; }
        public float Size { get; set; }

        private int _textureID;
        private int _uModelMatrixLoc;

        public Card(int program, string textureName)
        {
            Textures.LoadTexture(textureName, out _textureID);
            Size = 1f;
            _uModelMatrixLoc = GL.GetUniformLocation(program, "uModelMatrix");
        }

        public void Draw()
        {
            Textures.ActiveTexture(_textureID);

            // Define the model matrix
            Matrix4 modelMatrix =
                Matrix4.CreateScale(Size, Size, 1f) *
                Matrix4.CreateRotationZ(Angle * MathHelper.Pi / 180f) *
                Matrix4.CreateTranslation(X, Y, 0f);

            GL.UniformMatrix4(_uModelMatrixLoc, false, ref modelMatrix);

            GL.DrawArrays(PrimitiveType.TriangleStrip, 0, 4);
        }
    }
}
