Beispiel #1
0
 public override void AllocateVertices <T>(T[] vertices, ushort[] indices, out int startIndex, out int baseVertex, out VertexBuffer vbo, out IndexResourceHandle index)
 {
     throw new InvalidOperationException();
 }
Beispiel #2
0
 public abstract void AllocateVertices <T>(T[] vertices, ushort[] indices, out int startIndex, out int baseVertex, out VertexBuffer vbo, out IndexResourceHandle index) where T : struct;
 public bool Allocate(T[] vertices, ushort[] indices, out int startIndex, out int baseVertex, out IndexResourceHandle index)
 {
     index      = null;
     startIndex = baseVertex = -1;
     if (CountVertex + vertices.Length > TotalVertex)
     {
         return(false);
     }
     if (CountIndex + indices.Length > TotalIndex)
     {
         return(false);
     }
     index      = Index;
     startIndex = CountIndex;
     baseVertex = CountVertex;
     Buffer.SetData(vertices, vertices.Length, CountVertex);
     Elements.SetData(indices, indices.Length, CountIndex);
     CountVertex += vertices.Length;
     CountIndex  += indices.Length;
     return(true);
 }
Beispiel #4
0
 public override void AllocateVertices <T>(T[] vertices, ushort[] indices, out int startIndex, out int baseVertex, out VertexBuffer vbo, out IndexResourceHandle index)
 {
     vbo        = null;
     index      = null;
     startIndex = baseVertex = -1;
     if (typeof(T) == typeof(VertexPosition))
     {
         posResource.Allocate(As <VertexPosition>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else if (typeof(T) == typeof(VertexPositionColor))
     {
         posColorResource.Allocate(As <VertexPositionColor>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else if (typeof(T) == typeof(VertexPositionNormal))
     {
         posNormalResource.Allocate(As <VertexPositionNormal>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else if (typeof(T) == typeof(VertexPositionColorTexture))
     {
         posColorTextureResource.Allocate(As <VertexPositionColorTexture>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else if (typeof(T) == typeof(VertexPositionNormalTexture))
     {
         posNormalTextureResource.Allocate(As <VertexPositionNormalTexture>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else if (typeof(T) == typeof(VertexPositionNormalDiffuseTexture))
     {
         posNormalColorTextureResource.Allocate(As <VertexPositionNormalDiffuseTexture>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else if (typeof(T) == typeof(VertexPositionNormalTextureTwo))
     {
         posNormalTextureTwoResource.Allocate(As <VertexPositionNormalTextureTwo>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else if (typeof(T) == typeof(VertexPositionNormalDiffuseTextureTwo))
     {
         posNormalDiffuseTextureTwoResource.Allocate(As <VertexPositionNormalDiffuseTextureTwo>(vertices), indices, out vbo, out startIndex, out baseVertex, out index);
     }
     else
     {
         throw new NotSupportedException("Allocate " + typeof(T).Name);
     }
 }
 public void Allocate(T[] vertices, ushort[] indices, out VertexBuffer vbo, out int startIndex, out int baseVertex, out IndexResourceHandle index)
 {
     foreach (var buf in buffers)
     {
         if (buf.Allocate(vertices, indices, out startIndex, out baseVertex, out index))
         {
             vbo = buf.Buffer;
             return;
         }
     }
     FLLog.Debug("Vertices", "Allocating 16MiB for " + typeof(T).Name);
     buffers.Add(new VertexResourceBuffer <T>());
     buffers[buffers.Count - 1].Allocate(vertices, indices, out startIndex, out baseVertex, out index);
     vbo = buffers[buffers.Count - 1].Buffer;
 }