Class BufferUtils
- Namespace
- OmegaEngine.Graphics
- Assembly
- OmegaEngine.dll
Helper methods for creating, reading from and writing to SlimDX.Direct3D9.VertexBuffers, SlimDX.Direct3D9.IndexBuffers and attribute buffers.
public static class BufferUtils
- Inheritance
-
objectBufferUtils
Methods
CreateIndexBuffer(Device, short[])
Creates an SlimDX.Direct3D9.IndexBuffer and fills it with data.
public static IndexBuffer CreateIndexBuffer(this Device device, short[] data)
Parameters
deviceDeviceThe device to create the buffer on.
datashort[]The values to fill the buffer with.
Returns
- IndexBuffer
The newly created and filled SlimDX.Direct3D9.IndexBuffer.
CreateIndexBuffer(Device, int[])
Creates an SlimDX.Direct3D9.IndexBuffer and fills it with data.
public static IndexBuffer CreateIndexBuffer(this Device device, int[] data)
Parameters
deviceDeviceThe device to create the buffer on.
dataint[]The values to fill the buffer with.
Returns
- IndexBuffer
The newly created and filled SlimDX.Direct3D9.IndexBuffer.
CreateVertexBuffer<T>(Device, T[], VertexFormat)
Creates a SlimDX.Direct3D9.VertexBuffer and fills it with data.
public static VertexBuffer CreateVertexBuffer<T>(this Device device, T[] data, VertexFormat format) where T : struct
Parameters
deviceDeviceThe device to create the buffer on.
dataT[]The vertexes to fill the buffer with.
formatVertexFormatThe fixed-function vertex format.
Returns
- VertexBuffer
The newly created and filled SlimDX.Direct3D9.VertexBuffer.
Type Parameters
TThe vertex format used in the buffer.
GetPoints(Mesh)
Gets all points contained within a SlimDX.Direct3D9.Mesh.
public static Vector3[] GetPoints(this Mesh mesh)
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh to get points from.
Returns
- Vector3[]
An array of points defined by the object.
GetPoints(Mesh, int)
Gets all points contained within a specific subset of a SlimDX.Direct3D9.Mesh.
public static Vector3[] GetPoints(this Mesh mesh, int subset)
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh to get points from.
subsetintThe subset to get points for.
Returns
- Vector3[]
An array of points defined by the subset. Returns an empty array if the subset has no faces.
GetPoints(VertexBuffer, int)
Gets all points contained within a SlimDX.Direct3D9.VertexBuffer.
public static Vector3[] GetPoints(this VertexBuffer buffer, int vertexCount)
Parameters
bufferVertexBufferThe SlimDX.Direct3D9.VertexBuffer to get points from.
vertexCountintThe total number of vertex contained within
buffer.
Returns
- Vector3[]
An array of points defined by the object.
Read16Bit(IndexBuffer)
Copies the content of an SlimDX.Direct3D9.IndexBuffer to an array of 16-bit values.
public static short[] Read16Bit(this IndexBuffer buffer)
Parameters
bufferIndexBufferThe buffer to read from.
Returns
- short[]
Remarks
Warning! No check is performed to ensure the buffer actually uses 16-bit values.
Read32Bit(IndexBuffer)
Copies the content of an SlimDX.Direct3D9.IndexBuffer to an array of 32-bit values.
public static int[] Read32Bit(this IndexBuffer buffer)
Parameters
bufferIndexBufferThe buffer to read from.
Returns
- int[]
Remarks
Warning! No check is performed to ensure the buffer actually uses 32-bit values.
ReadAttributeBuffer(Mesh)
Copies the content of the attribute buffer of a SlimDX.Direct3D9.Mesh to an array of 32-bit values.
public static int[] ReadAttributeBuffer(this Mesh mesh)
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh containing the buffer to read from.
Returns
- int[]
ReadIndexBuffer(Mesh)
Copies the content of the SlimDX.Direct3D9.IndexBuffer of a SlimDX.Direct3D9.Mesh to an array of 32-bit values (16-bit values are automatically converted).
public static int[] ReadIndexBuffer(this Mesh mesh)
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh containing the buffer to read from.
Returns
- int[]
ReadVertexBuffer<T>(Mesh)
Copies the content of the SlimDX.Direct3D9.VertexBuffer of a SlimDX.Direct3D9.Mesh to an array of structs.
public static T[] ReadVertexBuffer<T>(this Mesh mesh) where T : struct
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh containing the buffer to read from.
Returns
- T[]
The content of the buffer in
mesh.
Type Parameters
TThe vertex format used in the buffer.
Read<T>(VertexBuffer)
Copies the content of a SlimDX.Direct3D9.VertexBuffer to an array of structs.
public static T[] Read<T>(this VertexBuffer buffer) where T : struct
Parameters
bufferVertexBufferThe buffer to read from.
Returns
- T[]
The content of the
buffer.
Type Parameters
TThe vertex format used in the buffer.
ToDefaultPool(Mesh, bool)
Creates a copy of a SlimDX.Direct3D9.Mesh in SlimDX.Direct3D9.Pool.Default, ready for rendering.
public static Mesh ToDefaultPool(this Mesh mesh, bool writeOnly = true)
Parameters
meshMeshThe finished system memory mesh to publish.
writeOnlyboolAdd SlimDX.Direct3D9.MeshFlags.WriteOnly for the fastest possible rendering. Prevents any CPU read-back.
Returns
- Mesh
ToDefaultPool(MeshFlags)
Strips pool and write-only flags from mesh creation options, so a clone ends up in the lockable SlimDX.Direct3D9.Pool.Default pool.
public static MeshFlags ToDefaultPool(this MeshFlags options)
Parameters
optionsMeshFlags
Returns
- MeshFlags
Remarks
All other flags, most importantly SlimDX.Direct3D9.MeshFlags.Use32Bit, are preserved.
ToSystemMemory(Mesh)
Creates a copy of a SlimDX.Direct3D9.Mesh in system memory, where the CPU can read and modify it at full speed.
public static Mesh ToSystemMemory(this Mesh mesh)
Parameters
meshMesh
Returns
- Mesh
ToSystemMemory(MeshFlags)
Replaces the pool flags in mesh creation options with SlimDX.Direct3D9.Pool.SystemMemory.
public static MeshFlags ToSystemMemory(this MeshFlags options)
Parameters
optionsMeshFlags
Returns
- MeshFlags
Write(IndexBuffer, short[])
Fills an SlimDX.Direct3D9.IndexBuffer with 16-bit values.
public static void Write(this IndexBuffer buffer, short[] data)
Parameters
bufferIndexBufferThe buffer to write to.
datashort[]The values to fill the buffer with.
Remarks
Warning! No check is performed to ensure the buffer actually uses 16-bit values.
Write(IndexBuffer, int[])
Fills an SlimDX.Direct3D9.IndexBuffer with 32-bit values.
public static void Write(this IndexBuffer buffer, int[] data)
Parameters
bufferIndexBufferThe buffer to write to.
dataint[]The values to fill the buffer with.
Remarks
Warning! No check is performed to ensure the buffer actually uses 32-bit values.
WriteAttributeBuffer(Mesh, int[])
Fills the attribute buffer of a SlimDX.Direct3D9.Mesh with 32-bit values.
public static void WriteAttributeBuffer(this Mesh mesh, int[] data)
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh containing the buffer to write to.
dataint[]The values to fill the buffer with.
WriteIndexBuffer(Mesh, short[])
Fills the SlimDX.Direct3D9.IndexBuffer of a SlimDX.Direct3D9.Mesh with 16-bit values.
public static void WriteIndexBuffer(this Mesh mesh, short[] data)
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh containing the buffer to write to.
datashort[]The values to fill the buffer with.
WriteIndexBuffer(Mesh, int[])
Fills the SlimDX.Direct3D9.IndexBuffer of a SlimDX.Direct3D9.Mesh with 32-bit values.
public static void WriteIndexBuffer(this Mesh mesh, int[] data)
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh containing the buffer to write to.
dataint[]The values to fill the buffer with.
WriteVertexBuffer<T>(Mesh, T[])
Fills the SlimDX.Direct3D9.VertexBuffer of a SlimDX.Direct3D9.Mesh with data.
public static void WriteVertexBuffer<T>(this Mesh mesh, T[] data) where T : struct
Parameters
meshMeshThe SlimDX.Direct3D9.Mesh containing the buffer to write to.
dataT[]The vertexes to fill the buffer with.
Type Parameters
TThe vertex format used in the buffer.
Write<T>(VertexBuffer, T[])
Fills a SlimDX.Direct3D9.VertexBuffer with data.
public static void Write<T>(this VertexBuffer buffer, T[] data) where T : struct
Parameters
bufferVertexBufferThe buffer to write to.
dataT[]The vertexes to fill the buffer with.
Type Parameters
TThe vertex format used in the buffer.