Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            //base.OnRenderFrame(e);

            DualityApp.Render(null, new Rect(viewportWidth, viewportHeight), new Vector2(viewportWidth, viewportHeight));

            SwapBuffers();
        }
Esempio n. 3
0
 void INativeWindow.Run()
 {
     while (DualityApp.ExecContext != DualityApp.ExecutionContext.Terminated)
     {
         DualityApp.Update();
         DualityApp.Render(null, new Rect(DualityApp.UserData.WindowSize), DualityApp.UserData.WindowSize);
     }
 }
Esempio n. 4
0
 void INativeWindow.Run()
 {
     while (DualityApp.ExecContext != DualityApp.ExecutionContext.Terminated)
     {
         DualityApp.Update();
         DualityApp.Render(null, new Rect(640, 480), new Vector2(640, 480));
     }
 }
Esempio n. 5
0
 void INativeWindow.Run()
 {
     while (DualityApp.ExecContext != DualityApp.ExecutionContext.Terminated)
     {
         DualityApp.Update();
         DualityApp.Render(new Rect(DualityApp.UserData.GfxWidth, DualityApp.UserData.GfxHeight));
     }
 }
Esempio n. 6
0
 protected override void OnRenderState()
 {
     // Render game pov
     if (!Scene.Current.Cameras.Any())
     {
         DrawDevice.RenderVoid();
     }
     else
     {
         DualityApp.Render();
     }
 }
Esempio n. 7
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            if (DualityApp.ExecContext == DualityApp.ExecutionContext.Terminated)
            {
                return;
            }

            DualityApp.Render(new Rect(this.ClientSize.Width, this.ClientSize.Height));
            Profile.TimeRender.BeginMeasure();
            Profile.TimeSwapBuffers.BeginMeasure();
            this.SwapBuffers();
            Profile.TimeSwapBuffers.EndMeasure();
            Profile.TimeRender.EndMeasure();
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            if (DualityApp.ExecContext == DualityApp.ExecutionContext.Terminated)
            {
                return;
            }

            DualityApp.Render();
            Performance.TimeRender.BeginMeasure();
            Performance.TimeSwapBuffers.BeginMeasure();
            this.SwapBuffers();
            Performance.TimeSwapBuffers.EndMeasure();
            Performance.TimeRender.EndMeasure();
        }
Esempio n. 10
0
        private void OnRenderFrame(FrameEventArgs e)
        {
            if (DualityApp.ExecContext == DualityApp.ExecutionContext.Terminated)
            {
                return;
            }

            Vector2 imageSize;
            Rect    viewportRect;

            DualityApp.CalculateGameViewport(this.Size, out viewportRect, out imageSize);

            DualityApp.Render(null, viewportRect, imageSize);

            this.internalWindow.SwapBuffers();
        }
Esempio n. 11
0
        private void OnUpdate(double milliseconds)
        {
            if (DualityApp.ExecContext == DualityApp.ExecutionContext.Terminated)
            {
                return;
            }

            DualityApp.Update();

            Vector2 imageSize;
            Rect    viewportRect;

            DualityApp.CalculateGameViewport(this.Size, out viewportRect, out imageSize);

            DualityApp.Render(null, viewportRect, imageSize);

            window.Invoke("requestAnimationFrame", updateDelegate);
        }
Esempio n. 12
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            // you only need to call this if you have delegates
            // registered that you want to have called
            base.OnRenderFrame(e);

            if (DualityApp.ExecContext == DualityApp.ExecutionContext.Terminated)
            {
                return;
            }

            DualityApp.Render(new Rect(this.MinimumWidth, MinimumHeight));
            Profile.TimeRender.BeginMeasure();
            Profile.TimeSwapBuffers.BeginMeasure();
            SwapBuffers();
            Profile.TimeSwapBuffers.EndMeasure();
            Profile.TimeRender.EndMeasure();
        }