示例#1
0
        protected override void Draw(DemoTime time)
        {
            base.Draw(time);

            // Draw the TextLayout
            RenderTarget2D.DrawTextLayout(new Vector2(0, 0), TextLayout, SceneColorBrush, DrawTextOptions.None);
        }
示例#2
0
        /// <summary>
        /// Handles the Paint event of the renderControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        void RenderControlPaint(object sender, PaintEventArgs e)
        {
            try
            {
                RenderTarget2D.BeginDraw();

                RenderTarget2D.Clear(Color.White);

                RenderTarget2D.DrawTextLayout(new Vector2(0, 0), CurrentTextLayout, SceneColorBrush);

                RenderTarget2D.EndDraw();
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
示例#3
0
        /// <summary>
        /// Handles the Paint event of the renderControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        void renderControl_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                RenderTarget2D.BeginDraw();

                RenderTarget2D.Clear(Color.White);

                RenderTarget2D.DrawLine(new Vector2(0, 0), new Vector2(renderControl.ClientSize.Width, renderControl.ClientSize.Height), SceneColorBrush);
                RenderTarget2D.DrawLine(new Vector2(0, renderControl.ClientSize.Height), new Vector2(renderControl.ClientSize.Width, 0), SceneColorBrush);

                RenderTarget2D.DrawTextLayout(new Vector2(0, 0), CurrentTextLayout, SceneColorBrush);

                RenderTarget2D.EndDraw();
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
示例#4
0
        /// <summary>
        /// This method is called once per game loop after calling Update. Like Update, the Render()
        /// method is also called from the main class. This is the method where the graphics pipeline
        /// is constructed and processed for the frame using methods on the ID3D11DeviceContext instance.
        ///
        /// It’s important to understand that this call (or other similar Draw* calls defined on
        /// ID3D11DeviceContext) actually executes the pipeline.
        /// https://msdn.microsoft.com/en-us/library/windows/desktop/dn643746(v=vs.85).aspx
        ///
        /// Specifically, this is when Direct3D communicates with the GPU to set drawing state, runs
        /// each pipeline stage, and writes the pixel results into the render-target buffer resource
        /// for display by the swap chain.
        ///
        /// Since communication between the CPU and GPU incurs overhead, combine multiple draw calls
        /// into a single one if you can, especially if your scene has a lot of rendered objects.
        /// </summary>
        ///
        /// OnRender will Call each Active GameObjects to be Rendered
        protected override void OnRender()
        {
            //clear previous frame
            RenderTarget2D.Clear(null);

            //if display mouse coords  -- add a checkbox or option menu later \

            //Display Mouse coordinates:  top left corner : (0,0)
            TextLayout.Dispose();
            TextLayout = new TextLayout(FactoryDWrite, _mousePosition.GetMouseCoordinates(), TextFormat, 400, 40);
            RenderTarget2D.DrawTextLayout(new Vector2(0, 0), TextLayout, SceneColorBrush, DrawTextOptions.None);

            //and all added lines
            foreach (IRenderableItem item in _drawings)
            {
                item.Render(RenderTarget2D);
            }

            //Render current line if not null "?." operator
            ((IRenderableItem)_currentDrawing)?.Render(RenderTarget2D);

            //At last, display GUI on top of everything
            _guiManager.Render(RenderTarget2D);
        }