Beispiel #1
0
        public static DynamicVertexBuffer Create(Vertex[] vertices, VertexLayout layout, BufferFlags flags = BufferFlags.None)
        {
            var vertex_buffer = new DynamicVertexBuffer
            {
                Handle = GraphicsContext.CreateDynamicVertexBuffer(vertices, layout, flags)
            };

            GraphicsContext.RegisterAllocatedResource(vertex_buffer);

            return(vertex_buffer);
        }
Beispiel #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;
        }