Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Removing cleaning up texture class.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed May 22, 2020
1 parent d93a14b commit 331b660
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 162 deletions.
14 changes: 7 additions & 7 deletions MonoGame/MonoGame.Framework/Graphics/SamplerStateCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ public sealed partial class SamplerStateCollection
{
private readonly GraphicsDevice _graphicsDevice;

private readonly SamplerState _samplerStateAnisotropicClamp;
private readonly SamplerState _samplerStateAnisotropicWrap;
private readonly SamplerState _samplerStateLinearClamp;
private readonly SamplerState _samplerStateLinearWrap;
// private readonly SamplerState _samplerStateAnisotropicClamp;
// private readonly SamplerState _samplerStateAnisotropicWrap;
// private readonly SamplerState _samplerStateLinearClamp;
// private readonly SamplerState _samplerStateLinearWrap;
private readonly SamplerState _samplerStatePointClamp;
private readonly SamplerState _samplerStatePointWrap;
// private readonly SamplerState _samplerStatePointWrap;

private readonly SamplerState[] _samplers;
private readonly SamplerState[] _actualSamplers;
private readonly bool _applyToVertexStage;
// private readonly bool _applyToVertexStage;

internal SamplerStateCollection(GraphicsDevice device, int maxSamplers, bool applyToVertexStage)
{
Expand All @@ -36,7 +36,7 @@ internal SamplerStateCollection(GraphicsDevice device, int maxSamplers, bool app

_samplers = new SamplerState[maxSamplers];
_actualSamplers = new SamplerState[maxSamplers];
_applyToVertexStage = applyToVertexStage;
// _applyToVertexStage = applyToVertexStage;

Clear();
}
Expand Down
1 change: 0 additions & 1 deletion MonoGame/MonoGame.Framework/Graphics/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// file 'LICENSE.txt', which is part of this source code package.

using System;
using System.Diagnostics;
using System.Threading;

namespace Microsoft.Xna.Framework.Graphics
Expand Down
56 changes: 28 additions & 28 deletions MonoGame/MonoGame.Framework/Graphics/Texture2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,28 +424,28 @@ public int Height
elementCount * tSize, dataByteSize), "elementCount");
}

internal Color[] GetColorData()
{
int colorDataLength = Width * Height;
var colorData = new Color[colorDataLength];

switch (Format)
{
case SurfaceFormat.Single:
var floatData = new float[colorDataLength];
GetData(floatData);

for (int i = 0; i < colorDataLength; i++)
{
float brightness = floatData[i];
// Export as a greyscale image.
colorData[i] = new Color(brightness, brightness, brightness);
}
break;

case SurfaceFormat.Color:
GetData(colorData);
break;
// internal Color[] GetColorData()
// {
// int colorDataLength = Width * Height;
// var colorData = new Color[colorDataLength];
//
// switch (Format)
// {
// case SurfaceFormat.Single:
// var floatData = new float[colorDataLength];
// GetData(floatData);
//
// for (int i = 0; i < colorDataLength; i++)
// {
// float brightness = floatData[i];
// // Export as a greyscale image.
// colorData[i] = new Color(brightness, brightness, brightness);
// }
// break;
//
// case SurfaceFormat.Color:
// GetData(colorData);
// break;

// case SurfaceFormat.Alpha8:
// var alpha8Data = new Alpha8[colorDataLength];
Expand Down Expand Up @@ -578,11 +578,11 @@ internal Color[] GetColorData()
//
// break;

default:
throw new Exception("Texture surface format not supported");
}

return colorData;
}
// default:
// throw new Exception("Texture surface format not supported");
// }
//
// return colorData;
// }
}
}
122 changes: 61 additions & 61 deletions MonoGame/MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ public partial class VertexBuffer : GraphicsResource
public VertexDeclaration VertexDeclaration { get; private set; }
// public BufferUsage BufferUsage { get; private set; }

protected VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, /*BufferUsage bufferUsage,*/ bool dynamic)
{
if (graphicsDevice == null)
{
throw new ArgumentNullException("graphicsDevice", FrameworkResources.ResourceCreationWhenDeviceIsNull);
}
this.GraphicsDevice = graphicsDevice;
this.VertexDeclaration = vertexDeclaration;
this.VertexCount = vertexCount;
// this.BufferUsage = bufferUsage;

// Make sure the graphics device is assigned in the vertex declaration.
if (vertexDeclaration.GraphicsDevice != graphicsDevice)
vertexDeclaration.GraphicsDevice = graphicsDevice;

_isDynamic = dynamic;

PlatformConstruct();
}
// protected VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, /*BufferUsage bufferUsage,*/ bool dynamic)
// {
// if (graphicsDevice == null)
// {
// throw new ArgumentNullException("graphicsDevice", FrameworkResources.ResourceCreationWhenDeviceIsNull);
// }
// this.GraphicsDevice = graphicsDevice;
// this.VertexDeclaration = vertexDeclaration;
// this.VertexCount = vertexCount;
// // this.BufferUsage = bufferUsage;
//
// // Make sure the graphics device is assigned in the vertex declaration.
// if (vertexDeclaration.GraphicsDevice != graphicsDevice)
// vertexDeclaration.GraphicsDevice = graphicsDevice;
//
// _isDynamic = dynamic;
//
// PlatformConstruct();
// }

// public VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage bufferUsage) :
// this(graphicsDevice, vertexDeclaration, vertexCount, bufferUsage, false)
Expand Down Expand Up @@ -77,38 +77,38 @@ internal protected override void GraphicsDeviceResetting()
/// For vertexStride we pass the size of a <see cref="VertexPositionTexture"/>.
/// </p>
/// </remarks>
public void GetData<T> (int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride = 0) where T : struct
{
var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
if (vertexStride == 0)
vertexStride = elementSizeInBytes;

var vertexByteSize = VertexCount * VertexDeclaration.VertexStride;
if (vertexStride > vertexByteSize)
throw new ArgumentOutOfRangeException("vertexStride", "Vertex stride can not be larger than the vertex buffer size.");

if (data == null)
throw new ArgumentNullException("data");
if (data.Length < (startIndex + elementCount))
throw new ArgumentOutOfRangeException("elementCount", "This parameter must be a valid index within the array.");
// if (BufferUsage == BufferUsage.WriteOnly)
// throw new NotSupportedException("Calling GetData on a resource that was created with BufferUsage.WriteOnly is not supported.");
if (elementCount > 1 && elementCount * vertexStride > vertexByteSize)
throw new InvalidOperationException("The array is not the correct size for the amount of data requested.");

PlatformGetData<T>(offsetInBytes, data, startIndex, elementCount, vertexStride);
}

public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{
this.GetData<T>(0, data, startIndex, elementCount, 0);
}

public void GetData<T>(T[] data) where T : struct
{
var elementSizeInByte = ReflectionHelpers.SizeOf<T>.Get();
this.GetData<T>(0, data, 0, data.Length, elementSizeInByte);
}
// public void GetData<T> (int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride = 0) where T : struct
// {
// var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
// if (vertexStride == 0)
// vertexStride = elementSizeInBytes;
//
// var vertexByteSize = VertexCount * VertexDeclaration.VertexStride;
// if (vertexStride > vertexByteSize)
// throw new ArgumentOutOfRangeException("vertexStride", "Vertex stride can not be larger than the vertex buffer size.");
//
// if (data == null)
// throw new ArgumentNullException("data");
// if (data.Length < (startIndex + elementCount))
// throw new ArgumentOutOfRangeException("elementCount", "This parameter must be a valid index within the array.");
// // if (BufferUsage == BufferUsage.WriteOnly)
// // throw new NotSupportedException("Calling GetData on a resource that was created with BufferUsage.WriteOnly is not supported.");
// if (elementCount > 1 && elementCount * vertexStride > vertexByteSize)
// throw new InvalidOperationException("The array is not the correct size for the amount of data requested.");
//
// PlatformGetData<T>(offsetInBytes, data, startIndex, elementCount, vertexStride);
// }
//
// public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
// {
// this.GetData<T>(0, data, startIndex, elementCount, 0);
// }
//
// public void GetData<T>(T[] data) where T : struct
// {
// var elementSizeInByte = ReflectionHelpers.SizeOf<T>.Get();
// this.GetData<T>(0, data, 0, data.Length, elementSizeInByte);
// }

/// <summary>
/// Sets the vertex buffer data, specifying the index at which to start copying from the source data array,
Expand Down Expand Up @@ -170,11 +170,11 @@ internal protected override void GraphicsDeviceResetting()
/// <param name="elementCount">Number of elements to copy from <paramref name="data"/>.
/// The combination of <paramref name="startIndex"/> and <paramref name="elementCount"/>
/// must be within the <paramref name="data"/> array bounds.</param>
public void SetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{
var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
SetDataInternal<T>(0, data, startIndex, elementCount, elementSizeInBytes, SetDataOptions.None);
}
// public void SetData<T>(T[] data, int startIndex, int elementCount) where T : struct
// {
// var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
// SetDataInternal<T>(0, data, startIndex, elementCount, elementSizeInBytes, SetDataOptions.None);
// }

/// <summary>
/// Sets the vertex buffer data. This is the same as calling <see cref="SetData{T}(int, T[], int, int, int)"/>
Expand All @@ -183,11 +183,11 @@ internal protected override void GraphicsDeviceResetting()
/// </summary>
/// <typeparam name="T">Type of elements in the data array.</typeparam>
/// <param name="data">Data array.</param>
public void SetData<T>(T[] data) where T : struct
{
var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
SetDataInternal<T>(0, data, 0, data.Length, elementSizeInBytes, SetDataOptions.None);
}
// public void SetData<T>(T[] data) where T : struct
// {
// var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
// SetDataInternal<T>(0, data, 0, data.Length, elementSizeInBytes, SetDataOptions.None);
// }

protected void SetDataInternal<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride, SetDataOptions options) where T : struct
{
Expand Down

0 comments on commit 331b660

Please sign in to comment.