/// <summary> /// Constructor /// </summary> /// <param name="scene">Scene</param> /// <param name="description">Description</param> public Sprite(Scene scene, SpriteDescription description) : base(scene, description) { this.Textured = description.Textures != null && description.Textures.Length > 0; this.InitializeBuffers(description.Name, this.Textured, description.UVMap); if (this.Textured) { this.InitializeTexture(description.ContentPath, description.Textures); } this.renderWidth = this.Game.Form.RenderWidth.NextPair(); this.renderHeight = this.Game.Form.RenderHeight.NextPair(); this.sourceWidth = description.Width <= 0 ? this.renderWidth : description.Width.NextPair(); this.sourceHeight = description.Height <= 0 ? this.renderHeight : description.Height.NextPair(); this.viewProjection = Sprite.CreateViewOrthoProjection(this.renderWidth, this.renderHeight); this.Width = this.sourceWidth; this.Height = this.sourceHeight; this.FitScreen = description.FitScreen; this.TextureIndex = 0; this.Color = description.Color; this.Manipulator = new Manipulator2D(); }
/// <summary> /// Updates renderer parameters /// </summary> private void UpdateRectangleAndView() { this.Width = this.Game.Form.RenderWidth; this.Height = this.Game.Form.RenderHeight; this.Viewport = new Viewport(0, 0, this.Width, this.Height, 0, 1.0f); this.ViewProjection = Sprite.CreateViewOrthoProjection(this.Width, this.Height); this.lightDrawer.Update(this.Game.Graphics, this.Width, this.Height); }
/// <summary> /// Resize /// </summary> public virtual void Resize() { int width = this.Game.Form.RenderWidth.NextPair(); int height = this.Game.Form.RenderHeight.NextPair(); this.viewProjection = Sprite.CreateViewOrthoProjection(width, height); if (this.FitScreen) { float w = width / (float)this.renderWidth; float h = height / (float)this.renderHeight; this.Width = ((int)(this.sourceWidth * w)).NextPair(); this.Height = ((int)(this.sourceHeight * h)).NextPair(); } }
/// <summary> /// Constructor /// </summary> /// <param name="scene">Scene</param> /// <param name="description">Text description</param> public TextDrawer(Scene scene, TextDrawerDescription description) : base(scene, description) { this.Font = string.Format("{0} {1}", description.Font, description.FontSize); this.viewProjection = Sprite.CreateViewOrthoProjection( this.Game.Form.RenderWidth.NextPair(), this.Game.Form.RenderHeight.NextPair()); this.fontMap = FontMap.Map(this.Game, description.Font, description.FontSize, description.Style); VertexPositionTexture[] verts = new VertexPositionTexture[FontMap.MAXTEXTLENGTH * 4]; uint[] idx = new uint[FontMap.MAXTEXTLENGTH * 6]; this.vertexBuffer = this.BufferManager.Add(description.Name, verts, true, 0); this.indexBuffer = this.BufferManager.Add(description.Name, idx, true); this.TextColor = description.TextColor; this.ShadowColor = description.ShadowColor; this.ShadowDelta = description.ShadowDelta; this.MapText(); }
/// <summary> /// Resize /// </summary> public void Resize() { this.viewProjection = Sprite.CreateViewOrthoProjection( this.Game.Form.RenderWidth.NextPair(), this.Game.Form.RenderHeight.NextPair()); }