Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
BufferData.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using SiliconStudio.Core;
4 
5 namespace SiliconStudio.Paradox.Graphics.Data
6 {
7  /// <summary>
8  /// Content of a GPU buffer (vertex buffer, index buffer, etc...).
9  /// </summary>
10  public partial class BufferData
11  {
12  public BufferData()
13  {
14  }
15 
16  public BufferData(BufferFlags bufferFlags, byte[] content)
17  {
18  Content = content;
19  BufferFlags = bufferFlags;
20  }
21 
22  /// <summary>
23  /// Gets or sets the buffer content.
24  /// </summary>
25  /// <value>
26  /// The buffer content.
27  /// </value>
28  public byte[] Content { get; set; }
29 
30  /// <summary>
31  /// Buffer flags describing the type of buffer.
32  /// </summary>
33  public BufferFlags BufferFlags { get; set; }
34 
35  /// <summary>
36  /// Usage of this buffer.
37  /// </summary>
38  public GraphicsResourceUsage Usage { get; set; }
39 
40  /// <summary>
41  /// The size of the structure (in bytes) when it represents a structured/typed buffer.
42  /// </summary>
43  public int StructureByteStride { get; set; }
44 
45  /// <summary>
46  /// Creates a new instance of <see cref="BufferData"/> from a typed buffer.
47  /// </summary>
48  /// <typeparam name="T">Type of the element to store in the buffer data.</typeparam>
49  /// <param name="bufferFlags">The flags indicating the type of buffer</param>
50  /// <param name="content">An array of data</param>
51  /// <returns>A buffer data.</returns>
52  public static BufferData New<T>(BufferFlags bufferFlags, T[] content) where T : struct
53  {
54  var sizeOf = Utilities.SizeOf(content);
55  var buffer = new byte[sizeOf];
56  Utilities.Write(buffer, content, 0, content.Length);
57  return new BufferData(bufferFlags, buffer);
58  }
59  }
60 }
GraphicsResourceUsage
Identifies expected resource use during rendering. The usage directly reflects whether a resource is ...
BufferData(BufferFlags bufferFlags, byte[] content)
Definition: BufferData.cs:16
Only valid for a property / field that has a class or struct type. When restored, instead of recreati...
Content of a GPU buffer (vertex buffer, index buffer, etc...).
Definition: BufferData.cs:10