Show More
Commit Description:
Add basic infrastructure to store and display visitor count....
Commit Description:
Add basic infrastructure to store and display visitor count. May eventually move to simulating visitors as entities. We'll see.
File last commit:
Show/Diff file:
Action:
FNA/src/Graphics/RenderTarget2D.cs
212 lines | 3.6 KiB | text/x-csharp | CSharpLexer
Early working version (including all dependencies, lol).
r0 #region License
/* FNA - XNA4 Reimplementation for Desktop Platforms
Upgrade FNA to 22.12...
r690 * Copyright 2009-2022 Ethan Lee and the MonoGame Team
Early working version (including all dependencies, lol).
r0 *
* Released under the Microsoft Public License.
* See LICENSE for details.
*/
#endregion
#region Using Statements
using System;
#endregion
namespace Microsoft.Xna.Framework.Graphics
{
public class RenderTarget2D : Texture2D, IRenderTarget
{
#region Public Properties
public DepthFormat DepthStencilFormat
{
get;
private set;
}
public int MultiSampleCount
{
get;
private set;
}
public RenderTargetUsage RenderTargetUsage
{
get;
private set;
}
public bool IsContentLost
{
get
{
return false;
}
}
#endregion
#region IRenderTarget Properties
/// <inheritdoc/>
Upgrade FNA to 22.12...
r690 IntPtr IRenderTarget.DepthStencilBuffer
Early working version (including all dependencies, lol).
r0 {
get
{
return glDepthStencilBuffer;
}
}
/// <inheritdoc/>
Upgrade FNA to 22.12...
r690 IntPtr IRenderTarget.ColorBuffer
Early working version (including all dependencies, lol).
r0 {
get
{
return glColorBuffer;
}
}
#endregion
Upgrade FNA to 22.12...
r690 #region Private FNA3D Variables
Early working version (including all dependencies, lol).
r0
Upgrade FNA to 22.12...
r690 private IntPtr glDepthStencilBuffer;
private IntPtr glColorBuffer;
Early working version (including all dependencies, lol).
r0
#endregion
#region ContentLost Event
#pragma warning disable 0067
// We never lose data, but lol XNA4 compliance -flibit
public event EventHandler<EventArgs> ContentLost;
#pragma warning restore 0067
#endregion
#region Public Constructors
public RenderTarget2D(
GraphicsDevice graphicsDevice,
int width,
int height
) : this(
graphicsDevice,
width,
height,
false,
SurfaceFormat.Color,
DepthFormat.None,
0,
RenderTargetUsage.DiscardContents
) {
}
public RenderTarget2D(
GraphicsDevice graphicsDevice,
int width,
int height,
bool mipMap,
SurfaceFormat preferredFormat,
DepthFormat preferredDepthFormat
) : this(
graphicsDevice,
width,
height,
mipMap,
preferredFormat,
preferredDepthFormat,
0,
RenderTargetUsage.DiscardContents
) {
}
public RenderTarget2D(
GraphicsDevice graphicsDevice,
int width,
int height,
bool mipMap,
SurfaceFormat preferredFormat,
DepthFormat preferredDepthFormat,
int preferredMultiSampleCount,
RenderTargetUsage usage
) : base(
graphicsDevice,
width,
height,
mipMap,
preferredFormat
) {
DepthStencilFormat = preferredDepthFormat;
Upgrade FNA to 22.12...
r690 MultiSampleCount = FNA3D.FNA3D_GetMaxMultiSampleCount(
graphicsDevice.GLDevice,
Format,
MathHelper.ClosestMSAAPower(preferredMultiSampleCount)
Early working version (including all dependencies, lol).
r0 );
RenderTargetUsage = usage;
if (MultiSampleCount > 0)
{
Upgrade FNA to 22.12...
r690 glColorBuffer = FNA3D.FNA3D_GenColorRenderbuffer(
graphicsDevice.GLDevice,
Early working version (including all dependencies, lol).
r0 Width,
Height,
Format,
MultiSampleCount,
texture
);
}
// If we don't need a depth buffer then we're done.
if (DepthStencilFormat == DepthFormat.None)
{
return;
}
Upgrade FNA to 22.12...
r690 glDepthStencilBuffer = FNA3D.FNA3D_GenDepthStencilRenderbuffer(
graphicsDevice.GLDevice,
Early working version (including all dependencies, lol).
r0 Width,
Height,
DepthStencilFormat,
MultiSampleCount
);
}
#endregion
#region Protected Dispose Method
protected override void Dispose(bool disposing)
{
if (!IsDisposed)
{
Upgrade FNA to 22.12...
r690 if (glColorBuffer != IntPtr.Zero)
Early working version (including all dependencies, lol).
r0 {
Upgrade FNA to 22.12...
r690 FNA3D.FNA3D_AddDisposeRenderbuffer(
GraphicsDevice.GLDevice,
glColorBuffer
);
Early working version (including all dependencies, lol).
r0 }
Upgrade FNA to 22.12...
r690 if (glDepthStencilBuffer != IntPtr.Zero)
Early working version (including all dependencies, lol).
r0 {
Upgrade FNA to 22.12...
r690 FNA3D.FNA3D_AddDisposeRenderbuffer(
GraphicsDevice.GLDevice,
glDepthStencilBuffer
);
Early working version (including all dependencies, lol).
r0 }
}
base.Dispose(disposing);
}
#endregion
#region Internal Context Reset Method
protected internal override void GraphicsDeviceResetting()
{
base.GraphicsDeviceResetting();
}
#endregion
}
}