Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
Full cleanup of Graphics/Vertices/
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Mar 24, 2014
1 parent 8dd78db commit c9ecd31
Show file tree
Hide file tree
Showing 16 changed files with 1,017 additions and 894 deletions.
17 changes: 5 additions & 12 deletions MonoGame.Framework/Graphics/Vertices/BufferUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
*/
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion

namespace Microsoft.Xna.Framework.Graphics
{
public enum BufferUsage
{
None,
WriteOnly
}
public enum BufferUsage
{
None,
WriteOnly
}
}
21 changes: 7 additions & 14 deletions MonoGame.Framework/Graphics/Vertices/IVertexType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@
*/
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion

namespace Microsoft.Xna.Framework.Graphics
{
public interface IVertexType
{
VertexDeclaration VertexDeclaration
{
get;
}
}
public interface IVertexType
{
VertexDeclaration VertexDeclaration
{
get;
}
}
}
1 change: 0 additions & 1 deletion MonoGame.Framework/Graphics/Vertices/IndexBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#region Using Statements
using System;
using System.Linq;
using System.Runtime.InteropServices;

using OpenTK.Graphics.OpenGL;
Expand Down
3 changes: 0 additions & 3 deletions MonoGame.Framework/Graphics/Vertices/IndexElementSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/
#endregion

using System;

namespace Microsoft.Xna.Framework.Graphics
{
public enum IndexElementSize
Expand All @@ -17,4 +15,3 @@ public enum IndexElementSize
ThirtyTwoBits
}
}

192 changes: 108 additions & 84 deletions MonoGame.Framework/Graphics/Vertices/VertexBufferBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,88 +9,112 @@

namespace Microsoft.Xna.Framework.Graphics
{
public struct VertexBufferBinding
{
#region Public Properties

/// <summary>
/// Gets the instance frequency. A value of 0 means no instancing.
/// </summary>
public int InstanceFrequency { get { return _instanceFrequency; } }

/// <summary>
/// Gets the vertex buffer.
/// </summary>
public VertexBuffer VertexBuffer { get { return _vertexBuffer; } }

/// <summary>
/// Gets the offset in bytes from the beginning of the vertex buffer to the first vertex to use.
/// </summary>
public int VertexOffset { get { return _vertexOffset; } }

#endregion

#region Internal Static Properties

/// <summary>
/// A null vertex buffer binding for unused vertex buffer slots.
/// </summary>
static internal VertexBufferBinding None { get { return _none; } }

#endregion

#region Private Variables

VertexBuffer _vertexBuffer;
int _vertexOffset;
int _instanceFrequency;

#endregion

#region Private Static Variables

static VertexBufferBinding _none = new VertexBufferBinding(null);

#endregion

#region Public Constructors

/// <summary>
/// Creates an instance of VertexBufferBinding.
/// </summary>
/// <param name="vertexBuffer">The vertex buffer to bind.</param>
public VertexBufferBinding(VertexBuffer vertexBuffer)
{
_vertexBuffer = vertexBuffer;
_vertexOffset = 0;
_instanceFrequency = 0;
}

/// <summary>
/// Creates an instance of VertexBufferBinding.
/// </summary>
/// <param name="vertexBuffer">The vertex buffer to bind.</param>
/// <param name="vertexOffset">The offset in bytes to the first vertex to use.</param>
public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset)
{
_vertexBuffer = vertexBuffer;
_vertexOffset = vertexOffset;
_instanceFrequency = 0;
}

/// <summary>
/// Creates an instance of VertexBufferBinding.
/// </summary>
/// <param name="vertexBuffer">The vertex buffer to bind.</param>
/// <param name="vertexOffset">The offset in bytes to the first vertex to use.</param>
/// <param name="instanceFrequency">Number of instances to draw for each draw call. Use 0 if not using instanced drawing.</param>
public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset, int instanceFrequency)
{
_vertexBuffer = vertexBuffer;
_vertexOffset = vertexOffset;
_instanceFrequency = instanceFrequency;
}

#endregion
}
public struct VertexBufferBinding
{
#region Public Properties

/// <summary>
/// Gets the instance frequency. A value of 0 means no instancing.
/// </summary>
public int InstanceFrequency
{
get
{
return instanceFrequency;
}
}

/// <summary>
/// Gets the vertex buffer.
/// </summary>
public VertexBuffer VertexBuffer
{
get
{
return vertexBuffer;
}
}

/// <summary>
/// Gets the offset in bytes from the beginning of the vertex buffer to the first vertex to use.
/// </summary>
public int VertexOffset
{
get
{
return vertexOffset;
}
}

#endregion

#region Internal Static Properties

/// <summary>
/// A null vertex buffer binding for unused vertex buffer slots.
/// </summary>
internal static VertexBufferBinding None
{
get
{
return none;
}
}

#endregion

#region Private Variables

private VertexBuffer vertexBuffer;
private int vertexOffset;
private int instanceFrequency;

#endregion

#region Private Static Variables

private static VertexBufferBinding none = new VertexBufferBinding(null);

#endregion

#region Public Constructors

/// <summary>
/// Creates an instance of VertexBufferBinding.
/// </summary>
/// <param name="vertexBuffer">The vertex buffer to bind.</param>
public VertexBufferBinding(VertexBuffer vertexBuffer)
{
this.vertexBuffer = vertexBuffer;
vertexOffset = 0;
instanceFrequency = 0;
}

/// <summary>
/// Creates an instance of VertexBufferBinding.
/// </summary>
/// <param name="vertexBuffer">The vertex buffer to bind.</param>
/// <param name="vertexOffset">The offset in bytes to the first vertex to use.</param>
public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset)
{
this.vertexBuffer = vertexBuffer;
this.vertexOffset = vertexOffset;
instanceFrequency = 0;
}

/// <summary>
/// Creates an instance of VertexBufferBinding.
/// </summary>
/// <param name="vertexBuffer">The vertex buffer to bind.</param>
/// <param name="vertexOffset">The offset in bytes to the first vertex to use.</param>
/// <param name="instanceFrequency">Number of instances to draw for each draw call. Use 0 if not using instanced drawing.</param>
public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset, int instanceFrequency)
{
this.vertexBuffer = vertexBuffer;
this.vertexOffset = vertexOffset;
this.instanceFrequency = instanceFrequency;
}

#endregion
}
}
29 changes: 14 additions & 15 deletions MonoGame.Framework/Graphics/Vertices/VertexColorTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,34 @@
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Runtime.InteropServices;
#endregion

namespace Microsoft.Xna.Framework.Graphics
{
[StructLayout(LayoutKind.Sequential, Pack=1)]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct VertexColorTexture
{
#region Public Fields
{
#region Public Fields

public Vector2 Vertex;
public Vector2 Vertex;
public uint Color;
public Vector2 TexCoord;

#endregion
#endregion

#region Public Constructor
#region Public Constructor

public VertexColorTexture ( Vector2 vertex, Color color, Vector2 texCoord )
{
public VertexColorTexture(
Vector2 vertex,
Color color,
Vector2 texCoord
) {
Vertex = vertex;
Color = color.PackedValue;
TexCoord = texCoord;
}
}

#endregion
}
#endregion
}
}

Loading

0 comments on commit c9ecd31

Please sign in to comment.