public RenderContainer(SwapChainDescription swapChainDescription, RenderControl control) { try { _swapChainDescription = swapChainDescription; using (Factory1 factory = new Factory1()) using (Adapter adapter = factory.GetAdapter(0)) { Device11 = new Dx11ChainedDevice(adapter, _swapChainDescription); Device10 = new Dx10Device(adapter); } GraphicsDevice = new GenericGraphicsDevice(Device11.Device); SpriteBatch = new SpriteBatch(GraphicsDevice); Reset(control.Width, control.Height); control.Resize += OnRenderControlResize; } catch { Dispose(); throw; } }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, int x, int y, Rectangle destinationRect) { base.Draw(gameTime, spriteBatch, x, y, destinationRect); if (x != X || y != Y) throw new ArgumentException("Wrong coordinate"); Draw(gameTime, spriteBatch, destinationRect); }
public static void DrawRectangle(SpriteBatch spriteBatch, Rectangle rect, Color color) { spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X, rect.Y, rect.Width, 1), color); spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X, rect.Y, 1, rect.Height), color); spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X, rect.Y + rect.Height, rect.Width, 1), color); spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X + rect.Width, rect.Y, 1, rect.Height), color); }
public ShadowMap( VisionContent vContent, int width, int height, int nearPlane = 1, int farPlane = 200) { _graphicsDevice = vContent.GraphicsDevice; ShadowDepthTarget = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float); DepthStencilTarget = DepthStencilBuffer.New(_graphicsDevice, width, height, DepthFormat.Depth16); _spriteBatch = new SpriteBatch(_graphicsDevice); _shadowBlurEffect = vContent.LoadEffect("Effects/Blur"); _shadowBlurEffect.Parameters["dx"].SetValue(1f/width); _shadowBlurEffect.Parameters["dy"].SetValue(1f/height); _shadowBlurTarg = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float); ShadowNearPlane = nearPlane; ShadowFarPlane = farPlane; Camera = new Camera( new Vector2(width, height), Vector3.Zero, Vector3.Up, ShadowNearPlane, ShadowFarPlane); UpdateProjection(60, 60); }
public Signs( VisionContent vContent, Matrix world, Texture2D texture, List<VisionClass> vclasses, float width, float height) : base(vContent, world, texture, width, height, 0) { _signTextEffect = vContent.LoadEffect("effects/signtexteffect"); _spriteBatch = new SpriteBatch(Effect.GraphicsDevice); _spriteFont = vContent.Load<SpriteFont>("fonts/BlackCastle"); _vclasses = vclasses; foreach (var vc in vclasses) { vc.GroundBoundingSphere = new BoundingSphere( vc.Position + world.TranslationVector, vc.R); vc.SignClickBoundingSphere = new BoundingSphere( vc.Position + world.TranslationVector + new Vector3(0, TextDistanceAboveGround - 2, 0), 2); } AddPositionsWithSameNormal(Vector3.Up, vclasses.Select(vc => vc.Position - world.TranslationVector).ToArray()); CreateVertices(false); }
public void Draw(SpriteBatch _spriteBatch, GameTime gameTime) { foreach (Entity e in entities) { e.Render(_spriteBatch); } }
protected override void LoadContent() { // Instantiate a SpriteBatch spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice)); // Loads a sprite font // The [Arial16.xml] file is defined with the build action [ToolkitFont] in the project arial16Font = Content.Load<SpriteFont>("Arial16"); // Creates a basic effect basicEffect = ToDisposeContent(new BasicEffect(GraphicsDevice)); basicEffect.DiffuseColor = Color.OrangeRed.ToVector4(); basicEffect.PreferPerPixelLighting = true; basicEffect.EnableDefaultLighting(); // Creates torus primitive sphere = ToDisposeContent(GeometricPrimitive.Sphere.New(GraphicsDevice, 1.75f)); pixelTexture = Texture2D.New(GraphicsDevice, 1, 1, GraphicsDevice.BackBuffer.Format); pixelTexture.SetData<Color>(new Color[] { Color.Green }); occlusionQuery = new OcclusionQuery(GraphicsDevice); offscreenBuffer = RenderTarget2D.New(GraphicsDevice, 128, 128, GraphicsDevice.BackBuffer.Format); base.LoadContent(); }
public FloatingTexts(VisionContent vcontent, SpriteBatch spriteBatch, SpriteFont font) : base(vcontent.LoadEffect("effects/signtexteffect")) { VContent = vcontent; SpriteBatch = spriteBatch; Font = font; }
public ShadowMap( VisionContent vContent, Camera camera, int width, int height, int nearPlane = 1, int farPlane = 200) { _graphicsDevice = vContent.GraphicsDevice; RealCamera = camera; ShadowDepthTarget = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float); _spriteBatch = new SpriteBatch(_graphicsDevice); _shadowBlurEffect = vContent.LoadPlainEffect("ShadowEffects/Blur"); _shadowBlurTarg = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float); ShadowNearPlane = nearPlane; ShadowFarPlane = farPlane; Camera = new Camera( new Vector2(width, height), Vector3.Zero, Vector3.Up, ShadowNearPlane, ShadowFarPlane); UpdateProjection(50, 50); }
public virtual void Draw(GameTime gameTime, bool isInForeground, SpriteBatch spriteBatch) { if (State == States.Opening) OpeningTransition.Update(gameTime); else if (State == States.Closing) ClosingTransition.Update(gameTime); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); spriteFont = Content.Load<SpriteFont>("Arial16"); image = Content.Load<Texture2D>("background"); base.LoadContent(); }
private void DrawSprites(Device device, SpriteBatch spritebatch, Rectangle cliprectangle) { try { DxTexture texture = _texture; if (texture == null) return; spritebatch.Begin(); try { int width = Math.Min(texture.Descriptor2D.Width, cliprectangle.Width); int height = Math.Min(texture.Descriptor2D.Height, cliprectangle.Height); Rectangle rectangle = new Rectangle(cliprectangle.X, cliprectangle.Y, width, height); texture.Draw(device, spritebatch, Vector2.Zero, rectangle, 1.0f); } finally { spritebatch.End(); } } catch (Exception ex) { Log.Error(ex); } }
public SimpleText(GraphicsDevice device, string fontFilename) { this.device = device; this.graphicsDevice = device; this.spriteFont = SpriteFont.Load(graphicsDevice, fontFilename); var sfd = SpriteFontData.Load(fontFilename); this.spriteBatch = new SpriteBatch(graphicsDevice); }
/// <summary> /// Create a batch manager for drawing text and sprite /// </summary> /// <param name="device">Device pointer</param> /// <param name="filename">Path of the font file</param> public SharpBatch(SharpDevice device, string filename) { Device = device; GraphicsDevice = GraphicsDevice.New(Device.Device); GraphicsDevice.SetViewports(Device.DeviceContext.Rasterizer.GetViewports()[0]); Batch = new SpriteBatch(GraphicsDevice); Font = SpriteFont.Load(GraphicsDevice, filename); }
protected override void LoadContent() { base.LoadContent(); spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice)); texture = Content.Load<Texture2D>("Input"); customEffect = Content.Load<Effect>("Effect"); }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { base.Draw(gameTime, spriteBatch); spriteBatch.Draw(Sprite.Sheet.Texture, DestinationRect, Sprite.SourceRect, Color.White); if (List.Count > CurrentIndex) spriteBatch.DrawString(font, List[CurrentIndex], new Vector2(DestinationRect.X, DestinationRect.Y), Color.White); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); ring.LoadContent(Content); base.LoadContent(); }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { base.Draw(gameTime, spriteBatch); spriteBatch.Draw(Sprites[(int)CurrentState].Sheet.Texture, DestinationRect, Sprites[(int)CurrentState].SourceRect, Color.White); if (Text != "") spriteBatch.DrawString(font, Text, new Vector2(DestinationRect.X, DestinationRect.Y), Color.White); }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { base.Draw(gameTime, spriteBatch); Sprite s = Sprites[IsSelected ? 1 : 0]; spriteBatch.Draw(s.Sheet.Texture, DestinationRect, s.SourceRect, Color.White); if (Text != "") spriteBatch.DrawString(font, Text, new Vector2(DestinationRect.X, DestinationRect.Y), Color.White); }
public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); RectangleF clip; RectangleF destRect = Bounds; Rectangle? sourceRect = null; if (HasClip(out clip)) { RectangleF inter = RectangleF.Empty; inter.Left = Math.Max(clip.Left, destRect.Left); inter.Top = Math.Max(clip.Top, destRect.Top); inter.Right = Math.Min(clip.Right, destRect.Right); inter.Bottom = Math.Min(clip.Bottom, destRect.Bottom); float leftClip = inter.Left - DrawPosition.X; float rightClip = inter.Right - (DrawPosition.X + Width); float topClip = inter.Top - DrawPosition.Y; float bottomClip = inter.Bottom - (DrawPosition.Y + Height); float clippedWidth = rightClip - leftClip; float clippedHeight = bottomClip - topClip; Rectangle source = Rectangle.Empty; source.X = (int)leftClip; source.Y = (int)topClip; source.Width = (int)(Width + clippedWidth); source.Height = (int)(Height + clippedHeight); sourceRect = source; destRect.X += leftClip; destRect.Y += topClip; destRect.Width = Math.Max(destRect.Width + clippedWidth, 0); destRect.Height = Math.Max(destRect.Height + clippedHeight, 0); if (UIManager.DrawDebug) { PRect rect = new PRect(clip, 1); rect.Color = Color.Yellow; rect.Draw(); rect = new PRect(inter, 1); rect.Color = Color.Magenta; rect.Draw(); } //int rC = (int)( inter.Right - ( DrawPosition.X + Width ) - location.X + location.X); //int lC = (int)( location.X + inter.Left - DrawPosition.X - location.X ); //int bC = (int)( location.Y + inter.Bottom - ( DrawPosition.Y + Height ) - location.Y ); //int tC = (int)( location.Y + inter.Top - DrawPosition.Y - location.Y ); } spriteBatch.Draw(texture, destRect, sourceRect, Color, 0f, Vector2.Zero, SpriteEffect, LayerDepth); }
public override void Draw(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch) { base.Draw(graphicsDevice, spriteBatch); foreach (Projectile p in projectiles) { p.Draw(graphicsDevice); } spriteBatch.Draw(loadBarBack, new Vector2(200, 0), Color.White); spriteBatch.Draw(loadBar, new RectangleF(205, 5, (timer/3000) * 250, 25), Color.White); spriteBatch.Draw(currentSphere, new Vector2(635, 5), Color.White); }
protected override void LoadContent() { loadedMyData = Content.Load<MyData>("MyData.yml"); Window.Title = string.Format("Yaml Data Loading: [{0}]", loadedMyData.Name); // Instantiate a SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice); base.LoadContent(); }
protected override void Initialize() { base.Initialize(); spriteBatch = new SpriteBatch(GraphicsDevice); Canvas.Engine = this; RootCanvas = new Canvas(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height); program.Engine = this; program.Setup(); }
protected override void LoadContent() { // SpriteFont supports the following font file format: // - DirectX Toolkit MakeSpriteFont or SharpDX Toolkit tkfont // - BMFont from Angelcode http://www.angelcode.com/products/bmfont/ arial16BMFont = Content.Load<SpriteFont>("Arial16"); // Instantiate a SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice); base.LoadContent(); }
public void Draw(Device device, SpriteBatch spriteBatch, Vector2 position, Rectangle? sourceRectangle, float layerDepth) { ShaderResourceView shaderView = GetShaderResourceView(device); spriteBatch.Draw(shaderView, position, sourceRectangle, new Color(0xff, 0xff, 0xff, 0xff), 0, Vector2.Zero, Vector2.One, SpriteEffects.None, layerDepth); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Rectangle destinationRect, Color color, float depth = 0.5f, SpriteEffects spriteEffects = SpriteEffects.None) { if (Animation == null) throw new NotSupportedException("No animation is currently playing."); SimulateTime(gameTime); if (CurrentSprite != null) spriteBatch.Draw(CurrentSprite.Sheet.Texture, destinationRect, Animation.Sprites[FrameIndex].SourceRect, color, 0.0f, Vector2.Zero, spriteEffects, depth); }
internal void Draw(SpriteBatch sb, Vector2 offset) { if (_tex != null && _tex.IsLoaded) { var pos3 = Owner.Transform.Translation; var pos = new Vector2(pos3.X, pos3.Y) + offset; var scale = Owner.Transform.Scale; var rot = Owner.Transform.Rotation; var tex = _tex.Texture2D.ShaderResourceView[ViewType.Full, 0, 0]; sb.Draw(tex, pos, SourceRegion, Color.White, rot, Origin, scale, SpriteEffects.None, pos3.Z); } }
protected override void LoadContent() { // Loads the balls texture (32 textures (32x32) stored vertically => 32 x 1024 ). ballsTexture = Content.Load<Texture2D>("balls.dds"); // SpriteFont supports the following font file format: // - DirectX Toolkit MakeSpriteFont or SharpDX Toolkit tkfont // - BMFont from Angelcode http://www.angelcode.com/products/bmfont/ arial16BMFont = Content.Load<SpriteFont>("Arial16.tkfnt"); // Instantiate a SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice); }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { base.Draw(gameTime, spriteBatch); if (Background != null) spriteBatch.Draw(Background.Sheet.Texture, DestinationRect, Background.SourceRect, Color.White); foreach (Control control in SubControls.Values) { if (DestinationRect.Contains(control.DestinationRect)) control.Draw(gameTime, spriteBatch); } }
public void Draw(SpriteBatch spriteBatch) { var topRot = MathUtil.Pi * splitRatio; var bottomRot = MathUtil.Pi * (1.0f - splitRatio); var topPos = origin + new Vector2((float)-Math.Cos(topRot), (float)-Math.Sin(topRot)) * radius; var bottomPos = origin + new Vector2((float)-Math.Cos(topRot), (float)Math.Sin(topRot)) * radius; // draw "top" separator spriteBatch.Draw(separatorTexture, topPos, null, Color.White, topRot, separatorOrigin, scale, SpriteEffects.None, 0); // draw "bottom" separator spriteBatch.Draw(separatorTexture, bottomPos, null, Color.White, bottomRot, separatorOrigin, scale, SpriteEffects.FlipHorizontally, 0); }