本文整理汇总了C#中SharpDX.Direct3D11.Buffer类的典型用法代码示例。如果您正苦于以下问题:C# Buffer类的具体用法?C# Buffer怎么用?C# Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Buffer类属于SharpDX.Direct3D11命名空间,在下文中一共展示了Buffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IndexBuffer
public IndexBuffer(Device device, ushort[] indices)
{
if(device == null)
{
throw new ArgumentNullException("device");
}
if(indices == null)
{
throw new ArgumentNullException("indices");
}
using(var dataStream = new DataStream(sizeof(UInt16)*indices.Length, true, true))
{
dataStream.WriteRange(indices);
dataStream.Position = 0;
Buffer = new Buffer(device,
dataStream,
(int) dataStream.Length,
ResourceUsage.Immutable,
BindFlags.IndexBuffer,
CpuAccessFlags.None,
ResourceOptionFlags.None,
0);
}
Count = indices.Length;
}
开发者ID:Bloyteg,项目名称:AlphaMapper,代码行数:29,代码来源:IndexBuffer.cs
示例2: Postprocess
public Postprocess(Game game, string shaderFile, RenderTexture rt = null, string name = null)
{
this.game = game;
this.renderTexture = rt;
if(name == null)
{
this.Name = System.IO.Path.GetFileNameWithoutExtension(shaderFile);
this.debugName = "Postprocess " + this.Name;
}
else
{
this.debugName = this.Name = name;
}
this.shaderFile = shaderFile;
var desc = SamplerStateDescription.Default();
desc.Filter = Filter.MinMagMipPoint;
defaultSamplerStateDescription = desc;
LoadShader();
BuildVertexBuffer();
ppBuffer = Material.CreateBuffer<LiliumPostprocessData>();
game.AddObject(this);
}
开发者ID:woncomp,项目名称:LiliumLab,代码行数:25,代码来源:Postprocess.cs
示例3: Buffer
public Buffer(BufferDescription description)
{
_description = description;
_flags = GetBufferFlagsFromDescription(description);
_nativeBuffer = new SharpDX.Direct3D11.Buffer(GraphicManager.Device, description);
}
开发者ID:bgarate,项目名称:SynergyEngine,代码行数:7,代码来源:Buffer.cs
示例4: Rectangle
public Rectangle(Renderer renderer, Vector2I screenSize, Vector2I position, Vector2I size, Vector4 color, float depth = 0.0f)
{
_shader = renderer.ColorShader;
Position = position;
ScreenSize = screenSize;
Size = size;
_color = color;
_changed = true;
Depth = depth;
int vertexCount = 4;
_indexCount = 6;
_vertices = new VertexDefinition.PositionColor[vertexCount];
UInt32[] indices = { 0, 1, 2, 0, 3, 1 };
_vertexBuffer = Buffer.Create(renderer.DirectX.Device, _vertices,
new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionColor>() * vertexCount,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
StructureByteStride = 0
});
_indexBuffer = Buffer.Create(renderer.DirectX.Device, BindFlags.IndexBuffer, indices);
}
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:29,代码来源:Rectangle.cs
示例5: SibenikMaterial
public SibenikMaterial(Device device, TweakBar bar, String name)
: base(device, bar, name)
{
bar.AddColor(Prefix + "diffuse", "Diffuse", name, new Color3(1, 1, 1));
bar.AddColor(Prefix + "specular", "Specular", name, new Color3(1, 1, 1));
bar.AddFloat(Prefix + "shininess", "Shininess", name, 1, 256, 64, 0.1, 2);
bar.AddFloat(Prefix + "brightness", "Brightness", name, 0, 15000, 5, 50, 2);
pixelShader = Material.CompileShader(device, "sibenik");
constantBuffer = Material.AllocateMaterialBuffer(device, BufferSize);
sampler = new SamplerState(device, new SamplerStateDescription()
{
ComparisonFunction = Comparison.Always,
AddressU = TextureAddressMode.Wrap,
AddressV = TextureAddressMode.Wrap,
AddressW = TextureAddressMode.Wrap,
Filter = Filter.Anisotropic,
BorderColor = Color4.Black,
MaximumAnisotropy = 16,
MaximumLod = 15,
MinimumLod = 0,
MipLodBias = 0,
});
}
开发者ID:TomCrypto,项目名称:Insight,代码行数:26,代码来源:SibenikMaterial.cs
示例6: CreateDeviceDependentResources
protected override void CreateDeviceDependentResources()
{
RemoveAndDispose(ref vertexBuffer);
RemoveAndDispose(ref indexBuffer);
// Retrieve our SharpDX.Direct3D11.Device1 instance
var device = this.DeviceManager.Direct3DDevice;
// Load texture (a DDS cube map)
textureView = ShaderResourceView.FromFile(device, "CubeMap.dds");
// Create our sampler state
samplerState = new SamplerState(device, new SamplerStateDescription()
{
AddressU = TextureAddressMode.Clamp,
AddressV = TextureAddressMode.Clamp,
AddressW = TextureAddressMode.Clamp,
BorderColor = new Color4(0, 0, 0, 0),
ComparisonFunction = Comparison.Never,
Filter = Filter.MinMagMipLinear,
MaximumLod = 9, // Our cube map has 10 mip map levels (0-9)
MinimumLod = 0,
MipLodBias = 0.0f
});
Vertex[] vertices;
int[] indices;
GeometricPrimitives.GenerateSphere(out vertices, out indices, Color.Gray);
vertexBuffer = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, vertices));
vertexBinding = new VertexBufferBinding(vertexBuffer, Utilities.SizeOf<Vertex>(), 0);
indexBuffer = ToDispose(Buffer.Create(device, BindFlags.IndexBuffer, indices));
totalVertexCount = indices.Length;
}
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:35,代码来源:SphereRenderer.cs
示例7: Geometry
//Constructor
internal Geometry(SharpDevice device, ModelGeometry data, bool animated)
{
this.Name = data.Name;
this.Device = device;
//Data
List<VertexFormat> vertices = new List<VertexFormat>(data.Vertices);
List<int> indices = new List<int>(data.Indices);
VertexCount = vertices.Count;
IndexCount = indices.Count;
//Vertex Buffer
VertexBuffer = SharpDX.Direct3D11.Buffer.Create<VertexFormat>(Device.Device, BindFlags.VertexBuffer, vertices.ToArray());
//Index Buffer
IndexBuffer = SharpDX.Direct3D11.Buffer.Create<int>(Device.Device, BindFlags.IndexBuffer, indices.ToArray());
Material = new Material(data.Material);
IsAnimated = animated;
transformBuffer = new Buffer11(Device.Device, Utilities.SizeOf<SkinShaderInformation>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
paletteBuffer = new Buffer11(Device.Device, Utilities.SizeOf<Matrix>() * 256, ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
}
开发者ID:chantsunman,项目名称:SharpDX_Demo,代码行数:27,代码来源:Geometry.cs
示例8: StencilShadowRenderer
public StencilShadowRenderer(Game game)
{
this.game = game;
var desc = new MaterialPassDesc();
desc.ManualConstantBuffers = true;
desc.ShaderFile = "StencilShadow.hlsl";
desc.BlendStates.RenderTarget[0].IsBlendEnabled = true;
desc.BlendStates.RenderTarget[0].SourceBlend = BlendOption.SourceAlpha;
desc.BlendStates.RenderTarget[0].DestinationBlend = BlendOption.InverseSourceAlpha;
desc.BlendStates.RenderTarget[0].BlendOperation = BlendOperation.Add;
desc.BlendStates.RenderTarget[0].SourceAlphaBlend = BlendOption.One;
desc.BlendStates.RenderTarget[0].DestinationAlphaBlend = BlendOption.Zero;
desc.BlendStates.RenderTarget[0].AlphaBlendOperation = BlendOperation.Add;
desc.BlendStates.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
desc.DepthStencilStates.IsDepthEnabled = true;
desc.DepthStencilStates.DepthWriteMask = DepthWriteMask.Zero;
desc.DepthStencilStates.DepthComparison = Comparison.LessEqual;
desc.DepthStencilStates.IsStencilEnabled = true;
desc.DepthStencilStates.StencilReadMask = 1;
desc.DepthStencilStates.StencilWriteMask = 1;
desc.DepthStencilStates.FrontFace.FailOperation = StencilOperation.Keep;
desc.DepthStencilStates.FrontFace.DepthFailOperation = StencilOperation.Keep;
desc.DepthStencilStates.FrontFace.PassOperation = StencilOperation.Replace;
desc.DepthStencilStates.FrontFace.Comparison = Comparison.NotEqual;
desc.StencilRef = 1;
pass = new MaterialPass(game.Device, desc, "StencilShadow");
buffer = Material.CreateBuffer<ShaderData>();
}
开发者ID:woncomp,项目名称:LiliumLab,代码行数:29,代码来源:StencilShadowRenderer.cs
示例9: CreateBufferUAV
public static UnorderedAccessView CreateBufferUAV(SharpDX.Direct3D11.Device device, Buffer buffer, UnorderedAccessViewBufferFlags flags = UnorderedAccessViewBufferFlags.None)
{
UnorderedAccessViewDescription uavDesc = new UnorderedAccessViewDescription
{
Dimension = UnorderedAccessViewDimension.Buffer,
Buffer = new UnorderedAccessViewDescription.BufferResource { FirstElement = 0 }
};
if ((buffer.Description.OptionFlags & ResourceOptionFlags.BufferAllowRawViews) == ResourceOptionFlags.BufferAllowRawViews)
{
// A raw buffer requires R32_Typeless
uavDesc.Format = Format.R32_Typeless;
uavDesc.Buffer.Flags = UnorderedAccessViewBufferFlags.Raw | flags;
uavDesc.Buffer.ElementCount = buffer.Description.SizeInBytes / 4;
}
else if ((buffer.Description.OptionFlags & ResourceOptionFlags.BufferStructured) == ResourceOptionFlags.BufferStructured)
{
uavDesc.Format = Format.Unknown;
uavDesc.Buffer.Flags = flags;
uavDesc.Buffer.ElementCount = buffer.Description.SizeInBytes / buffer.Description.StructureByteStride;
}
else
{
throw new ArgumentException("Buffer must be raw or structured", "buffer");
}
return new UnorderedAccessView(device, buffer, uavDesc);
}
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:27,代码来源:ParticleRenderer.cs
示例10: PathShader
public PathShader(Device device)
{
var vertexShaderByteCode = ShaderBytecode.CompileFromFile(FileName, "VS", "vs_4_0", ShaderFlags);
var pixelShaderByteCode = ShaderBytecode.CompileFromFile(FileName, "PS", "ps_4_0", ShaderFlags);
var geometryShaderByteCode = ShaderBytecode.CompileFromFile(FileName, "GS", "gs_4_0", ShaderFlags);
VertexShader = new VertexShader(device, vertexShaderByteCode);
PixelShader = new PixelShader(device, pixelShaderByteCode);
GeometryShader = new GeometryShader(device, geometryShaderByteCode);
Layout = VertexDefinition.Path.GetInputLayout(device, vertexShaderByteCode);
vertexShaderByteCode.Dispose();
pixelShaderByteCode.Dispose();
geometryShaderByteCode.Dispose();
ConstantMatrixBuffer = new Buffer(device, MatrixBufferDesription);
ConstantPathDataBuffer = new Buffer(device,
new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = Utilities.SizeOf<PathData>(),
BindFlags = BindFlags.ConstantBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
StructureByteStride = 0
});
SamplerState = new SamplerState(device, WrapSamplerStateDescription);
}
开发者ID:ndech,项目名称:Alpha,代码行数:28,代码来源:PathShader.cs
示例11: Draw
public static void Draw(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Texture11 texture, SharpDX.Direct3D.PrimitiveTopology primitiveType, float opacity = 1.0f)
{
if (VertexBuffer == null)
{
VertexBuffer = new Buffer(renderContext.Device, System.Runtime.InteropServices.Marshal.SizeOf(points[0]) * 2500, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, System.Runtime.InteropServices.Marshal.SizeOf(points[0]));
VertexBufferBinding = new VertexBufferBinding(VertexBuffer, System.Runtime.InteropServices.Marshal.SizeOf((points[0])), 0);
}
renderContext.devContext.InputAssembler.PrimitiveTopology = primitiveType;
renderContext.BlendMode = BlendMode.Alpha;
renderContext.setRasterizerState(TriangleCullMode.Off);
SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mat.Transpose();
WarpOutputShader.MatWVP = mat;
WarpOutputShader.Use(renderContext.devContext, texture != null, opacity);
renderContext.SetVertexBuffer(VertexBufferBinding);
DataBox box = renderContext.devContext.MapSubresource(VertexBuffer, 0, MapMode.WriteDiscard, MapFlags.None);
Utilities.Write(box.DataPointer, points, 0, count);
renderContext.devContext.UnmapSubresource(VertexBuffer, 0);
if (texture != null)
{
renderContext.devContext.PixelShader.SetShaderResource(0, texture.ResourceView);
}
else
{
renderContext.devContext.PixelShader.SetShaderResource(0, null);
}
renderContext.devContext.Draw(count, 0);
}
开发者ID:china-vo,项目名称:wwt-windows-client,代码行数:33,代码来源:Sprite2d.cs
示例12: Init
internal void Init(string name, ref BufferDescription description, IntPtr? initData)
{
m_description = description;
m_elementCount = description.SizeInBytes / Math.Max(1, Description.StructureByteStride);
try
{
m_buffer = new Buffer(MyRender11.Device, initData ?? default(IntPtr), description)
{
DebugName = name,
};
}
catch (SharpDXException e)
{
MyRenderProxy.Log.WriteLine("Error during allocation of a directX buffer!");
LogStuff(e);
throw;
}
try
{
AfterBufferInit();
}
catch (SharpDXException e)
{
MyRenderProxy.Log.WriteLine("Error during creating a view or an unordered access to a directX buffer!");
LogStuff(e);
throw;
}
IsReleased = false;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:32,代码来源:MyBuffers.cs
示例13: UpdateBuffer
/****************************************************************************************************
*
****************************************************************************************************/
public void UpdateBuffer(DeviceContext context, Matrix world, ICamera camera)
{
var view = camera.CreateViewMatrix();
var projection = camera.CreateProjectionMatrix(Resolution);
Matrices[0] = Matrix.Transpose(world);
Matrices[1] = Matrix.Transpose(view);
Matrices[2] = Matrix.Transpose(projection);
Matrices[3] = Matrix.Transpose(world * view);
Matrices[4] = Matrix.Transpose(world * view * projection);
Matrices[5] = Matrix.Transpose(view * projection);
Matrices[6] = Matrix.Invert(world);
Matrices[7] = Matrix.Invert(world * view);
Matrices[8] = Matrix.Transpose(Matrix.Identity * Matrix.Scaling(LightPosition));
Matrices[9] = new Matrix(new float[]
{
LerpTime, AbsoluteTime, Resolution.X, Resolution.Y,
BeatTime, Lead,0,0,
Nisse0, Nisse1, Nisse2, Nisse3,
0,0,0,0,
});
if (Buffer == null)
{
Buffer = new Buffer(context.Device, Matrices.Length * Utilities.SizeOf<Matrix>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
}
context.UpdateSubresource(Matrices, Buffer);
}
开发者ID:JoltSoftwareDevelopment,项目名称:Jolt.MashRoom,代码行数:30,代码来源:ShaderEnvironment.cs
示例14: CreateGameColorBuffer
/// <summary>
/// Create a buffer containing all GameColors
/// </summary>
public static SharpDX.Direct3D11.Buffer CreateGameColorBuffer(Device device)
{
int numcolors = GameColorRGB.NUMCOLORS;
var arr = new int[numcolors];
for (int i = 0; i < numcolors; ++i)
{
var gc = (GameColor)i;
arr[i] = GameColorRGB.FromGameColor(gc).ToInt32();
}
SharpDX.Direct3D11.Buffer colorBuffer;
using (var stream = DataStream.Create(arr, true, false))
{
colorBuffer = new SharpDX.Direct3D11.Buffer(device, stream, new BufferDescription()
{
BindFlags = BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None,
SizeInBytes = sizeof(int) * arr.Length,
Usage = ResourceUsage.Immutable,
});
}
return colorBuffer;
}
开发者ID:Fulborg,项目名称:dwarrowdelf,代码行数:30,代码来源:Helpers11.cs
示例15: TextureShader
public TextureShader(Device device)
{
var vertexShaderByteCode = ShaderBytecode.CompileFromFile(ShaderFileName, "TextureVertexShader", "vs_4_0", ShaderFlags);
var pixelShaderByteCode = ShaderBytecode.CompileFromFile(ShaderFileName, "TexturePixelShader", "ps_4_0", ShaderFlags);
VertexShader = new VertexShader(device, vertexShaderByteCode);
PixelShader = new PixelShader(device, pixelShaderByteCode);
Layout = VertexDefinition.PositionTexture.GetInputLayout(device, vertexShaderByteCode);
vertexShaderByteCode.Dispose();
pixelShaderByteCode.Dispose();
ConstantMatrixBuffer = new Buffer(device, MatrixBufferDesription);
// Create a texture sampler state description.
var samplerDesc = new SamplerStateDescription
{
Filter = Filter.Anisotropic,
AddressU = TextureAddressMode.Mirror,
AddressV = TextureAddressMode.Mirror,
AddressW = TextureAddressMode.Mirror,
MipLodBias = 0,
MaximumAnisotropy = 16,
ComparisonFunction = Comparison.Always,
BorderColor = new Color4(1, 1, 1, 1),
MinimumLod = 0,
MaximumLod = 0
};
// Create the texture sampler state.
SamplerState = new SamplerState(device, samplerDesc);
}
开发者ID:ndech,项目名称:Alpha,代码行数:33,代码来源:TextureShader.cs
示例16: CreateDeviceDependentResources
/// <summary>
/// Create any device dependent resources here.
/// This method will be called when the device is first
/// initialized or recreated after being removed or reset.
/// </summary>
protected override void CreateDeviceDependentResources()
{
// Ensure that if already set the device resources
// are correctly disposed of before recreating
RemoveAndDispose(ref quadVertices);
RemoveAndDispose(ref quadIndices);
// Retrieve our SharpDX.Direct3D11.Device1 instance
var device = this.DeviceManager.Direct3DDevice;
// Create a quad (two triangles)
quadVertices = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, new[] {
/* Vertex Position Vertex Color */
new Vector4(0.25f, 0.5f, -0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), // Top-left
new Vector4(0.75f, 0.5f, -0.5f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), // Top-right
new Vector4(0.75f, 0.0f, -0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), // Base-right
new Vector4(0.25f, 0.0f, -0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), // Base-left
}));
quadBinding = new VertexBufferBinding(quadVertices, Utilities.SizeOf<Vector4>() * 2, 0);
// v0 v1
// |-----|
// | \ A |
// | B \ |
// |-----|
// v3 v2
quadIndices = ToDispose(Buffer.Create(device, BindFlags.IndexBuffer, new ushort[] {
0, 1, 2, // A
2, 3, 0 // B
}));
}
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:36,代码来源:QuadRenderer.cs
示例17: CreateDeviceDependentResources
protected override void CreateDeviceDependentResources()
{
base.CreateDeviceDependentResources();
RemoveAndDispose(ref vertexBuffer);
// Retrieve our SharpDX.Direct3D11.Device1 instance
var device = this.DeviceManager.Direct3DDevice;
List<Vertex> vertices = new List<Vertex>();
vertices.AddRange(new[] {
new Vertex(0, 0, -4, Vector3.UnitY, Color.Blue),
new Vertex(0, 0, 4,Vector3.UnitY, Color.Blue),
new Vertex(-4, 0, 0, Vector3.UnitY, Color.Red),
new Vertex(4, 0, 0,Vector3.UnitY, Color.Red),
});
for (var i = -4f; i < -0.09f; i += 0.2f)
{
vertices.Add(new Vertex(i, 0, -4, Color.Gray));
vertices.Add(new Vertex(i, 0, 4, Color.Gray));
vertices.Add(new Vertex(-i, 0, -4, Color.Gray));
vertices.Add(new Vertex(-i, 0, 4, Color.Gray));
vertices.Add(new Vertex(-4, 0, i, Color.Gray));
vertices.Add(new Vertex(4, 0, i, Color.Gray));
vertices.Add(new Vertex(-4, 0, -i, Color.Gray));
vertices.Add(new Vertex(4, 0, -i, Color.Gray));
}
vertexCount = vertices.Count;
vertexBuffer = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, vertices.ToArray()));
}
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:32,代码来源:AxisGridRenderer.cs
示例18: UpdateVertexArray
public Vector2I UpdateVertexArray(string text, ref VertexDefinition.PositionTextureColor[] vertices, ref Buffer vertexBuffer, Color defaultColor, List<TexturedRectangle> icons, int positionX = 0, int positionY = 0)
{
icons.Clear();
Color color = defaultColor;
int width = 0;
int maxWidth = 0;
int height = Characters.First().Value.height;
int maxHeight = height;
for (int i = 0; i < text.Length; i++)
{
char letter = text[i];
if (letter == '\n')
{
maxWidth = Math.Max(maxWidth, width);
width = 0;
positionX = 0;
positionY += height;
maxHeight += height;
continue;
}
if (letter == '[')
{
if (text[i + 1] == '[')
continue;
string token = text.Substring(i + 1, text.IndexOf(']', i + 1) - (i + 1));
if (!ColorParser.TryParse(token, out color))
{
if (token == "-")
color = defaultColor;
else if (token == "gold")
{
icons.Add(new TexturedRectangle(_context,
_context.TextureManager.Create("gold.png", "Data/UI/Icons/"), new Vector2I(height, height)));
positionX += height + 1;
width += height + 1;
}
else
throw new InvalidOperationException("Unexpected token : " + token);
}
i = text.IndexOf(']', i + 1);
continue;
}
Character c = Characters[letter];
Vector4 colorAsVector = color.ToVector4();
vertices[i * 4] = new VertexDefinition.PositionTextureColor { position = new Vector3(positionX, positionY, 0.0f), texture = new Vector2(c.uLeft, c.vTop), color = colorAsVector }; //Top left
vertices[i * 4 + 1] = new VertexDefinition.PositionTextureColor { position = new Vector3(positionX + c.width, positionY + c.height, 0.0f), texture = new Vector2(c.uRight, c.vBottom), color = colorAsVector }; //Right bottom
vertices[i * 4 + 2] = new VertexDefinition.PositionTextureColor { position = new Vector3(positionX, positionY + c.height, 0.0f), texture = new Vector2(c.uLeft, c.vBottom), color = colorAsVector }; //Left bottom
vertices[i * 4 + 3] = new VertexDefinition.PositionTextureColor { position = new Vector3(positionX + c.width, positionY, 0.0f), texture = new Vector2(c.uRight, c.vTop), color = colorAsVector }; //Top right
positionX += c.width + 1;
width += c.width + 1;
}
DataStream mappedResource;
_context.DirectX.Device.ImmediateContext.MapSubresource(vertexBuffer, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None,
out mappedResource);
mappedResource.WriteRange(vertices);
_context.DirectX.Device.ImmediateContext.UnmapSubresource(vertexBuffer, 0);
return new Vector2I(Math.Max(maxWidth, width), maxHeight);
}
开发者ID:ndech,项目名称:Alpha,代码行数:59,代码来源:Font.cs
示例19: SetConstantBuffer
internal void SetConstantBuffer(int slot, Buffer constantBuffer)
{
if (constantBuffer == m_constantBuffers[slot])
return;
m_constantBuffers[slot] = constantBuffer;
m_shaderStage.SetConstantBuffer(slot, constantBuffer);
m_statistics.SetConstantBuffers++;
}
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:8,代码来源:MyShaderStages.cs
示例20: BodyJointStatusBuffer
/// <summary>
/// Constructor
/// </summary>
/// <param name="device">Direct3D11 Device</param>
public BodyJointStatusBuffer(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.buffer = new SharpDX.Direct3D11.Buffer(device, JointBufferDescriptor.DynamicBuffer(new BufferStride(4)));
this.shaderView = new ShaderResourceView(device, this.buffer);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:12,代码来源:BodyJointStatusBuffer.cs
注:本文中的SharpDX.Direct3D11.Buffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论