本文整理汇总了C#中Sprite.End方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.End方法的具体用法?C# Sprite.End怎么用?C# Sprite.End使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.End方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Device device;
SwapChain swapChain;
RenderTargetView renderTarget;
EmptyWindow.CreateDeviceSwapChainAndRenderTarget(mForm, out device, out swapChain, out renderTarget);
// buffer size 1 .. 4096 (0 defaults to 4096)
var sprite = new Sprite(device, 10);
var font = new Font(device, 20, "ARIAL");
Application.Idle +=
delegate
{
device.ClearRenderTargetView(renderTarget, new Color4(1, 0, 0));
var rectangle = new Rectangle(10, 10, 400, 300);
sprite.Begin(SpriteFlags.None);
font.Draw(sprite, "Hello from SlimDX", rectangle, FontDrawFlags.Left,
(uint)Color.Yellow.ToArgb());
sprite.End();
swapChain.Present(0, PresentFlags.None);
Application.DoEvents();
};
Application.Run(mForm);
}
示例2: OnPaint
protected override void OnPaint(PaintEventArgs pe)
{
if ((this.m_FormRenderFrame.Device != null) && (this.m_FormRenderFrame.Texture != null) && (this.Visible) && (this.WindowState != FormWindowState.Minimized)) {
try {
this.m_FormRenderFrame.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1F, 0);
SurfaceDescription surfaceDescription = this.m_FormRenderFrame.Texture.GetLevelDescription(0);
Size size = new Size(surfaceDescription.Width, surfaceDescription.Height);
Size targetSize = new Size(Math.Max(1, (Int32)((Single)size.Width * this.m_ZoomFactor)), Math.Max(1, (Int32)((Single)size.Height * this.m_ZoomFactor)));
if (this.Size != targetSize) {
this.Size = targetSize;
}
this.m_FormRenderFrame.Device.BeginScene();
Sprite sprite = new Sprite(this.m_FormRenderFrame.Device);
sprite.Begin(SpriteFlags.None);
sprite.Draw2D(this.m_FormRenderFrame.Texture, new Rectangle(new Point(0, 0), size), new SizeF(((Single)size.Width * this.m_ZoomFactor), ((Single)size.Height * this.m_ZoomFactor)), new PointF(0F, 0F), Color.FromArgb(255, 255, 255, 255));
sprite.End();
sprite.Dispose();
this.m_FormRenderFrame.Device.EndScene();
this.m_FormRenderFrame.Device.Present();
} catch {
}
}
}
示例3: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
spritePosition = new Vector3(200f, 200f, 0f);
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0);
device.BeginScene();
using (Sprite sprite = new Sprite(device)) {
sprite.Begin(SpriteFlags.AlphaBlend);
//render sprites here
sprite.End();
}
device.EndScene();
device.Present();
this.Invalidate();
}
示例4: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
spritePosition = new Vector3(200f, 200f, 0f);
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0);
device.BeginScene();
using (Sprite sprite = new Sprite(device))
{
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw(tileSet.Texture, tilePosition, spriteCenter, spritePosition,
Color.FromArgb(255,255,255,255));
sprite.End();
}
device.EndScene();
device.Present();
this.Invalidate();
}
示例5: TextureViewer_Load
void TextureViewer_Load(object sender, EventArgs e)
{
this.Show();
Application.DoEvents();
pp = new PresentParameters();
pp.BackBufferCount = 2;
pp.SwapEffect = SwapEffect.Discard;
pp.Windowed = true;
Direct3D d3d = new Direct3D();
d3d_device = new Device(d3d, 0, DeviceType.Hardware, d3dPanel.Handle, CreateFlags.HardwareVertexProcessing, pp);
texture = Texture.FromFile(d3d_device, texturePath);
int texWidth = texture.GetLevelDescription(0).Width;
int texHeight = texture.GetLevelDescription(0).Height;
d3dPanel.Top = menuStrip1.Height;
d3dPanel.Left = 0;
d3dPanel.ClientSize = new Size(texWidth, texHeight);
this.ClientSize = new System.Drawing.Size(
d3dPanel.Width,
d3dPanel.Height + menuStrip1.Height
);
pp.BackBufferWidth = texWidth;
pp.BackBufferHeight = texHeight;
d3d_device.Reset(pp);
sprite = new Sprite(d3d_device);
while (this.Visible)
{
d3d_device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, new Color4(Color.Black), 1.0f, 0);
d3d_device.BeginScene();
sprite.Begin(SpriteFlags.AlphaBlend);
Rectangle rect = new Rectangle()
{
X = 0,
Y = 0,
Width = texture.GetLevelDescription(0).Width,
Height = texture.GetLevelDescription(0).Height
};
sprite.Draw(texture, rect, new Color4(Color.White));
sprite.End();
d3d_device.EndScene();
d3d_device.Present();
Application.DoEvents();
}
}
示例6: DrawOverlay
public void DrawOverlay(Surface targetSurface)
{
Texture subTexture;
Subtitle currentSubtitle;
lock (_syncObj)
{
currentSubtitle = _currentSubtitle;
subTexture = _subTexture;
// Available sub is not due
if (currentSubtitle == null || !currentSubtitle.ShouldDraw)
return;
if (targetSurface == null || targetSurface.Disposed || subTexture == null)
{
if (_drawCount > 0)
ServiceRegistration.Get<ILogger>().Debug("Draw count for last sub: {0}", _drawCount);
_drawCount = 0;
return;
}
_drawCount++;
}
try
{
if (!subTexture.Disposed)
{
// TemporaryRenderTarget changes RenderTarget to texture and restores settings when done (Dispose)
using (new TemporaryRenderTarget(targetSurface))
using (TemporaryRenderState temporaryRenderState = new TemporaryRenderState())
using (Sprite sprite = new Sprite(_device))
{
sprite.Begin(SpriteFlags.AlphaBlend);
// No alpha test here, allow all values
temporaryRenderState.SetTemporaryRenderState(RenderState.AlphaTestEnable, 0);
// Use the SourceAlpha channel and InverseSourceAlpha for destination
temporaryRenderState.SetTemporaryRenderState(RenderState.BlendOperation, (int) BlendOperation.Add);
temporaryRenderState.SetTemporaryRenderState(RenderState.SourceBlend, (int) Blend.SourceAlpha);
temporaryRenderState.SetTemporaryRenderState(RenderState.DestinationBlend, (int) Blend.InverseSourceAlpha);
// Check the target texture dimensions and adjust scaling and translation
SurfaceDescription desc = targetSurface.Description;
Matrix transform = Matrix.Identity;
transform *= Matrix.Translation(currentSubtitle.HorizontalPosition, currentSubtitle.FirstScanLine, 0);
// Subtitle could be smaller for 16:9 anamorphic video (subtitle width: 720, video texture: 1024)
// then we need to scale the subtitle width also.
if (currentSubtitle.ScreenWidth != desc.Width)
transform *= Matrix.Scaling((float) desc.Width / currentSubtitle.ScreenWidth, 1, 1);
sprite.Transform = transform;
sprite.Draw(subTexture, Color.White);
sprite.End();
}
}
}
catch (Exception ex)
{
ServiceRegistration.Get<ILogger>().Debug("Error in DrawOverlay", ex);
}
if (_onTextureInvalidated != null)
_onTextureInvalidated();
}
示例7: RenderScene
/// <summary>
/// Renders the scene.
/// </summary>
public void RenderScene(Color background, List<LightObj> lights, Camera camera)
{
bool useGlow = false;
// Sets the variables for the shader.
SetVariables(lights, camera);
//effect.Technique = "Test";
for (int i = 0; i < mesh.Count; i++)
{
if (mesh[i].Emissive.Enable && !mesh[i].Emissive.Path.Equals(""))
{
useGlow = true;
break;
}
}
// If/Else statement to control rendering with emissive glow or not.
if (useGlow)
RenderGlow();
else
BeginRender(background);
// If emissive glow is used, the base scene is rendered to a texture.
if (useGlow)
{
surfRender.BeginScene(renderedScene.GetSurfaceLevel(0), device.Viewport);
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, background, 1.0f, 0);
}
if (groundPlane.Enabled)
RenderModel((Model)groundPlane, lights[0].Shadows, 0);
// Loops through all the models and renders each.
for (int i = 0; i < mesh.Count; i++)
{
if (mesh[i].Enabled)
RenderModel(mesh[i], lights[0].Shadows, 0);
}
if (showLights)
{
using (Sprite spriteobject = new Sprite(device))
{
foreach (LightObj light in lights)
{
if (!light.Enabled)
continue;
spriteobject.SetWorldViewRH(device.Transform.World, device.Transform.View);
spriteobject.Begin(SpriteFlags.AlphaBlend | SpriteFlags.Billboard | SpriteFlags.SortTexture | SpriteFlags.ObjectSpace);
//spriteobject.Transform = Matrix.Scaling(0.25f, 0.25f, 0.25f);
spriteobject.Draw(lightTexture, Rectangle.Empty, Vector3.Empty, light.Direction, Color.White);
spriteobject.End();
}
}
}
// If emissive glow is used, the textures are set to the shader and rendered to a sprite.
if (useGlow)
{
surfRender.EndScene(Filter.None);
effect.SetValue("renderedScene", renderedScene);
BeginRender(background);
using (Sprite spriteobject = new Sprite(device))
{
prevTechnique = effect.Technique;
effect.Technique = "Bloom";
effect.Begin(FX.None);
spriteobject.Begin(SpriteFlags.None);
effect.BeginPass(0);
spriteobject.Draw(renderedGlow, Rectangle.Empty, new Vector3(0, 0, 0), new Vector3(0, 0, 0), Color.White);
effect.EndPass();
spriteobject.End();
effect.End();
effect.Technique = prevTechnique;
}
}
EndRender();
}
示例8: drawRadar
/// <summary>
/// Draws the radar.
/// </summary>
public void drawRadar()
{
using (Sprite s = new Sprite(device))
{
s.Begin(SpriteFlags.AlphaBlend);
Point playerP = new Point((int)player.Location.X + radarPoint.X,
(int)player.Location.Z + radarPoint.Y);
s.Draw2D(ContentLoader.Radar, Rectangle.Empty, new Size((int)(playerP.X * 2), (int)((this.height-playerP.Y) * 2)),
new Point(0, (int)(this.height - (this.height - playerP.Y) * 2)), Color.White);
s.Draw2D(this.radarEnemyTexture, Rectangle.Empty,
this.enemySize, playerP, Color.LightSkyBlue);
s.Draw2D(ContentLoader.GUIBack, Rectangle.Empty, new Size((int)(this.width * 0.15f), 120),
new Point(0, 0), Color.White);
foreach (Enemy e in enemies)
{
Point point = new Point(
(int)(radarPoint.X + e.Location.X * Math.Cos(player.Head.Rotation.X) - e.Location.Z * Math.Sin(player.Head.Rotation.X)),
(int)(radarPoint.Y - e.Location.X * Math.Sin(player.Head.Rotation.X) - e.Location.Z * Math.Cos(player.Head.Rotation.X)));
s.Draw2D(this.radarEnemyTexture, Rectangle.Empty,
this.enemySize, point, Color.Red);
}
s.End();
}
}
示例9: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
deltaTime = hrt.ElapsedTime;
UpdateSprite(deltaTime);
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0);
device.BeginScene();
using (Sprite sprite = new Sprite(device)) {
sprite.Begin(SpriteFlags.None);
//Set rotation center for sprite
spriteCenter.X = spritePosition.X + tileSet.ExtentX;
spriteCenter.Y = spritePosition.Y + tileSet.ExtentY;
//Spin, Shift, Stretch :-)
sprite.Transform = Matrix.RotationZ(angle) * Matrix.Translation(spriteCenter);
sprite.Draw(tileSet.Texture, tilePosition, spriteCenter, spritePosition,
Color.FromArgb(255,255,255,255));
sprite.End();
}
device.EndScene();
device.Present();
this.Invalidate();
}
示例10: Draw
public void Draw( Sprite sprite, int grid_size )
{
if (m_file_texture != null)
{
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw2D(m_file_texture, m_source, new Rectangle(0, 0, grid_size, grid_size), new Point((int)((float)m_location.X * ((float)grid_size / ((float)grid_size / (float)m_source.Width))),
(int)(float)(m_location.Y * ((float)grid_size / ((float)grid_size / (float)m_source.Height)))), Color.White);
sprite.End();
}
}
示例11: drawImage2d
public void drawImage2d(Device i_dev,int i_x,int i_y,INyARRgbRaster i_raster)
{
NyARIntSize s = i_raster.getSize();
if (this._texture == null)
{
this._texture=new NyARD3dTexture(i_dev,s.w,s.h);
}
else if (!this._texture.isEqualSize(s))
{
this._texture.Dispose();
this._texture = new NyARD3dTexture(i_dev, s.w, s.h);
}
this._texture.setRaster(i_raster);
using (Sprite sp = new Sprite(i_dev))
{
sp.Begin(SpriteFlags.None);
sp.Draw((Texture)this._texture, new Rectangle(i_x,i_y, s.w,s.h), Vector3.Empty,new Vector3(i_dev.Viewport.X, i_dev.Viewport.Y, 0),Color.White);
sp.End();
}
}
示例12: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
try
{
RenderIntoSurface();
m_d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, m_clBackColor , 1.0f, 0);
SetupCamera();
m_d3dDevice.BeginScene();
if(this.Editor != null && this.Editor.PhysicalStructure != null && m_d3dDevice != null)
if(Editor.PhysicalStructure.RootBody != null)
{
RigidBodies.RigidBody_DX rbRoot = (RigidBodies.RigidBody_DX)Editor.PhysicalStructure.RootBody;
if(rbRoot.Device == null || m_bReset)
{
rbRoot.InitDevice(m_d3dDevice);
m_bReset = false;
this.Invalidate();
}
else
Editor.PhysicalStructure.Draw(Editor.CommandBar.CommandMode);
}
using (Sprite s = new Sprite(m_d3dDevice))
{
//save the renderTexture to a graphics stream
//gsStream = TextureLoader.SaveToStream(ImageFileFormat.Dds, renderTexture);
//load the renderTexture to a texture object with a color key for transparency
//texTransBillBoard = TextureLoader.FromStream(Device,gsStream,0,0,1,Usage.None,Format.Unknown,Pool.Managed,Filter.None, Filter.None,Color.Black.ToArgb());
//Draw the texture
s.Begin(SpriteFlags.None);
s.Draw(renderTexture, new Rectangle(0,0, RenderSurfaceSize, RenderSurfaceSize), new Vector3(), new Vector3(0,0,0.0f), Color.White);
s.End();
}
m_d3dDevice.EndScene();
m_d3dDevice.Present(this);
}
catch(Microsoft.DirectX.Direct3D.DeviceLostException)
{
try
{
m_d3dDevice.Reset(m_ppPresentParams);
this.Invalidate();
}
catch (DeviceLostException)
{
// If it's still lost or lost again, just do nothing
}
}
catch(Exception ex)
{
Util.Logger.LogMsg(AnimatTools.Interfaces.Logger.enumLogLevel.Error, Util.GetErrorDetails("", ex));
if(Editor.PhysicalStructure.RootBody == null)
return;
}
}
示例13: Render
/// <summary>
/// Render the panel. This base class method renders all the widgets
/// (using their current frame). Subclasses may override this
/// to add code for writing text and other UI components as well.
/// </summary>
public void Render()
{
// --------------------- Set Renderstate ------------------
// Set ALL that we care about and rem out the others.
// If I add any here, add them to ALL renderable classes
//*** world matrix ***
//Engine.Device.Transform.World = Matrix.Identity; // Matrix is fixed at 0,0,0
//*** expected vertex format ***
//Engine.Device.VertexFormat = CustomVertex.PositionNormalTextured.Format; // Textured objects
//Engine.Device.VertexFormat = CustomVertex.PositionNormalColored.Format; // Vertex-coloured objects
//*** material ***
//Engine.Device.Material = material;
//*** Once-only texture settings ***
//Engine.Device.SetTexture(0,texture); // Use this texture for all primitives
//Engine.Device.SetTexture(0,null); // Use no texture at all (material-only objects)
//Engine.Device.SamplerState[0].MagFilter = TextureFilter.None; // (texel smoothing option)
//Engine.Device.SamplerState[0].MagFilter = TextureFilter.Linear; // (texel smoothing option)
//Engine.Device.SamplerState[0].AddressU = TextureAddress.Mirror; // Texture mirroring required
//Engine.Device.SamplerState[0].AddressV = TextureAddress.Mirror; // ditto in V direction
//*** Transparency settings ***
//Engine.Device.RenderState.AlphaBlendEnable = true; // enable/disable transparency)
// Vector alpha...
//Engine.Device.RenderState.DiffuseMaterialSource = ColorSource.Color1;
// Material alpha...
// Engine.Device.RenderState.DiffuseMaterialSource = ColorSource.Material;
// Engine.Device.RenderState.SourceBlend = Blend.SourceAlpha; // Source blend
// Engine.Device.RenderState.DestinationBlend = Blend.InvSourceAlpha; // Dest blend
// Texture alpha...
//Engine.Device.TextureState[0].ColorOperation = TextureOperation.Modulate; // Use the following for texture transp
//Engine.Device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
//Engine.Device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
//Engine.Device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
//Engine.Device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
//Engine.Device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;
//*** depth buffering ***
Engine.Device.RenderState.ZBufferEnable = false; // ZBuffer
//*** lighting ***
Engine.Device.RenderState.Lighting = false; // enabled
Engine.Device.RenderState.SpecularEnable = false; // Specular lighting
// --------------------------------------------------------
// Draw all the widgets...
Sprite sprite; // we only need one sprite
using (sprite=new Sprite(Engine.Device))
{
sprite.Begin(SpriteFlags.AlphaBlend);
for (int s=0; s<widgetList.Count; s++)
{
widgetList[s].Draw(sprite); // draw the current anim frame
}
sprite.End();
}
}
示例14: drawHealth
/// <summary>
/// Draws the given texture to the given point on the screen.
/// </summary>
/// <param name="texture">The texture to draw.</param>
/// <param name="point">Where to display the texture on the screen.</param>
/// <param name="scale">The amount to scale the x value of the Sprite.</param>
public void drawHealth(Texture texture, Point point, float scale)
{
Size healthSize = new Size((int)((this.width * 0.288f) * scale),
(int)(this.height * 0.060));
this.healthBarSize = new Size((int)(this.width * 0.530f),
(int)(this.height * 0.24));
using (Sprite s = new Sprite(device))
{
Point newPoint = new Point((int)(this.width * 0.0344) + point.X,
(int)(this.height * 0.0736) + point.Y);
Size healthBack = new Size((int)(this.width-(this.width-newPoint.X+30)),
(int)(this.height * 0.120));
s.Begin(SpriteFlags.AlphaBlend);
s.Draw2D(ContentLoader.GUIBack, Rectangle.Empty,
healthBack, new Point(newPoint.X-30, 0), Color.White);
s.Draw2D(healthTexture, new Rectangle(point, healthSize),
healthSize, newPoint, Color.Red);
s.Draw2D(texture, Rectangle.Empty, healthBarSize, point, Color.Black);
s.End();
}
}
示例15: DrawInfo
/// <summary>
/// Draw the player information.
/// </summary>
/// <param name="device">The direct3D device.</param>
private void DrawInfo(Device device)
{
try
{
int deviceWidth = device.Viewport.Width;
int deviceHeight = device.Viewport.Height;
long frameCounter = _memory.GetFrameCount();
if (frameCounter > 10)
{
if (string.IsNullOrEmpty(_playerOneName))
{
_playerOneName = _memory.GetCharacter(1);
}
if (string.IsNullOrEmpty(_playerTwoName))
{
_playerTwoName = _memory.GetCharacter(2);
}
_sprite = new Sprite(_device);
_sprite.Begin(SpriteFlags.AlphaBlend);
_sprite.Transform
= Matrix.Scaling(new Vector3(_fontSize / (12 / 2), _fontSize / (7 / 2), 0));
_spritePosition = new Vector2(
_fontSize,
(deviceHeight / _fontSize) * 7);
_sprite.Draw(_background, new Vector3(1, 1, 0), new Vector3(_spritePosition, -1), Color.White);
_spritePosition = new Vector2(
deviceWidth - (_fontSize * 13),
(deviceHeight / _fontSize) * 7);
_sprite.Draw(_background, new Vector3(1, 1, 0), new Vector3(_spritePosition, -1), Color.White);
_sprite.End();
_sprite.Dispose();
_sprite = new Sprite(_device);
_sprite.Begin(SpriteFlags.AlphaBlend);
// P1
string playerOneHeader = string.Format("-{0}'s STATS-", _playerOneName);
string playerOnePos = string.Format(
"[{0},{1}]",
_memory.GetPosX(1).ToString("F3"),
_memory.GetPosY(1).ToString("F3"));
string playerOneHealth = string.Format("HP : {0}", _memory.GetHealth(1));
string playerOneStun = string.Format("STUN : {0}", _memory.GetStun(1));
string playerOneEx = string.Format("EX : {0}", _memory.GetEXmeter(1));
string playerOneUltra = string.Format("ULTRA : {0}", _memory.GetUltraMeter(1));
string playerOneScript = string.Format(
"ANIM : {0} ({1})",
_memory.PlayerAnim(1),
_memory.GetAnimFrame(1));
int playerOneInterruptFrame = _memory.GetInterruptFrame(1);
string playerOneInterrupt = string.Format("INTRPT: {0}", playerOneInterruptFrame);
// P2
string playerTwoHeader = string.Format("-{0}'s STATS-", _playerTwoName);
string playerTwoPos = string.Format(
"[{0},{1}]",
_memory.GetPosX(2).ToString("F3"),
_memory.GetPosY(2).ToString("F3"));
string playerTwoHealth = string.Format("HP : {0}", _memory.GetHealth(2));
string playerTwoStun = string.Format("STUN : {0}", _memory.GetStun(2));
string playerTwoEx = string.Format("EX : {0}", _memory.GetEXmeter(2));
string playerTwoUltra = string.Format("ULTRA : {0}", _memory.GetUltraMeter(2));
string playerTwoScript = string.Format(
"ANIM : {0} ({1})",
_memory.PlayerAnim(2),
_memory.GetAnimFrame(2));
int playerTwoInterruptFrame = _memory.GetInterruptFrame(2);
string playerTwoInterrupt = string.Format("INTRPT: {0}", playerTwoInterruptFrame);
string playerOneAdv = string.Format("ADV : {0}", playerOneInterruptFrame - playerTwoInterruptFrame);
string playerTwoAdv = string.Format("ADV : {0}", playerTwoInterruptFrame - playerOneInterruptFrame);
string playerOneStats = string.Join(
"\n",
playerOneHeader,
playerOnePos,
playerOneHealth,
playerOneStun,
playerOneEx,
playerOneUltra,
playerOneScript,
playerOneInterrupt,
playerOneAdv);
string playerTwoStats = string.Join(
"\n",
playerTwoHeader,
//.........这里部分代码省略.........