using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VisimBox.Resources;
using VisimBox.Renderer;
using VisimBox.Renderer.RenderObjects;
using VisiMath.Geometry;
using VisiMath;


namespace VisimRenderGL
{
    public class GLMeshManager : MeshManager
    {
        public override Mesh Create(IVertexArray vertices, int[] indices, PrimitiveTypes type, Type VertexType)
        {
            IVertexArray verticesfinal;

            if ((VertexType != null) && (vertices[0].GetType() != VertexType))
            {
                VertexFactory.CopyVertexArray(VertexType, vertices, out verticesfinal);
            }
            else verticesfinal = vertices;
            
            GLVertexBuffer vb = new GLVertexBuffer(verticesfinal, false, ResourceUsage.Static);            
            GLIndexBuffer ib = null;
            
            if (indices != null)
                ib = new GLIndexBuffer(indices, false, ResourceUsage.Static);
            
            GLMesh glm = new GLMesh(vb, ib, type);
            return glm;
        }
    }
}
