Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Buffer.Vertex.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 //
4 // Copyright (c) 2010-2012 SharpDX - Alexandre Mutel
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 
24 using SiliconStudio.Paradox.Games;
25 
26 namespace SiliconStudio.Paradox.Graphics
27 {
28  public partial class Buffer
29  {
30  /// <summary>
31  /// Vertex buffer helper methods.
32  /// </summary>
33  public static class Vertex
34  {
35  /// <summary>
36  /// Creates a new Vertex buffer with <see cref="GraphicsResourceUsage.Default"/> uasge by default.
37  /// </summary>
38  /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
39  /// <param name="size">The size in bytes.</param>
40  /// <param name="usage">The usage.</param>
41  /// <returns>A Vertex buffer</returns>
42  public static Buffer New(GraphicsDevice device, int size, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)
43  {
44  return Buffer.New(device,size, BufferFlags.VertexBuffer, usage);
45  }
46 
47  /// <summary>
48  /// Creates a new Vertex buffer with <see cref="GraphicsResourceUsage.Default"/> uasge by default.
49  /// </summary>
50  /// <typeparam name="T">Type of the Vertex buffer to get the sizeof from</typeparam>
51  /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
52  /// <param name="usage">The usage.</param>
53  /// <returns>A Vertex buffer</returns>
54  public static Buffer<T> New<T>(GraphicsDevice device, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) where T : struct
55  {
56  return Buffer.New<T>(device, 1, BufferFlags.VertexBuffer, usage);
57  }
58 
59  /// <summary>
60  /// Creates a new Vertex buffer with <see cref="GraphicsResourceUsage.Immutable"/> uasge by default.
61  /// </summary>
62  /// <typeparam name="T">Type of the Vertex buffer to get the sizeof from</typeparam>
63  /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
64  /// <param name="value">The value to initialize the Vertex buffer.</param>
65  /// <param name="usage">The usage of this resource.</param>
66  /// <returns>A Vertex buffer</returns>
67  public static Buffer<T> New<T>(GraphicsDevice device, ref T value, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) where T : struct
68  {
69  return Buffer.New(device,ref value, BufferFlags.VertexBuffer, usage);
70  }
71 
72  /// <summary>
73  /// Creates a new Vertex buffer with <see cref="GraphicsResourceUsage.Immutable"/> uasge by default.
74  /// </summary>
75  /// <typeparam name="T">Type of the Vertex buffer to get the sizeof from</typeparam>
76  /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
77  /// <param name="value">The value to initialize the Vertex buffer.</param>
78  /// <param name="usage">The usage of this resource.</param>
79  /// <returns>A Vertex buffer</returns>
80  public static Buffer<T> New<T>(GraphicsDevice device, T[] value, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) where T : struct
81  {
82  return Buffer.New(device,value, BufferFlags.VertexBuffer, usage);
83  }
84 
85  /// <summary>
86  /// Creates a new Vertex buffer with <see cref="GraphicsResourceUsage.Default"/> usage by default.
87  /// </summary>
88  /// <typeparam name="T">Type of the Vertex buffer to get the sizeof from</typeparam>
89  /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
90  /// <param name="vertexBufferCount">Number of vertex in this buffer with the sizeof(T).</param>
91  /// <param name="usage">The usage.</param>
92  /// <returns>A Vertex buffer</returns>
93  public static Buffer<T> New<T>(GraphicsDevice device, int vertexBufferCount, GraphicsResourceUsage usage = GraphicsResourceUsage.Default) where T : struct
94  {
95  return Buffer.New<T>(device, vertexBufferCount, BufferFlags.VertexBuffer, usage);
96  }
97 
98  /// <summary>
99  /// Creates a new Vertex buffer with <see cref="GraphicsResourceUsage.Immutable"/> uasge by default.
100  /// </summary>
101  /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
102  /// <param name="value">The value to initialize the Vertex buffer.</param>
103  /// <param name="usage">The usage of this resource.</param>
104  /// <returns>A Vertex buffer</returns>
105  public static Buffer New(GraphicsDevice device, DataPointer value, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable)
106  {
107  return Buffer.New(device,value, 0, BufferFlags.VertexBuffer, usage);
108  }
109  }
110  }
111 }
GraphicsResourceUsage
Identifies expected resource use during rendering. The usage directly reflects whether a resource is ...
static Buffer New(GraphicsDevice device, DataPointer value, GraphicsResourceUsage usage=GraphicsResourceUsage.Immutable)
Creates a new Vertex buffer with GraphicsResourceUsage.Immutable uasge by default.
static Buffer New(GraphicsDevice device, int size, GraphicsResourceUsage usage=GraphicsResourceUsage.Default)
Creates a new Vertex buffer with GraphicsResourceUsage.Default uasge by default.
All-in-One Buffer class linked SharpDX.Direct3D11.Buffer.
SiliconStudio.Paradox.Graphics.Buffer Buffer
Definition: BasicEffect.cs:15
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
A buffer with typed information.
Definition: Buffer.cs:607
Vertex buffer helper methods.
_In_ size_t _In_ size_t size
Definition: DirectXTexP.h:175