public void OnMainLoop(object sender, EventArgs e) { _sprite.Begin(Dx9.SpriteFlags.AlphaBlend); _font.DrawString(_sprite, "Hello World", 0, 0, SD.Color.White); _sprite.Draw(_circleTexture, Vector3.Zero, _mousePosition, new Color4(SD.Color.White)); _sprite.End(); using (Dx9.Sprite s = new Dx9.Sprite(_control.Device)) { s.Begin(Dx9.SpriteFlags.AlphaBlend); s.Draw(_texture, Vector3.Zero, Vector3.Zero, new Color4(SD.Color.White)); UpdateCamera(); s.End(); } _shipSprite.Begin(Dx9.SpriteFlags.AlphaBlend); Matrix matrix = Matrix.Transformation2D(new Vector2(0, 0), 0.0f, new Vector2(1f, 1f), new Vector2(_shipVector3.X + 100f, _shipVector3.Y + 100f), _rotation, new Vector2(0f, 0f)); _shipSprite.Transform = matrix; _shipSprite.Draw(_shipTexture, Vector3.Zero, _shipVector3, SD.Color.White); UpdateCamera(); _shipSprite.End(); }
public void Render(GameTime RenderTime, SlimDX.Direct3D9.Sprite SpriteRenderer) { if (engine.crashed) { crashFade.FadeIn(); crashFadeBack.FadeIn(); } else { crashFade.FadeOut(); crashFadeBack.FadeOut(); } if (!crashFade.IsOut || engine.crashed) { crashFade.Update(RenderTime.Elapsed); crashFadeBack.Update(RenderTime.Elapsed); crashWait.Update(RenderTime.Elapsed); crashWait.FadeIn(); SpriteRenderer.Begin(SpriteFlags.SortTexture | SpriteFlags.SortDepthFrontToBack | SpriteFlags.AlphaBlend); System.Drawing.Rectangle rc = new System.Drawing.Rectangle(0, 0, size.x, size.y); SpriteRenderer.Draw(emptyTexture, rc, new SlimDX.Vector3(0, 0, 0), new SlimDX.Vector3(0, 0, 0.001f), new SlimDX.Color4(crashFadeBack.State * 0.8f, 0, 0, 0)); SpriteRenderer.Transform = SlimDX.Matrix.Translation(size.x / 2, size.y / 2, 0); SpriteRenderer.Transform = SlimDX.Matrix.Scaling(0.5f, 0.5f, 0.5f) * SpriteRenderer.Transform; SpriteRenderer.Draw(crashedTexture, new SlimDX.Vector3(128, 128, 0), new SlimDX.Vector3(0, 0, 0), new SlimDX.Color4(crashFade.State, 1, 1, 1)); SpriteRenderer.End(); if (crashWait.IsIn) { engine.RecoverAfterCrash(); crashWait.State = 0; } } }
public void Render(GameTime RenderTime, SlimDX.Direct3D9.Sprite SpriteRenderer) { if (!(block && blendFade.IsFadingOut)) { blendFade.Update(RenderTime.Elapsed); } if (!blendFade.IsOut) { SpriteRenderer.Transform = SlimDX.Matrix.Identity; System.Drawing.Rectangle rc = new System.Drawing.Rectangle(0, 0, size.x, size.y); SpriteRenderer.Draw(emptyTexture, rc, new SlimDX.Vector3(0, 0, 0), new SlimDX.Vector3(0, 0, 0), new SlimDX.Color4(blendFade.State, 0, 0, 0)); } }
public void Render(GameTime RenderTime, SlimDX.Direct3D9.Sprite SpriteRenderer) { // loading render rotationState += rotationSpeed * RenderTime.Elapsed; if (rotationState >= 1) { rotationState -= (float)System.Math.Floor(rotationState); } if (!engine.isLoading) { if (engine.loadingStack > 0 || engine.ResourceManager.IsLoading) { loadingDelayState += loadingDelay * RenderTime.Elapsed; if (loadingDelayState >= 1) { engine.isLoading = true; } } } else { if (engine.loadingStack == 0 && !engine.ResourceManager.IsLoading) { engine.isLoading = false; } loadingDelayState = 0; fadeOutState = 1; } if (fadeOutState > 0) { SpriteRenderer.Begin(SpriteFlags.SortTexture | SpriteFlags.SortDepthFrontToBack | SpriteFlags.AlphaBlend); SpriteRenderer.Transform = SlimDX.Matrix.Translation(size.x - 32, size.y - 32, 0); SpriteRenderer.Transform = SlimDX.Matrix.RotationZ(-(float)System.Math.PI * rotationState * 2) * SpriteRenderer.Transform; SpriteRenderer.Transform = SlimDX.Matrix.Scaling(1.5f, 1.5f, 1.5f) * SpriteRenderer.Transform; SpriteRenderer.Draw(loadingTexture, new SlimDX.Vector3(16, 16, 0), new SlimDX.Vector3(0, 0, 0), new SlimDX.Color4(fadeOutState, 1, 1, 1)); SpriteRenderer.End(); fadeOutState -= RenderTime.Elapsed * fadeOutSpeed; } }
void Render(GameTime RenderTime) { lock (queue) { if (queue.Count > 0) { render = queue.Dequeue(); } } spriteRenderer.Begin(SpriteFlags.SortTexture | SpriteFlags.SortDepthFrontToBack | SpriteFlags.AlphaBlend); //if (engine.UseTextureFilter) //{ // device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic); // device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic); // device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Anisotropic); //} //else { device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point); device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point); device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Point); } // TODO engine scale spriteRenderer.Transform = SlimDX.Matrix.Scaling(new SlimDX.Vector3(renderScale, renderScale, 1)); SlimDX.Matrix lineMatrix = SlimDX.Matrix.AffineTransformation2D(1, new SlimDX.Vector2(), 0, new SlimDX.Vector2()); // TODO engine scale //lineMatrix = SlimDX.Matrix.Transformation2D(new SlimDX.Vector2(), 0, new SlimDX.Vector2(engine.Scale.x, engine.Scale.y), new SlimDX.Vector2(), 0, new SlimDX.Vector2()); lineMatrix = SlimDX.Matrix.Transformation2D(new SlimDX.Vector2(), 0, new SlimDX.Vector2(renderScale, renderScale), new SlimDX.Vector2(), 0, new SlimDX.Vector2()); lineMatrix = spriteRenderer.Transform; lineRenderer.Begin(); // application render engine.MainTarget.elapsed = RenderTime.Elapsed; float currentFactor = 1; if (render != null) { foreach (RenderEntity entity in render) { if (entity is SpriteEntity) { SpriteEntity sprite = entity as SpriteEntity; // diposed texture links may remain in queue after direct3d reset, just skip them if (sprite.Texture.Disposed) { continue; } // if sprite resolution changed, then update transform matrix if (currentFactor != sprite.Factor) { currentFactor = sprite.Factor; // TODO engine scale //spriteRenderer.Transform = SlimDX.Matrix.Scaling(new SlimDX.Vector3(engine.Scale.x * sprite.Factor, engine.Scale.y * sprite.Factor, 1)); spriteRenderer.Transform = SlimDX.Matrix.Scaling(new SlimDX.Vector3(renderScale * sprite.Factor, renderScale * sprite.Factor, 1)); } // recompute position for not 1:1 sprite resolutions SlimDX.Vector3 pos = sprite.Position; if (currentFactor != 1) { pos.X /= currentFactor; pos.Y /= currentFactor; } spriteRenderer.Draw(sprite.Texture, sprite.Rectangle, new SlimDX.Vector3(0, 0, 0), pos, sprite.Color); } else if (entity is LineEntity) { LineEntity line = entity as LineEntity; SlimDX.Vector3[] vec = new SlimDX.Vector3[] { line.Start, line.End }; SlimDX.Vector4[] v = SlimDX.Vector3.Transform(vec, ref lineMatrix); SlimDX.Vector2[] vec2 = new SlimDX.Vector2[] { new SlimDX.Vector2(v[0].X, v[0].Y), new SlimDX.Vector2(v[1].X, v[1].Y) }; lineRenderer.Draw(vec2, line.Color); } } } lineRenderer.End(); blendOverlay.BlockFadeOut = engine.IsLoading || blockBlend; blendOverlay.Render(RenderTime, spriteRenderer); if (engine.MusicBlend) { engine.Music.Volume = 1 - BlendState; } else { engine.Music.Volume = 1; } spriteRenderer.End(); errorOverlay.Render(RenderTime, spriteRenderer); loadingOverlay.Render(RenderTime, spriteRenderer); }