本文整理汇总了C#中GraphicsDevice.SetVertexInputLayout方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.SetVertexInputLayout方法的具体用法?C# GraphicsDevice.SetVertexInputLayout怎么用?C# GraphicsDevice.SetVertexInputLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.SetVertexInputLayout方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: WarpSceneRenderer
public WarpSceneRenderer(Scene scene, int width, int height)
{
_scene = scene;
_width = width;
_height = height;
_aspectRatio = width / (float)height;
_device = GraphicsDevice.New(DriverType.Warp, DeviceCreationFlags.None, FeatureLevel.Level_10_1);
var serviceProvider = new ServiceProvider();
serviceProvider.AddService<IGraphicsDeviceService>(new GraphicsDeviceService(_device));
_contentManager = new ContentManager(serviceProvider);
_contentManager.Resolvers.Add(new ContentResolver());
var viewport = new Viewport(0, 0, _width, _height);
_device.SetViewports(viewport);
const MSAALevel msaaLevel = MSAALevel.None;
_depthStencilTexture = DepthStencilBuffer.New(_device, _width, _height, msaaLevel, DepthFormat.Depth24Stencil8);
_renderTexture = RenderTarget2D.New(_device, _width, _height, msaaLevel, PixelFormat.R8G8B8A8.UNorm);
Options = new RenderOptions();
_effect = new BasicEffect(_device);
_effect.EnableDefaultLighting();
_inputLayout = VertexInputLayout.New(0, typeof(VertexPositionNormalTexture));
_device.SetVertexInputLayout(_inputLayout);
_meshes = new List<WarpMesh>();
foreach (Mesh mesh in _scene.Meshes)
{
if (!mesh.Positions.Any())
continue;
var warpMesh = new WarpMesh(_device, mesh);
_meshes.Add(warpMesh);
warpMesh.Initialize(_contentManager);
}
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
}