Example #1
0
 /// <summary>
 /// Make the GameWindow rendering context current
 /// </summary>
 public void MakeCurrent()
 {
     if (RenderControl != null)
     {
         RenderControl.MakeCurrent();
     }
 }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LayoutForm_Load(object sender, EventArgs e)
        {
            RenderControl.MakeCurrent();
            Display.Init();

            Batch = new SpriteBatch();
        }
Example #3
0
        /// <summary>
        /// Time to paint my dear !
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RenderControl_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            RenderControl.MakeCurrent();

            // Stop the draw timer
            DrawTimer.Stop();

            // Clear the background
            Display.ClearBuffers();

            Batch.Begin();

            // Background texture


            // Background texture
            Rectangle dst = new Rectangle(Point.Empty, RenderControl.Size);

            Batch.Draw(CheckerBoard, dst, dst, Color.White);


            // Draw the layout
            CurrentLayout.Draw(Batch);


            // Draw the selection box
            SelectionBox.Draw(Batch);

            // If no action and mouse over an element, draw its bounding box
            if (SelectionBox.MouseTool == MouseTools.NoTool)
            {
                Control elem = FindElementAt(RenderControl.PointToClient(System.Windows.Forms.Control.MousePosition));
                if (elem != null)
                {
                    //Display.DrawRectangle(elem.Rectangle, Color.White);
                }
            }

            Batch.End();
            RenderControl.SwapBuffers();

            // Start the draw timer
            DrawTimer.Start();
        }
Example #4
0
        /// <summary>
        /// On resize
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnResize(object sender, EventArgs e)
        {
            Trace.WriteDebugLine("[GameWindow] OnResize()");

            if (RenderControl == null)
            {
                Trace.WriteLine("[GameWindow] OnResize() : RenderControl is null !!");
                return;
            }

            if (RenderControl.Context == null)
            {
                Trace.WriteLine("[GameWindow] OnResize() : RenderControl.Context is null !!");
                return;
            }

            RenderControl.MakeCurrent();
            Display.ViewPort = new Rectangle(Point.Empty, RenderControl.Size);
        }
Example #5
0
        /// <summary>
        /// Control init
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLoad(object sender, EventArgs e)
        {
            Trace.WriteDebugLine("[GameWindow] Form_Load()");

            if (RenderControl == null)
            {
                Trace.WriteLine("[GameWindow] Form_Load() : RenderControl is null !!");
                return;
            }

            if (RenderControl.Context == null)
            {
                Trace.WriteDebugLine("[GameWindow] Form_Load() : RenderControl.Context == null");
                return;
            }

            // Initialization
            RenderControl.MakeCurrent();
            Display.Init();
            Display.Diagnostic();

            // Force the resize of the GLControl
            OnResize(null, null);
        }
Example #6
0
 /// <summary>
 /// Resize the render control
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void RenderControl_Resize(object sender, EventArgs e)
 {
     RenderControl.MakeCurrent();
     Display.ViewPort = new Rectangle(new Point(), RenderControl.Size);
 }