本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetVertexBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.SetVertexBuffer方法的具体用法?C# GraphicsDevice.SetVertexBuffer怎么用?C# GraphicsDevice.SetVertexBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.SetVertexBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
/// <summary>
/// Render the terrain
/// </summary>
/// <param name="device"></param>
/// <param name="world"></param>
public override void Draw(GraphicsDevice device, WorldState world)
{
world._3D.ApplyCamera(Effect, this);
//device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
//device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
device.SetVertexBuffer(VertexBuffer);
device.Indices = IndexBuffer;
//device.RasterizerState.CullMode = CullMode.None;
foreach (var pass in Effect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GeomLength, 0, NumPrimitives);
}
device.SetVertexBuffer(GrassVertexBuffer);
//device.Indices = GrassIndexBuffer;
foreach (var pass in Effect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawPrimitives(PrimitiveType.LineList, 0, GrassPrimitives);
//device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, GrassPrimitives*2, 0, GrassPrimitives);
};
}
示例2: Initilize
public static void Initilize(GraphicsDevice gd)
{
ConstructCube();
vBuffer = new VertexBuffer(gd, VertexPositionNormalTexture.VertexDeclaration, 36, BufferUsage.WriteOnly);
vBuffer.SetData(verts);
gd.SetVertexBuffer(vBuffer);
ib = new IndexBuffer(gd, IndexElementSize.SixteenBits, 14, BufferUsage.WriteOnly);
ib.SetData(new short[14]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
});
gd.Indices = ib;
wireframeRaster = new RasterizerState();
wireframeRaster.FillMode = FillMode.WireFrame;
wireframeRaster.CullMode = CullMode.None;
wireframeEfect = new BasicEffect(gd);
wireframeEfect.Projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f,
wireframeEfect.GraphicsDevice.Viewport.AspectRatio, 0.01f, 3000f);
}
示例3: Render
public static void Render(BoundingSphere sphere,
GraphicsDevice graphicsDevice,
Matrix view,
Matrix projection,
Color color,
Guid id)
{
var subscription = Subscriptions[id];
graphicsDevice.SetVertexBuffer(subscription.VertexBuffer);
subscription.BasicEffect.World = Matrix.CreateScale(sphere.Radius)*
Matrix.CreateTranslation(sphere.Center);
subscription.BasicEffect.View = view;
subscription.BasicEffect.Projection = projection;
subscription.BasicEffect.DiffuseColor = color.ToVector3();
foreach (var pass in subscription.BasicEffect.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, SphereResolution);
graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip,
SphereResolution + 1,
SphereResolution);
graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip,
(SphereResolution + 1)*2,
SphereResolution);
}
}
示例4: RenderToDevice
public override void RenderToDevice(GraphicsDevice device, BasicEffect basicEffet)
{
if (Visible)
{
if (!basicEffet.LightingEnabled)
{
if (isConstructed == false)
Construct();
using
(
VertexBuffer buffer = new VertexBuffer(
device,
VertexPositionColor.VertexDeclaration,
points,
BufferUsage.WriteOnly)
)
{
// Load the buffer
buffer.SetData(pointList);
// Send the vertex buffer to the device
device.SetVertexBuffer(buffer);
device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, pointList, 0, 6, lineListIndices, 0, 3);
}
}
}
}
示例5: Draw
public void Draw(GraphicsDevice device, BasicEffect effect)
{
if (buf == null)
{
buf = new VertexBuffer(device, typeof(VertexPositionTexture), 4, BufferUsage.None);
var vpt = new VertexPositionTexture[4]{
new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0,0)),
new VertexPositionTexture(new Vector3(SIZE, 0, 0), new Vector2(1,0)),
new VertexPositionTexture(new Vector3(0, 0, SIZE), new Vector2(0,1)),
new VertexPositionTexture(new Vector3(SIZE, 0, SIZE), new Vector2(1,1))
};
buf.SetData(vpt);
}
device.SetVertexBuffer(buf);
effect.TextureEnabled = true;
effect.Texture = texture;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
}
示例6: Render
public void Render(GraphicsDevice device, Camera cam)
{
if (!Transform.renderer.enabled)
{
return;
}
device.SetVertexBuffer(VertexBuffer);
device.Indices = IndexBuffer;
Effect e = Material.shader.effect;
Material.shader.ApplyPreRenderSettings(Material, UseVertexColor);
Material.SetBlendState(device);
IEffectMatrices ems = e as IEffectMatrices;
if (ems != null)
{
ems.World = Transform.world;
ems.View = cam.view;
ems.Projection = cam.projectionMatrix;
}
foreach (EffectPass pass in e.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawIndexedPrimitives(
PrimitiveType.TriangleList,
0,
0,
VertexBuffer.VertexCount,
0,
IndexBuffer.IndexCount / 3
);
}
RenderStats.AddDrawCall(batches, VertexBuffer.VertexCount, IndexBuffer.IndexCount / 3);
}
示例7:
void IMesh.Render(GraphicsDevice Device)
{
Device.SetVertexBuffer(verticies);
Device.Indices = indicies;
Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verticies.VertexCount,
0, System.Math.Min(primitiveCount, 65535));
}
示例8: Render
/// <summary>
/// Draws the primitive to the screen.
/// </summary>
/// <param Name="device">GPU to draw with.</param>
public virtual void Render(GraphicsDevice device)
{
lock (VertexLock)
{
#if MONOGAME_BUILD
device.SamplerStates[0].Filter = TextureFilter.Point;
device.SamplerStates[1].Filter = TextureFilter.Point;
device.SamplerStates[2].Filter = TextureFilter.Point;
device.SamplerStates[3].Filter = TextureFilter.Point;
device.SamplerStates[4].Filter = TextureFilter.Point;
#endif
if (VertexBuffer == null)
{
return;
}
if (Vertices == null || VertexBuffer == null || Vertices.Length < 3 || VertexBuffer.IsDisposed || VertexBuffer.VertexCount < 3)
{
return;
}
device.SetVertexBuffer(VertexBuffer);
if (IndexBuffer != null)
{
device.Indices = IndexBuffer;
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VertexBuffer.VertexCount, 0, IndexBuffer.IndexCount / 3);
}
else
{
device.DrawPrimitives(PrimitiveType.TriangleList, 0, Vertices.Length/3);
}
}
}
示例9: Draw
public static void Draw(Matrix World, Matrix View, Matrix Projection, GraphicsDevice graphics, Matrix world)
{
//World, View, Projection
efeito.World = world;
efeito.View = View;
efeito.Projection = Projection;
//Iluminação
efeito.VertexColorEnabled = true;
//Fog
efeito.FogEnabled = true;
efeito.FogColor = Vector3.Zero;
efeito.FogStart = Camera.nearPlane;
efeito.FogEnd = Camera.farPlaneShort;
//Load the buffer
vertexBuffer.SetData(vertexList);
// Send the vertex buffer to the device
graphics.SetVertexBuffer(vertexBuffer);
foreach (EffectPass pass in efeito.CurrentTechnique.Passes)
{
pass.Apply();
graphics.DrawUserPrimitives(PrimitiveType.LineList, vertexList, 0, 3);
}
}
示例10: RenderToDevice
public override void RenderToDevice(GraphicsDevice device, BasicEffect basicEffet)
{
if (basicEffet.LightingEnabled)
{
// Build the cube, setting up the _vertices array
if (isConstructed == false)
Construct();
// Create the shape buffer and dispose of it to prevent out of memory
using (VertexBuffer buffer = new VertexBuffer(
device,
VertexPositionNormalTexture.VertexDeclaration,
NUM_VERTICES,
BufferUsage.WriteOnly))
{
// Load the buffer
buffer.SetData(_vertices);
// Send the vertex buffer to the device
device.SetVertexBuffer(buffer);
// Draw the primitives from the vertex buffer to the device as triangles
device.DrawPrimitives(PrimitiveType.TriangleList, 0, NUM_TRIANGLES);
}
}
}
示例11: ReadyBuffers
//Set Buffers Onto GPU
public void ReadyBuffers(GraphicsDevice GraphicsDevice)
{
//Set Vertex Buffer
GraphicsDevice.SetVertexBuffer(vb);
//Set Index Buffer
GraphicsDevice.Indices = ib;
}
示例12: draw
public static void draw(GraphicsDevice device)
{
if (vBuffer == null)
{
vBuffer = CreateVertexBuffer(device);
}
device.SetVertexBuffer(vBuffer);
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
示例13: Draw
/// <summary>
/// Draws the specified game time.
/// </summary>
/// <param name="viewMatrix">The view matrix.</param>
/// <param name="projectionMatrix">The projection matrix.</param>
/// <param name="shaderEffect">The shader effect.</param>
/// <param name="graphicsDevice">The graphics device.</param>
public void Draw(Matrix viewMatrix, Matrix projectionMatrix, Effect shaderEffect, GraphicsDevice graphicsDevice)
{
// Kopie der Sichtmatrix erstellen und die Translation
// unberücksichtigt lassen, da der Himmel unendlich erscheinen soll
// unabhängig davon, wo wir uns im Level befinden
Matrix view = viewMatrix;
////oView.Translation = Vector3.Zero;
// Graphics Device zum Rendern der Primitive vorbereiten
////Game1.Instance.GraphicsDevice.VertexDeclaration = this.vertexDeclaration;
graphicsDevice.SetVertexBuffer(vertexBuffer);
// Tiefentest deaktivieren und Schreibschutz des Z-Buffers aktivieren
// Beim Rendern der Sky Box sollen keine Tiefenwerte in den Z-Buffer geschrieben
// werden, denn der Himmel liegt immer hinter allen anderen Objekten
////Game1.Instance.GraphicsDevice.DepthStencilState.DepthBufferEnable = true;
////Game1.Instance.GraphicsDevice.DepthStencilState.DepthBufferWriteEnable = true;
graphicsDevice.DepthStencilState = DepthStencilState.Default;
////shaderEffect.CurrentTechnique = shaderEffect.Techniques["Simplest"];
shaderEffect.Parameters["xWorldViewProjection"].SetValue(Matrix.Identity * viewMatrix * projectionMatrix);
shaderEffect.Parameters["xWorld"].SetValue(Matrix.Identity);
shaderEffect.Parameters["xTexture"].SetValue(this.texture);
// Render States setzen
graphicsDevice.RasterizerState = RasterizerState.CullNone;
////Game1.Instance.GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Mirror;
////Game1.Instance.GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Mirror;
////effect.Begin();
SamplerState samplerState = graphicsDevice.SamplerStates[0];
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
foreach (var pass in shaderEffect.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
}
////effect.End();
////m_oEffect.Texture = m_oLeftTexture;
////this.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 24, 2);
////m_oEffect.Texture = m_oRightTexture;
////this.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 36, 2);
////m_oEffect.Texture = m_oTopTexture;
////this.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 48, 2);
////m_oEffect.CurrentTechnique.Passes[0].End();
// Tiefentest wieder aktivieren und Schreibschutz entfernen
////Game1.Instance.GraphicsDevice.DepthStencilState.DepthBufferEnable = true;
////Game1.Instance.GraphicsDevice.DepthStencilState.DepthBufferWriteEnable = true;
}
示例14: Draw
internal void Draw(Texture2D[] textures, GraphicsDevice device, BasicEffect effect, EffectPass pass)
{
effect.World = displayObject.WorldTransform;
effect.Texture = textures[displayObject.TextureIndex];
device.SetVertexBuffer(vertexBuffer);
device.Indices = indexBuffer;
pass.Apply();
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3);
}
示例15: RenderWireframe
/// <summary>
/// Draws the primitive to the screen.
/// </summary>
/// <param name="device">GPU to draw with.</param>
public virtual void RenderWireframe(GraphicsDevice device)
{
RasterizerState state = new RasterizerState();
RasterizerState oldState = device.RasterizerState;
state.FillMode = FillMode.WireFrame;
device.RasterizerState = state;
device.SetVertexBuffer(m_vertexBuffer);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_vertices.Length / 3);
device.RasterizerState = oldState;
}