/// <inheritdoc /> protected override void OnRenderState() { // We're not calling the base implementation, because the default is to // render the scene from the view of an editing camera. The Game View, however, // is in the special position to render the actual game and completely ignore // any editing camera. // // base.OnRenderState(); Point2 clientSize = new Point2(this.RenderableControl.ClientSize.Width, this.RenderableControl.ClientSize.Height); Point2 targetSize = this.TargetRenderSize; Rect windowRect = this.LocalGameWindowRect; Vector2 imageSize; Rect viewportRect; DualityApp.CalculateGameViewport(targetSize, out viewportRect, out imageSize); // Render the game view background using a background color matching editor UI, // so users can discern between an area that isn't rendered to and a rendered // area of the game that happens to be black or outside the game viewport. DrawDevice.RenderVoid(new Rect(clientSize), new ColorRgba(64, 64, 64)); if (this.UseOffscreenBuffer) { // Render the scene to an offscreen buffer of matching size first this.SetupOutputRenderTarget(); DualityApp.Render(this.outputTarget, viewportRect, imageSize); // Blit the offscreen buffer to the window area this.SetupBlitDevice(); this.blitDevice.TargetSize = clientSize; this.blitDevice.ViewportRect = new Rect(clientSize); BatchInfo blitMaterial = this.blitDevice.RentMaterial(); blitMaterial.Technique = DrawTechnique.Solid; blitMaterial.MainTexture = this.outputTexture; TargetResize blitResize = this.TargetSizeFitsClientArea ? TargetResize.None : TargetResize.Fit; this.blitDevice.PrepareForDrawcalls(); this.blitDevice.AddFullscreenQuad(blitMaterial, blitResize); this.blitDevice.Render(); } else { Rect windowViewportRect = new Rect( windowRect.X + viewportRect.X, windowRect.Y + viewportRect.Y, viewportRect.W, viewportRect.H); // Render the scene centered into the designated viewport area this.CleanupRenderTarget(); DrawDevice.RenderVoid(windowRect); DualityApp.Render(null, windowViewportRect, imageSize); } }
protected override void OnRenderState() { // Render game pov if (!Scene.Current.Cameras.Any()) { DrawDevice.RenderVoid(); } else { DualityApp.Render(); } }
protected override void OnRenderState() { // Render game pov Rect viewportRect = new Rect(this.ClientSize.Width, this.ClientSize.Height); if (!Scene.Current.FindComponents <Camera>().Any()) { DrawDevice.RenderVoid(viewportRect); } else { DualityApp.Render(viewportRect); } }
private void OnResize(EventArgs e) { DualityApp.WindowSize = this.Size; DrawDevice.RenderVoid(new Rect(this.Size)); }