本文整理汇总了C#中SurfaceFormat类的典型用法代码示例。如果您正苦于以下问题:C# SurfaceFormat类的具体用法?C# SurfaceFormat怎么用?C# SurfaceFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SurfaceFormat类属于命名空间,在下文中一共展示了SurfaceFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderTarget2D
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
: base(graphicsDevice, width, height, mipMap, preferredFormat)
{
RenderTargetUsage = usage;
//allocateOpenGLTexture();
}
示例2: RenderTarget2D
public RenderTarget2D (GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
:base (graphicsDevice, width, height, mipMap, preferredFormat)
{
#if IPHONE
if(GraphicsDevice.OpenGLESVersion == MonoTouch.OpenGLES.EAGLRenderingAPI.OpenGLES2)
{
GL20.GenFramebuffers(1, ref frameBuffer);
}
else
{
RenderTargetUsage = usage;
DepthStencilFormat = preferredDepthFormat;
}
#elif ANDROID
if (GraphicsDevice.OpenGLESVersion == OpenTK.Graphics.GLContextVersion.Gles2_0)
{
GL20.GenFramebuffers(1, ref frameBuffer);
}
else
{
RenderTargetUsage = usage;
DepthStencilFormat = preferredDepthFormat;
}
#else
RenderTargetUsage = usage;
DepthStencilFormat = preferredDepthFormat;
#endif
}
示例3: DisplayMode
internal DisplayMode(int width, int height, int refreshRate, SurfaceFormat format)
{
this.width = width;
this.height = height;
this.refreshRate = refreshRate;
this.format = format;
}
示例4: PostProcesses
public PostProcesses(SurfaceFormat? surface = null, DepthFormat? depth = null, bool mipmap = false, RenderTargetUsage? usage = null)
{
FormatSurface = surface;
FormatDepth = depth;
MipMap = mipmap;
Usage = usage;
}
示例5: CreateBitmap
/// <summary>
/// 根据图像格式(SurfaceFormat) 创建Bitmap
/// </summary>
/// <param name="width">宽度</param>
/// <param name="height">高度</param>
/// <param name="format">图像格式</param>
/// <returns></returns>
public static Bitmap CreateBitmap(GraphicsDevice p_GraphicsDevice, int p_Width, int p_Height, SurfaceFormat format)
{
return new Bitmap
{
Texture = new Texture2D(p_GraphicsDevice, p_Width, p_Height, false, format)
};
}
示例6: FlipTexture2D
public FlipTexture2D(GraphicsDevice graphicsDeivce, int width, int height,
bool mipMap, SurfaceFormat format, int numberTextures)
{
textures = new Texture2D[numberTextures];
for (int i = 0; i < textures.Length; ++i)
textures[i] = new Texture2D(graphicsDeivce, width, height, mipMap, format);
}
示例7: SsaoMapBlur
public SsaoMapBlur(Effect effect, SpriteBatch spriteBatch, int width, int height, SurfaceFormat format, int radius, float amount)
{
if (effect == null) throw new ArgumentNullException("effect");
if (spriteBatch == null) throw new ArgumentNullException("spriteBatch");
if (width < 1) throw new ArgumentOutOfRangeException("width");
if (height < 1) throw new ArgumentOutOfRangeException("height");
if (radius < MinAmount || MaxRadius < radius) throw new ArgumentOutOfRangeException("value");
if (amount < MinAmount) throw new ArgumentOutOfRangeException("value");
this.effect = effect;
this.spriteBatch = spriteBatch;
Width = width;
Height = height;
Radius = radius;
Amount = amount;
graphicsDevice = effect.GraphicsDevice;
normalDepthMap = effect.Parameters["NormalDepthMap"];
horizontalBlurTechnique = effect.Techniques["HorizontalBlur"];
verticalBlurTechnique = effect.Techniques["VerticalBlur"];
InitializeEffectParameters();
backingRenderTarget = new RenderTarget2D(graphicsDevice, width, height, false, format,
DepthFormat.None, 0, RenderTargetUsage.PlatformContents);
}
示例8: PlatformConstruct
private void PlatformConstruct(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
{
// Setup the multisampling description.
var multisampleDesc = new SharpDX.DXGI.SampleDescription(1, 0);
if (preferredMultiSampleCount > 1)
{
multisampleDesc.Count = preferredMultiSampleCount;
multisampleDesc.Quality = (int)StandardMultisampleQualityLevels.StandardMultisamplePattern;
}
// Create a descriptor for the depth/stencil buffer.
// Allocate a 2-D surface as the depth/stencil buffer.
// Create a DepthStencil view on this surface to use on bind.
using (var depthBuffer = new SharpDX.Direct3D11.Texture2D(graphicsDevice._d3dDevice, new Texture2DDescription
{
Format = SharpDXHelper.ToFormat(preferredDepthFormat),
ArraySize = 1,
MipLevels = 1,
Width = width,
Height = height,
SampleDescription = multisampleDesc,
BindFlags = BindFlags.DepthStencil,
}))
{
// Create the view for binding to the device.
_depthStencilView = new DepthStencilView(graphicsDevice._d3dDevice, depthBuffer, new DepthStencilViewDescription()
{
Format = SharpDXHelper.ToFormat(preferredDepthFormat),
Dimension = DepthStencilViewDimension.Texture2D
});
}
}
示例9: ESTexture2D
public ESTexture2D(byte[] data, SurfaceFormat pixelFormat, int width, int height, Size size, ALL11 filter)
{
if (GraphicsDevice.OpenGLESVersion != OpenTK.Graphics.GLContextVersion.Gles2_0)
{
using(Bitmap bm = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888))
{
using (var buffer = ByteBuffer.Wrap(data))
{
bm.CopyPixelsFromBuffer(buffer);
}
InitWithBitmap(bm, filter);
}
}
else
{
var imagePtr = IntPtr.Zero;
try
{
imagePtr = Marshal.AllocHGlobal (data.Length);
Marshal.Copy (data, 0, imagePtr, data.Length);
InitWithData(imagePtr, pixelFormat, width, height, size, filter);
}
finally
{
Marshal.FreeHGlobal (imagePtr);
}
}
}
示例10: GetFormatSize
internal static int GetFormatSize(SurfaceFormat format)
{
switch (format)
{
case SurfaceFormat.Dxt1:
return 8;
case SurfaceFormat.Dxt3:
case SurfaceFormat.Dxt5:
return 16;
case SurfaceFormat.Alpha8:
return 1;
case SurfaceFormat.Bgr565:
case SurfaceFormat.Bgra4444:
case SurfaceFormat.Bgra5551:
case SurfaceFormat.HalfSingle:
case SurfaceFormat.NormalizedByte2:
return 2;
case SurfaceFormat.Color:
case SurfaceFormat.Single:
case SurfaceFormat.Rg32:
case SurfaceFormat.HalfVector2:
case SurfaceFormat.NormalizedByte4:
case SurfaceFormat.Rgba1010102:
return 4;
case SurfaceFormat.HalfVector4:
case SurfaceFormat.Rgba64:
case SurfaceFormat.Vector2:
return 8;
case SurfaceFormat.Vector4:
return 16;
default:
throw new ArgumentException("Should be a value defined in SurfaceFormat", "Format");
}
}
示例11: RenderTarget2D
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
: base(graphicsDevice, width, height, mipMap, preferredFormat, true)
{
RenderTarget2D renderTarget2D = this;
this.DepthStencilFormat = preferredDepthFormat;
this.MultiSampleCount = preferredMultiSampleCount;
this.RenderTargetUsage = usage;
if (preferredDepthFormat == DepthFormat.None)
return;
Threading.BlockOnUIThread((Action) (() =>
{
GL.GenRenderbuffers(1, out renderTarget2D.glDepthStencilBuffer);
GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, renderTarget2D.glDepthStencilBuffer);
RenderbufferStorage local_0 = RenderbufferStorage.DepthComponent16;
switch (preferredDepthFormat)
{
case DepthFormat.Depth24Stencil8:
local_0 = RenderbufferStorage.Depth24Stencil8;
break;
case DepthFormat.Depth24:
local_0 = RenderbufferStorage.DepthComponent24;
break;
case DepthFormat.Depth16:
local_0 = RenderbufferStorage.DepthComponent16;
break;
}
if (renderTarget2D.MultiSampleCount == 0)
GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, local_0, renderTarget2D.width, renderTarget2D.height);
else
GL.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, renderTarget2D.MultiSampleCount, local_0, renderTarget2D.width, renderTarget2D.height);
}));
}
示例12: CreateRenderTarget
public static RenderTarget2D CreateRenderTarget(GraphicsDevice device, int numberLevels, SurfaceFormat surface, int width, int height)
{
MultiSampleType type = device.PresentationParameters.MultiSampleType;
// If the card can't use the surface format
if (!GraphicsAdapter.DefaultAdapter.CheckDeviceFormat(
DeviceType.Hardware,
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Format,
TextureUsage.None,
QueryUsages.None,
ResourceType.RenderTarget,
surface))
{
// Fall back to current display format
surface = device.DisplayMode.Format;
}
// Or it can't accept that surface format
// with the current AA settings
else if (!GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(
DeviceType.Hardware, surface,
device.PresentationParameters.IsFullScreen, type))
{
// Fall back to no antialiasing
type = MultiSampleType.None;
}
// Create our render target
return new RenderTarget2D(device,
width, height, numberLevels, surface,
type, 0, RenderTargetUsage.PreserveContents);
}
示例13: GetIntermediateTexture
public IntermediateRenderTarget GetIntermediateTexture(int width, int height, bool mipmap, SurfaceFormat SurfaceFormat, DepthFormat DepthFormat, int preferedMultisampleCount, RenderTargetUsage RenderTargetUsage)
{
// Look for a matching rendertarget in the cache
for (int i = 0; i < intermediateTextures.Count; i++)
{
if (intermediateTextures[i].InUse == false
&& height == intermediateTextures[i].RenderTarget.Height
&& width == intermediateTextures[i].RenderTarget.Width
&& preferedMultisampleCount == intermediateTextures[i].RenderTarget.MultiSampleCount
&& SurfaceFormat == intermediateTextures[i].RenderTarget.Format
&& DepthFormat == intermediateTextures[i].RenderTarget.DepthStencilFormat
&& RenderTargetUsage == intermediateTextures[i].RenderTarget.RenderTargetUsage
&& (mipmap == true && intermediateTextures[i].RenderTarget.LevelCount > 0 || mipmap == false && intermediateTextures[i].RenderTarget.LevelCount == 0)
)
{
intermediateTextures[i].InUse = true;
return intermediateTextures[i];
}
}
// We didn't find one, let's make one
IntermediateRenderTarget newTexture = new IntermediateRenderTarget();
newTexture.RenderTarget = new RenderTarget2D(device,width, height, mipmap, SurfaceFormat,DepthFormat, preferedMultisampleCount, RenderTargetUsage );
intermediateTextures.Add(newTexture);
newTexture.InUse = true;
return newTexture;
}
示例14: UpdateCustomRenderTarget
public RenderTarget2D UpdateCustomRenderTarget(RenderTarget2D renderTarget, IGameContext gameContext, SurfaceFormat? surfaceFormat, DepthFormat? depthFormat, int? multiSampleCount)
{
if (IsCustomRenderTargetOutOfDate(renderTarget, gameContext, surfaceFormat, depthFormat, multiSampleCount))
{
if (renderTarget != null)
{
renderTarget.Dispose();
}
if (gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferWidth == 0 &&
gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferHeight == 0)
{
return null;
}
renderTarget = new RenderTarget2D(
gameContext.Graphics.GraphicsDevice,
gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferWidth,
gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferHeight,
false,
surfaceFormat ?? gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferFormat,
depthFormat ?? gameContext.Graphics.GraphicsDevice.PresentationParameters.DepthStencilFormat,
multiSampleCount ?? gameContext.Graphics.GraphicsDevice.PresentationParameters.MultiSampleCount,
RenderTargetUsage.PreserveContents);
}
return renderTarget;
}
示例15: RenderTarget2D
public RenderTarget2D (
GraphicsDevice graphicsDevice,
int width,
int height,
int numberLevels,
SurfaceFormat format
)
{
// throw new NotImplementedException();
texture = new Texture2D( graphicsDevice, width, height, numberLevels, TextureUsage.None, format );
// create framebuffer
/*GL.GenBuffers(1, ref textureFrameBuffer);
GL.BindBuffer(All.Framebuffer, textureFrameBuffer);
// attach renderbuffer
GL.FramebufferTexture2D(All.Framebuffer, All.ColorAttachment0, All.Texture2D, textureFrameBuffer, 0);
// attach depth buffer
uint depthRenderbuffer;
GL.GenRenderbuffers(1, ref depthRenderbuffer);
GL.BindRenderbuffer(All.Renderbuffer, depthRenderbuffer);
GL.RenderbufferStorage(All.Renderbuffer, All.DepthComponent16, width, height);
GL.FramebufferRenderbuffer(All.Framebuffer, All.DepthAttachment, All.Renderbuffer, depthRenderbuffer);
// unbind frame buffer
GL.BindBuffer(All.Framebuffer, 0);*/
}