예제 #1
0
        public VertexStream(Span <Vertex> vertices, int[] indices)
        {
            m_stream_mode = VertexStreamMode.Static;

            m_vertex_count = vertices.Length;

            m_vertices = new Vertex[vertices.Length];

            Unsafe.CopyBlockUnaligned(Unsafe.AsPointer(ref m_vertices[0]), Unsafe.AsPointer(ref vertices[0]), (uint)(vertices.Length * Unsafe.SizeOf <Vertex>()));

            m_indices = new ushort[indices.Length];

            Unsafe.CopyBlockUnaligned(Unsafe.AsPointer(ref m_indices[0]), Unsafe.AsPointer(ref indices[0]), (uint)(indices.Length * sizeof(ushort)));

            m_index_count = indices.Length;

            m_static_index_buffer  = IndexBuffer.Create(m_indices);
            m_static_vertex_buffer = VertexBuffer.Create(m_vertices, m_vertex_layout);
        }
예제 #2
0
        public VertexStream(VertexStreamMode stream_mode = VertexStreamMode.Stream)
        {
            if (stream_mode == VertexStreamMode.Static)
            {
                throw new Exception("Invalid VertexStream mode for this constructor: A static VertexStream must be constructed with a pre made vertex array");
            }

            m_stream_mode = stream_mode;

            m_vertices = new Vertex[INITIAL_MAX_BUFFER];
            m_indices  = new ushort[INITIAL_MAX_BUFFER];

            if (stream_mode == VertexStreamMode.Dynamic)
            {
                m_dynamic_vertex_buffer = DynamicVertexBuffer.Create(m_vertices, m_vertex_layout);
                m_dynamic_index_buffer  = DynamicIndexBuffer.Create(m_indices);
            }

            m_vertex_count = 0;
            m_index_count  = 0;
        }