本文整理汇总了C#中GraphicsDevice.SetVertexBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.SetVertexBuffer方法的具体用法?C# GraphicsDevice.SetVertexBuffer怎么用?C# GraphicsDevice.SetVertexBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.SetVertexBuffer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw(GraphicsDevice device)
{
device.SetVertexBuffer(Vertices);
device.SetIndexBuffer(Indices, true);
device.SetVertexInputLayout(InputLayout);
device.DrawIndexed(PrimitiveType.TriangleList, Indices.ElementCount);
}
示例2: DrawScreenAlignedTriangle
/// <summary>
/// draws a screen aligned triangle
/// </summary>
public void DrawScreenAlignedTriangle(GraphicsDevice device)
{
if (!initalised)
Init(device);
device.SetRasterizerState(_noneCullingState);
device.SetVertexBuffer(_screenTriangle);
device.SetVertexInputLayout(_vertexInputLayout);
device.Draw(PrimitiveType.TriangleList, 3);
}
示例3: Draw
public void Draw(GraphicsDevice graphicsDevice, Camera camera, Texture skyCubemap)
{
// setup camera
Matrix viewProjection = camera.ViewMatrix * camera.ProjectionMatrix;
Matrix viewProjectionInverse = viewProjection; viewProjectionInverse.Invert();
var cameraConstantBuffer = terrainShader.Effect.ConstantBuffers["Camera"];
cameraConstantBuffer.Set(0, viewProjectionInverse);
cameraConstantBuffer.Set(sizeof(float) * 4 * 4, camera.Position);
cameraConstantBuffer.IsDirty = true;
terrainShader.Effect.Parameters["Heightmap"].SetResource(heightmapTexture);
terrainShader.Effect.Parameters["SkyCubemap"].SetResource(skyCubemap);
terrainShader.Effect.Parameters["TerrainHeightmapSampler"].SetResource(linearBorderSamplerState);
graphicsDevice.SetVertexInputLayout(null);
graphicsDevice.SetVertexBuffer(0, (Buffer<Vector3>)null);
// Render screen-space terrain, including sky!
terrainShader.Effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Draw(PrimitiveType.PointList, 1);
}
示例4: DrawTrees
public void DrawTrees(GraphicsDevice device)
{
if (this.SceneryVertexCount == 0)
return;
device.SetVertexBuffer(m_sceneryVertexBuffer);
device.Draw(PrimitiveType.PointList, this.SceneryVertexCount);
}
示例5: DrawTerrain
public void DrawTerrain(GraphicsDevice device)
{
if (this.VertexCount == 0)
return;
device.SetVertexBuffer(m_vertexBuffer);
device.Draw(PrimitiveType.PointList, this.VertexCount);
}
示例6: Draw
/// <summary>
/// Draws this <see cref="ModelMeshPart"/>. See remarks for difference with XNA.
/// </summary>
/// <param name="graphicsDevice">The graphics device.</param>
/// <remarks>
/// Unlike XNA, a <see cref="ModelMeshPart"/> is not bound to a specific Effect. The effect must have been setup prior calling this method.
/// This method is only responsible to setup the VertexBuffer, IndexBuffer and call the appropriate <see cref="GraphicsDevice.DrawIndexed"/> method on the <see cref="GraphicsDevice"/>.
/// </remarks>
public void Draw(GraphicsDevice graphicsDevice)
{
// Setup the Vertex Buffer
var vertexBuffer = VertexBuffer.Resource.Buffer;
var elementSize = vertexBuffer.ElementSize;
graphicsDevice.SetVertexBuffer(0, vertexBuffer, elementSize, VertexBuffer.Start == 0 ? 0 : VertexBuffer.Start * elementSize);
// Setup the Vertex Buffer Input layout
graphicsDevice.SetVertexInputLayout(VertexBuffer.Resource.Layout);
// Setup the index Buffer
var indexBuffer = IndexBuffer.Resource;
graphicsDevice.SetIndexBuffer(indexBuffer, indexBuffer.ElementSize == 4, IndexBuffer.Start == 0 ? 0 : IndexBuffer.Start * indexBuffer.ElementSize);
// Finally Draw this mesh
graphicsDevice.DrawIndexed(PrimitiveType.TriangleList, IndexBuffer.Count);
}
示例7: draw
/// <summary>
/// Called by Game1, draws the final image. This happens independent of
/// a call to <see cref="Rasterizer.render"/>.
/// If this method is called without calling <see cref="Rasterizer.render"/> prior to it,
/// an empty screen appears.
/// </summary>
public void draw(GraphicsDevice device)
{
_colorTexture.SetData<Color>(_colorBuffer[0]);
_depthTexture.SetData<float>(_depthBuffer._elements[0]);
_effect.CurrentTechnique = _effect.Techniques["Simplest"];
_effect.Parameters["colorTexture"].SetValue(_colorTexture);
_effect.Parameters["depthTexture"].SetValue(_depthTexture);
_effect.Parameters["maxDim"].SetValue(_depthBuffer._maxDims[0]);
foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
{
pass.Apply();
device.SetVertexBuffer(_vb);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
}
device.Textures[0] = null;
device.Textures[1] = null;
}
示例8: DrawGhost
public void DrawGhost(Camera camera, GraphicsDevice graphicsDevice, VoxelType voxel, Int32 levelPositionCode)
{
_voxelEffect.Parameters["ViewProjection"].SetValue(camera.ViewMatrix * camera.ProjectionMatrix);
_voxelEffect.Parameters["VoxelTexture"].SetResource(_voxelTypeRenderingData[GetRenderingDataIndex(voxel)].Texture);
_voxelEffect.Parameters["Transparency"].SetValue(0.7f);
_voxelEffect.Parameters["Ambient"].SetValue(2.0f);
_voxelEffect.Parameters["ScalingFactor"].SetValue(TypeInformation.GetScalingFactor(voxel) * 0.5f);
_singleInstanceBuffer.SetDynamicData(graphicsDevice, (ptr) => System.Runtime.InteropServices.Marshal.Copy(
new Int32[] { levelPositionCode }, 0, ptr, 1));
graphicsDevice.SetRasterizerState(_noneCullingState);
graphicsDevice.SetDepthStencilState(_depthStencilStateState);
graphicsDevice.SetBlendState(_blendStateTransparent);
// Setup the vertices
graphicsDevice.SetVertexBuffer(0, _cubeVertexBuffer);
graphicsDevice.SetVertexBuffer(1, _singleInstanceBuffer);
graphicsDevice.SetVertexInputLayout(_vertexInputLayout);
_voxelEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawInstanced(PrimitiveType.TriangleList, _cubeVertexBuffer.ElementCount, 1, 0, 0);
}
示例9: Draw
/// <summary>
/// draw what else
/// </summary>
public void Draw(Camera camera, GraphicsDevice graphicsDevice)
{
_voxelEffect.Parameters["ViewProjection"].SetValue(camera.ViewMatrix * camera.ProjectionMatrix);
_voxelEffect.Parameters["Ambient"].SetValue(0.3f);
_voxelEffect.Parameters["CameraPosition"].SetValue(camera.Position);
graphicsDevice.SetRasterizerState(_backfaceCullingState);
graphicsDevice.SetDepthStencilState(_depthStencilStateState);
graphicsDevice.SetBlendState(_blendStateOpaque);
// Setup the vertices
graphicsDevice.SetVertexBuffer(_cubeVertexBuffer, 0);
graphicsDevice.SetVertexInputLayout(_vertexInputLayout);
// render all instances
for (int i = 0; i < _voxelTypeRenderingData.Length; ++i)
{
_voxelEffect.Parameters["ScalingFactor"].SetValue(TypeInformation.GetScalingFactor(_voxelTypeRenderingData[i].Voxel) * 0.5f);
_voxelEffect.Parameters["VoxelTexture"].SetResource(_voxelTypeRenderingData[i].Texture);
_voxelEffect.Parameters["SpecularModifier"].SetValue(TypeInformation.IsParasite( _voxelTypeRenderingData[i].Voxel ));
_voxelEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.SetVertexBuffer(1, _voxelTypeRenderingData[i].InstanceBuffer);
graphicsDevice.DrawInstanced(PrimitiveType.TriangleList, _cubeVertexBuffer.ElementCount, _voxelTypeRenderingData[i].InstanceDataRAM.Count, 0, 0);
}
graphicsDevice.SetVertexBuffer<int>(1, (Buffer<int>)null);
}
示例10: DrawGeometry
public void DrawGeometry(GraphicsDevice graphicsDevice)
{
graphicsDevice.SetVertexBuffer(0, patchVertexBuffer, 4, 0);
graphicsDevice.SetVertexInputLayout(vertexInputLayout);
for(int i = 0; i < patchInstanceBuffer.Length; ++i)
{
if (currentInstanceData[i].Count == 0)
continue;
graphicsDevice.SetIndexBuffer(patchIndexBuffer[i], false, 0);
graphicsDevice.SetVertexBuffer(1, patchInstanceBuffer[i], sizeof(float) * 4, 0);
graphicsDevice.DrawIndexedInstanced(PrimitiveType.PatchList(3), patchIndexBuffer[i].ElementCount, currentInstanceData[i].Count, 0, 0, 0);
}
}
示例11: Draw
public void Draw(GraphicsDevice graphicsDevice)
{
if (Visible && vertexBuffer != null)
{
graphicsDevice.SetVertexBuffer(vertexBuffer);
graphicsDevice.Draw(PrimitiveType.PointList, vertexBuffer.ElementCount);
}
}